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
24 remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
25 resizeToClient, shrinkToFit,
26 newConnection, fullscreen) {
27 this.sendCtrlAltDel_ = sendCtrlAltDel;
28 this.sendPrtScrn_ = sendPrtScrn;
29 this.resizeToClient_ = resizeToClient;
30 this.shrinkToFit_ = shrinkToFit;
31 this.newConnection_ = newConnection;
32 this.fullscreen_ = fullscreen;
34 * @type {remoting.ClientSession}
37 this.clientSession_ = null;
39 this.sendCtrlAltDel_.addEventListener(
40 'click', this.onSendCtrlAltDel_.bind(this), false);
41 this.sendPrtScrn_.addEventListener(
42 'click', this.onSendPrtScrn_.bind(this), false);
43 this.resizeToClient_.addEventListener(
44 'click', this.onResizeToClient_.bind(this), false);
45 this.shrinkToFit_.addEventListener(
46 'click', this.onShrinkToFit_.bind(this), false);
47 this.newConnection_.addEventListener(
48 'click', this.onNewConnection_.bind(this), false);
49 if (this.fullscreen_) {
50 this.fullscreen_.addEventListener(
51 'click', this.onFullscreen_.bind(this), false);
56 * @param {remoting.ClientSession} clientSession The active session, or null if
57 * there is no connection.
59 remoting.OptionsMenu.prototype.setClientSession = function(clientSession) {
60 this.clientSession_ = clientSession;
63 remoting.OptionsMenu.prototype.onShow = function() {
64 if (this.clientSession_) {
65 remoting.MenuButton.select(
66 this.resizeToClient_, this.clientSession_.getResizeToClient());
67 remoting.MenuButton.select(
68 this.shrinkToFit_, this.clientSession_.getShrinkToFit());
69 if (this.fullscreen_) {
70 remoting.MenuButton.select(
71 this.fullscreen_, remoting.fullscreen.isActive());
76 remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
77 if (this.clientSession_) {
78 this.clientSession_.sendCtrlAltDel();
82 remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
83 if (this.clientSession_) {
84 this.clientSession_.sendPrintScreen();
88 remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
89 if (this.clientSession_) {
90 this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
91 !this.clientSession_.getResizeToClient());
95 remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
96 if (this.clientSession_) {
97 this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
98 this.clientSession_.getResizeToClient());
102 remoting.OptionsMenu.prototype.onNewConnection_ = function() {
103 chrome.app.window.create('main.html', {
110 remoting.OptionsMenu.prototype.onFullscreen_ = function() {
111 remoting.fullscreen.toggle();