Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / remoting / webapp / options_menu.js
blobfce3bc9e9611d835b48afc14bd493b2acdbc1c4a
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 /**
6  * @fileoverview
7  * Class handling the in-session options menu (or menus in the case of apps v1).
8  */
10 'use strict';
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
15 /**
16  * @param {Element} sendCtrlAltDel
17  * @param {Element} sendPrtScrn
18  * @param {Element} resizeToClient
19  * @param {Element} shrinkToFit
20  * @param {Element} newConnection
21  * @param {Element?} fullscreen
22  * @param {Element?} startStopRecording
23  * @constructor
24  */
25 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
26                                 resizeToClient, shrinkToFit,
27                                 newConnection, fullscreen,
28                                 startStopRecording) {
29   this.sendCtrlAltDel_ = sendCtrlAltDel;
30   this.sendPrtScrn_ = sendPrtScrn;
31   this.resizeToClient_ = resizeToClient;
32   this.shrinkToFit_ = shrinkToFit;
33   this.newConnection_ = newConnection;
34   this.fullscreen_ = fullscreen;
35   this.startStopRecording_ = startStopRecording;
36   /**
37    * @type {remoting.ClientSession}
38    * @private
39    */
40   this.clientSession_ = null;
42   this.sendCtrlAltDel_.addEventListener(
43       'click', this.onSendCtrlAltDel_.bind(this), false);
44   this.sendPrtScrn_.addEventListener(
45       'click', this.onSendPrtScrn_.bind(this), false);
46   this.resizeToClient_.addEventListener(
47       'click', this.onResizeToClient_.bind(this), false);
48   this.shrinkToFit_.addEventListener(
49       'click', this.onShrinkToFit_.bind(this), false);
50   this.newConnection_.addEventListener(
51       'click', this.onNewConnection_.bind(this), false);
52   if (this.fullscreen_) {
53     this.fullscreen_.addEventListener(
54         'click', this.onFullscreen_.bind(this), false);
55   }
56   if (this.startStopRecording_) {
57     this.startStopRecording_.addEventListener(
58         'click', this.onStartStopRecording_.bind(this), false);
59   }
62 /**
63  * @param {remoting.ClientSession} clientSession The active session, or null if
64  *     there is no connection.
65  */
66 remoting.OptionsMenu.prototype.setClientSession = function(clientSession) {
67   this.clientSession_ = clientSession;
70 remoting.OptionsMenu.prototype.onShow = function() {
71   if (this.clientSession_) {
72     remoting.MenuButton.select(
73         this.resizeToClient_, this.clientSession_.getResizeToClient());
74     remoting.MenuButton.select(
75         this.shrinkToFit_, this.clientSession_.getShrinkToFit());
76     if (this.fullscreen_) {
77       remoting.MenuButton.select(
78           this.fullscreen_, remoting.fullscreen.isActive());
79     }
80     if (this.startStopRecording_) {
81       this.startStopRecording_.hidden = !this.clientSession_.canRecordVideo();
82       if (this.clientSession_.isRecordingVideo()) {
83         l10n.localizeElementFromTag(this.startStopRecording_,
84                                     /*i18n-content*/'STOP_RECORDING');
85       } else {
86         l10n.localizeElementFromTag(this.startStopRecording_,
87                                     /*i18n-content*/'START_RECORDING');
88       }
89     }
90   }
93 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
94   if (this.clientSession_) {
95     this.clientSession_.sendCtrlAltDel();
96   }
99 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
100   if (this.clientSession_) {
101     this.clientSession_.sendPrintScreen();
102   }
105 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
106   if (this.clientSession_) {
107     this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
108                                       !this.clientSession_.getResizeToClient());
109   }
112 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
113   if (this.clientSession_) {
114     this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
115                                       this.clientSession_.getResizeToClient());
116   }
119 remoting.OptionsMenu.prototype.onNewConnection_ = function() {
120   chrome.app.window.create('main.html', {
121     'width': 800,
122     'height': 600,
123     'frame': 'none'
124   });
127 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
128   remoting.fullscreen.toggle();
131 remoting.OptionsMenu.prototype.onStartStopRecording_ = function() {
132   if (this.clientSession_) {
133     this.clientSession_.startStopRecording();
134   }