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;
38 * @type {remoting.DesktopConnectedView}
41 this.desktopConnectedView_ = null;
43 this.sendCtrlAltDel_.addEventListener(
44 'click', this.onSendCtrlAltDel_.bind(this), false);
45 this.sendPrtScrn_.addEventListener(
46 'click', this.onSendPrtScrn_.bind(this), false);
47 this.resizeToClient_.addEventListener(
48 'click', this.onResizeToClient_.bind(this), false);
49 this.shrinkToFit_.addEventListener(
50 'click', this.onShrinkToFit_.bind(this), false);
51 this.newConnection_.addEventListener(
52 'click', this.onNewConnection_.bind(this), false);
53 if (this.fullscreen_) {
54 this.fullscreen_.addEventListener(
55 'click', this.onFullscreen_.bind(this), false);
57 if (this.startStopRecording_) {
58 this.startStopRecording_.addEventListener(
59 'click', this.onStartStopRecording_.bind(this), false);
64 * @param {remoting.DesktopConnectedView} desktopConnectedView The view for the
65 * active session, or null if there is no connection.
67 remoting.OptionsMenu.prototype.setDesktopConnectedView = function(
68 desktopConnectedView) {
69 this.desktopConnectedView_ = desktopConnectedView;
72 remoting.OptionsMenu.prototype.onShow = function() {
73 if (this.desktopConnectedView_) {
74 this.resizeToClient_.hidden =
75 this.desktopConnectedView_.getMode() ==
76 remoting.DesktopConnectedView.Mode.IT2ME;
77 remoting.MenuButton.select(
78 this.resizeToClient_, this.desktopConnectedView_.getResizeToClient());
79 remoting.MenuButton.select(
80 this.shrinkToFit_, this.desktopConnectedView_.getShrinkToFit());
81 if (this.fullscreen_) {
82 remoting.MenuButton.select(
83 this.fullscreen_, remoting.fullscreen.isActive());
85 if (this.startStopRecording_) {
86 this.startStopRecording_.hidden =
87 !this.desktopConnectedView_.canRecordVideo();
88 if (this.desktopConnectedView_.isRecordingVideo()) {
89 l10n.localizeElementFromTag(this.startStopRecording_,
90 /*i18n-content*/'STOP_RECORDING');
92 l10n.localizeElementFromTag(this.startStopRecording_,
93 /*i18n-content*/'START_RECORDING');
99 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
100 if (this.desktopConnectedView_) {
101 this.desktopConnectedView_.sendCtrlAltDel();
105 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
106 if (this.desktopConnectedView_) {
107 this.desktopConnectedView_.sendPrintScreen();
111 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
112 if (this.desktopConnectedView_) {
113 this.desktopConnectedView_.setScreenMode(
114 this.desktopConnectedView_.getShrinkToFit(),
115 !this.desktopConnectedView_.getResizeToClient());
119 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
120 if (this.desktopConnectedView_) {
121 this.desktopConnectedView_.setScreenMode(
122 !this.desktopConnectedView_.getShrinkToFit(),
123 this.desktopConnectedView_.getResizeToClient());
127 remoting.OptionsMenu.prototype.onNewConnection_ = function() {
128 chrome.app.window.create('main.html', {
135 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
136 remoting.fullscreen.toggle();
139 remoting.OptionsMenu.prototype.onStartStopRecording_ = function() {
140 if (this.desktopConnectedView_) {
141 this.desktopConnectedView_.startStopRecording();
146 * @type {remoting.OptionsMenu}
148 remoting.optionsMenu = null;