Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / remoting / webapp / crd / js / options_menu.js
blob6c855a8c55d6ee253f4e250dfebeb3fcac2e3103
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?} toggleStats
23 * @param {Element?} startStopRecording
24 * @constructor
26 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
27 resizeToClient, shrinkToFit,
28 newConnection, fullscreen, toggleStats,
29 startStopRecording) {
30 this.sendCtrlAltDel_ = sendCtrlAltDel;
31 this.sendPrtScrn_ = sendPrtScrn;
32 this.resizeToClient_ = resizeToClient;
33 this.shrinkToFit_ = shrinkToFit;
34 this.newConnection_ = newConnection;
35 this.fullscreen_ = fullscreen;
36 this.toggleStats_ = toggleStats;
37 this.startStopRecording_ = startStopRecording;
39 /** @private {remoting.DesktopConnectedView} */
40 this.desktopConnectedView_ = 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);
53 if (this.fullscreen_) {
54 fullscreen.addEventListener('click', this.onFullscreen_.bind(this), false);
56 if (this.toggleStats_) {
57 toggleStats.addEventListener(
58 'click', this.onToggleStats_.bind(this), false);
60 if (this.startStopRecording_) {
61 this.startStopRecording_.addEventListener(
62 'click', this.onStartStopRecording_.bind(this), false);
66 /**
67 * @param {remoting.DesktopConnectedView} desktopConnectedView The view for the
68 * active session, or null if there is no connection.
70 remoting.OptionsMenu.prototype.setDesktopConnectedView = function(
71 desktopConnectedView) {
72 this.desktopConnectedView_ = desktopConnectedView;
75 remoting.OptionsMenu.prototype.onShow = function() {
76 if (this.desktopConnectedView_) {
77 base.debug.assert(remoting.app instanceof remoting.DesktopRemoting);
78 var drApp = /** @type {remoting.DesktopRemoting} */ (remoting.app);
79 var mode = drApp.getConnectionMode();
81 this.resizeToClient_.hidden = mode === remoting.DesktopRemoting.Mode.IT2ME;
82 remoting.MenuButton.select(
83 this.resizeToClient_, this.desktopConnectedView_.getResizeToClient());
84 remoting.MenuButton.select(
85 this.shrinkToFit_, this.desktopConnectedView_.getShrinkToFit());
87 if (this.fullscreen_) {
88 remoting.MenuButton.select(
89 this.fullscreen_, remoting.fullscreen.isActive());
91 if (this.toggleStats_) {
92 remoting.MenuButton.select(
93 this.toggleStats_, this.desktopConnectedView_.isStatsVisible());
95 if (this.startStopRecording_) {
96 this.startStopRecording_.hidden =
97 !this.desktopConnectedView_.canRecordVideo();
98 if (this.desktopConnectedView_.isRecordingVideo()) {
99 l10n.localizeElementFromTag(this.startStopRecording_,
100 /*i18n-content*/'STOP_RECORDING');
101 } else {
102 l10n.localizeElementFromTag(this.startStopRecording_,
103 /*i18n-content*/'START_RECORDING');
109 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
110 if (this.desktopConnectedView_) {
111 this.desktopConnectedView_.sendCtrlAltDel();
115 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
116 if (this.desktopConnectedView_) {
117 this.desktopConnectedView_.sendPrintScreen();
121 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
122 if (this.desktopConnectedView_) {
123 this.desktopConnectedView_.setScreenMode(
124 this.desktopConnectedView_.getShrinkToFit(),
125 !this.desktopConnectedView_.getResizeToClient());
129 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
130 if (this.desktopConnectedView_) {
131 this.desktopConnectedView_.setScreenMode(
132 !this.desktopConnectedView_.getShrinkToFit(),
133 this.desktopConnectedView_.getResizeToClient());
137 remoting.OptionsMenu.prototype.onNewConnection_ = function() {
138 chrome.app.window.create('main.html', {
139 'width': 800,
140 'height': 600,
141 'frame': 'none'
145 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
146 remoting.fullscreen.toggle();
149 remoting.OptionsMenu.prototype.onToggleStats_ = function() {
150 if (this.desktopConnectedView_) {
151 this.desktopConnectedView_.toggleStats();
155 remoting.OptionsMenu.prototype.onStartStopRecording_ = function() {
156 if (this.desktopConnectedView_) {
157 this.desktopConnectedView_.startStopRecording();
162 * @type {remoting.OptionsMenu}
164 remoting.optionsMenu = null;