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.
7 * Class handling the in-session options menu (or menus in the case of apps v1).
12 /** @suppress {duplicate} */
13 var remoting = remoting || {};
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
25 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
26 resizeToClient, shrinkToFit,
27 newConnection, fullscreen,
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;
37 * @type {remoting.ClientSession}
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);
56 if (this.startStopRecording_) {
57 this.startStopRecording_.addEventListener(
58 'click', this.onStartStopRecording_.bind(this), false);
63 * @param {remoting.ClientSession} clientSession The active session, or null if
64 * there is no connection.
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());
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');
86 l10n.localizeElementFromTag(this.startStopRecording_,
87 /*i18n-content*/'START_RECORDING');
93 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
94 if (this.clientSession_) {
95 this.clientSession_.sendCtrlAltDel();
99 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
100 if (this.clientSession_) {
101 this.clientSession_.sendPrintScreen();
105 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
106 if (this.clientSession_) {
107 this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
108 !this.clientSession_.getResizeToClient());
112 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
113 if (this.clientSession_) {
114 this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
115 this.clientSession_.getResizeToClient());
119 remoting.OptionsMenu.prototype.onNewConnection_ = function() {
120 chrome.app.window.create('main.html', {
127 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
128 remoting.fullscreen.toggle();
131 remoting.OptionsMenu.prototype.onStartStopRecording_ = function() {
132 if (this.clientSession_) {
133 this.clientSession_.startStopRecording();