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 {HTMLElement} sendCtrlAltDel
17 * @param {HTMLElement} sendPrtScrn
18 * @param {HTMLElement} resizeToClient
19 * @param {HTMLElement} shrinkToFit
20 * @param {HTMLElement?} fullscreen
23 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
24 resizeToClient, shrinkToFit, fullscreen) {
25 this.sendCtrlAltDel_ = sendCtrlAltDel;
26 this.sendPrtScrn_ = sendPrtScrn;
27 this.resizeToClient_ = resizeToClient;
28 this.shrinkToFit_ = shrinkToFit;
29 this.fullscreen_ = fullscreen;
31 * @type {remoting.ClientSession}
34 this.clientSession_ = null;
36 this.sendCtrlAltDel_.addEventListener(
37 'click', this.onSendCtrlAltDel_.bind(this), false);
38 this.sendPrtScrn_.addEventListener(
39 'click', this.onSendPrtScrn_.bind(this), false);
40 this.resizeToClient_.addEventListener(
41 'click', this.onResizeToClient_.bind(this), false);
42 this.shrinkToFit_.addEventListener(
43 'click', this.onShrinkToFit_.bind(this), false);
44 if (this.fullscreen_) {
45 this.fullscreen_.addEventListener(
46 'click', this.onFullscreen_.bind(this), false);
51 * @param {remoting.ClientSession} clientSession The active session, or null if
52 * there is no connection.
54 remoting.OptionsMenu.prototype.setClientSession = function(clientSession) {
55 this.clientSession_ = clientSession;
58 remoting.OptionsMenu.prototype.onShow = function() {
59 if (this.clientSession_) {
60 remoting.MenuButton.select(
61 this.resizeToClient_, this.clientSession_.getResizeToClient());
62 remoting.MenuButton.select(
63 this.shrinkToFit_, this.clientSession_.getShrinkToFit());
64 if (this.fullscreen_) {
65 remoting.MenuButton.select(
66 this.fullscreen_, remoting.fullscreen.isActive());
71 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
72 if (this.clientSession_) {
73 this.clientSession_.sendCtrlAltDel();
77 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
78 if (this.clientSession_) {
79 this.clientSession_.sendPrintScreen();
83 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
84 if (this.clientSession_) {
85 this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
86 !this.clientSession_.getResizeToClient());
90 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
91 if (this.clientSession_) {
92 this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
93 this.clientSession_.getResizeToClient());
97 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
98 remoting.fullscreen.toggle();