Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Unified Diff: remoting/webapp/options_menu.js

Issue 336293003: Refactor tool-bar event handlers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/webapp/event_handlers.js ('k') | remoting/webapp/session_connector.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/options_menu.js
diff --git a/remoting/webapp/options_menu.js b/remoting/webapp/options_menu.js
new file mode 100644
index 0000000000000000000000000000000000000000..f68ecebcf6a506f4600c47208861c6c9e0bd0d1b
--- /dev/null
+++ b/remoting/webapp/options_menu.js
@@ -0,0 +1,99 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview
+ * Class handling the in-session options menu (or menus in the case of apps v1).
+ */
+
+'use strict';
+
+/** @suppress {duplicate} */
+var remoting = remoting || {};
+
+/**
+ * @param {HTMLElement} sendCtrlAltDel
+ * @param {HTMLElement} sendPrtScrn
+ * @param {HTMLElement} resizeToClient
+ * @param {HTMLElement} shrinkToFit
+ * @param {HTMLElement?} fullscreen
+ * @constructor
+ */
+remoting.OptionsMenu = function(sendCtrlAltDel, sendPrtScrn,
+ resizeToClient, shrinkToFit, fullscreen) {
+ this.sendCtrlAltDel_ = sendCtrlAltDel;
+ this.sendPrtScrn_ = sendPrtScrn;
+ this.resizeToClient_ = resizeToClient;
+ this.shrinkToFit_ = shrinkToFit;
+ this.fullscreen_ = fullscreen;
+ /**
+ * @type {remoting.ClientSession}
+ * @private
+ */
+ this.clientSession_ = null;
+
+ this.sendCtrlAltDel_.addEventListener(
+ 'click', this.onSendCtrlAltDel_.bind(this), false);
+ this.sendPrtScrn_.addEventListener(
+ 'click', this.onSendPrtScrn_.bind(this), false);
+ this.resizeToClient_.addEventListener(
+ 'click', this.onResizeToClient_.bind(this), false);
+ this.shrinkToFit_.addEventListener(
+ 'click', this.onShrinkToFit_.bind(this), false);
+ if (this.fullscreen_) {
+ this.fullscreen_.addEventListener(
+ 'click', this.onFullscreen_.bind(this), false);
+ }
+};
+
+/**
+ * @param {remoting.ClientSession} clientSession The active session, or null if
+ * there is no connection.
+ */
+remoting.OptionsMenu.prototype.setClientSession = function(clientSession) {
+ this.clientSession_ = clientSession;
+};
+
+remoting.OptionsMenu.prototype.onShow = function() {
+ if (this.clientSession_) {
+ remoting.MenuButton.select(
+ this.resizeToClient_, this.clientSession_.getResizeToClient());
+ remoting.MenuButton.select(
+ this.shrinkToFit_, this.clientSession_.getShrinkToFit());
+ if (this.fullscreen_) {
+ remoting.MenuButton.select(
+ this.fullscreen_, remoting.fullscreen.isActive());
+ }
+ }
+};
+
+remoting.OptionsMenu.prototype.onSendCtrlAltDel_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.sendCtrlAltDel();
+ }
+};
+
+remoting.OptionsMenu.prototype.onSendPrtScrn_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.sendPrintScreen();
+ }
+};
+
+remoting.OptionsMenu.prototype.onResizeToClient_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.setScreenMode(this.clientSession_.getShrinkToFit(),
+ !this.clientSession_.getResizeToClient());
+ }
+};
+
+remoting.OptionsMenu.prototype.onShrinkToFit_ = function() {
+ if (this.clientSession_) {
+ this.clientSession_.setScreenMode(!this.clientSession_.getShrinkToFit(),
+ this.clientSession_.getResizeToClient());
+ }
+};
+
+remoting.OptionsMenu.prototype.onFullscreen_ = function() {
+ remoting.fullscreen.toggle();
+};
« no previous file with comments | « remoting/webapp/event_handlers.js ('k') | remoting/webapp/session_connector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698