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

Side by Side Diff: remoting/webapp/window_frame.js

Issue 594503004: Move ownership of the tool-bar's menu buttons into remoting.Toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove MenuButton changes (will follow up with a better fix. Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « remoting/webapp/toolbar.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview 6 * @fileoverview
7 * Apps v2 custom title bar implementation 7 * Apps v2 custom title bar implementation
8 */ 8 */
9 9
10 'use strict'; 10 'use strict';
(...skipping 12 matching lines...) Expand all
23 */ 23 */
24 this.clientSession_ = null; 24 this.clientSession_ = null;
25 25
26 /** 26 /**
27 * @type {HTMLElement} 27 * @type {HTMLElement}
28 * @private 28 * @private
29 */ 29 */
30 this.titleBar_ = titleBar; 30 this.titleBar_ = titleBar;
31 31
32 /** 32 /**
33 * @type {remoting.OptionsMenu}
34 * @private
35 */
36 this.optionsMenu_ = new remoting.OptionsMenu(
37 titleBar.querySelector('.menu-send-ctrl-alt-del'),
38 titleBar.querySelector('.menu-send-print-screen'),
39 titleBar.querySelector('.menu-resize-to-client'),
40 titleBar.querySelector('.menu-shrink-to-fit'),
41 titleBar.querySelector('.menu-new-connection'),
42 titleBar.querySelector('.window-fullscreen'),
43 titleBar.querySelector('.menu-start-stop-recording'));
44
45 /**
46 * @type {HTMLElement} 33 * @type {HTMLElement}
47 * @private 34 * @private
48 */ 35 */
49 this.title_ = /** @type {HTMLElement} */ 36 this.title_ = /** @type {HTMLElement} */
50 (titleBar.querySelector('.window-title')); 37 (titleBar.querySelector('.window-title'));
51 base.debug.assert(this.title_ != null); 38 base.debug.assert(this.title_ != null);
52 39
53 /** 40 /**
54 * @type {HTMLElement} 41 * @type {HTMLElement}
55 * @private 42 * @private
56 */ 43 */
57 this.maximizeRestoreControl_ = /** @type {HTMLElement} */ 44 this.maximizeRestoreControl_ = /** @type {HTMLElement} */
58 (titleBar.querySelector('.window-maximize-restore')); 45 (titleBar.querySelector('.window-maximize-restore'));
59 base.debug.assert(this.maximizeRestoreControl_ != null); 46 base.debug.assert(this.maximizeRestoreControl_ != null);
60 47
61 var optionsButton = titleBar.querySelector('.window-options'); 48 var optionsButton = titleBar.querySelector('.window-options');
62 base.debug.assert(optionsButton != null); 49 base.debug.assert(optionsButton != null);
63 this.optionMenuButton_ = new remoting.MenuButton( 50 this.optionMenuButton_ = new remoting.MenuButton(
64 optionsButton, 51 optionsButton,
65 this.onShowOptionsMenu_.bind(this), 52 this.onShowOptionsMenu_.bind(this),
66 this.onHideOptionsMenu_.bind(this)); 53 this.onHideOptionsMenu_.bind(this));
67 54
68 /** 55 /**
69 * @type {HTMLElement} 56 * @type {HTMLElement}
70 * @private 57 * @private
71 */ 58 */
72 this.optionsMenuList_ = /** @type {HTMLElement} */ 59 this.optionsMenuList_ = /** @type {HTMLElement} */
73 (optionsButton.querySelector('.window-options-menu')); 60 (optionsButton.querySelector('.window-options-menu'));
74 base.debug.assert(this.optionsMenu_ != null); 61 base.debug.assert(this.optionsMenuList_ != null);
75 62
76 /** 63 /**
77 * @type {Array.<{cls:string, fn: function()}>} 64 * @type {Array.<{cls:string, fn: function()}>}
78 */ 65 */
79 var handlers = [ 66 var handlers = [
80 { cls: 'window-disconnect', fn: this.disconnectSession_.bind(this) }, 67 { cls: 'window-disconnect', fn: this.disconnectSession_.bind(this) },
81 { cls: 'window-maximize-restore', 68 { cls: 'window-maximize-restore',
82 fn: this.maximizeOrRestoreWindow_.bind(this) }, 69 fn: this.maximizeOrRestoreWindow_.bind(this) },
83 { cls: 'window-minimize', fn: this.minimizeWindow_.bind(this) }, 70 { cls: 'window-minimize', fn: this.minimizeWindow_.bind(this) },
84 { cls: 'window-close', fn: window.close.bind(window) }, 71 { cls: 'window-close', fn: window.close.bind(window) },
(...skipping 11 matching lines...) Expand all
96 this.handleWindowStateChange_.bind(this)); 83 this.handleWindowStateChange_.bind(this));
97 chrome.app.window.current().onRestored.addListener( 84 chrome.app.window.current().onRestored.addListener(
98 this.handleWindowStateChange_.bind(this)); 85 this.handleWindowStateChange_.bind(this));
99 chrome.app.window.current().onFullscreened.addListener( 86 chrome.app.window.current().onFullscreened.addListener(
100 this.handleWindowStateChange_.bind(this)); 87 this.handleWindowStateChange_.bind(this));
101 chrome.app.window.current().onFullscreened.addListener( 88 chrome.app.window.current().onFullscreened.addListener(
102 this.showWindowControlsPreview_.bind(this)); 89 this.showWindowControlsPreview_.bind(this));
103 }; 90 };
104 91
105 /** 92 /**
93 * @return {remoting.OptionsMenu}
94 */
95 remoting.WindowFrame.prototype.createOptionsMenu = function() {
96 return new remoting.OptionsMenu(
97 this.titleBar_.querySelector('.menu-send-ctrl-alt-del'),
98 this.titleBar_.querySelector('.menu-send-print-screen'),
99 this.titleBar_.querySelector('.menu-resize-to-client'),
100 this.titleBar_.querySelector('.menu-shrink-to-fit'),
101 this.titleBar_.querySelector('.menu-new-connection'),
102 this.titleBar_.querySelector('.window-fullscreen'),
103 this.titleBar_.querySelector('.menu-start-stop-recording'));
104 };
105
106 /**
106 * @param {remoting.ClientSession} clientSession The client session, or null if 107 * @param {remoting.ClientSession} clientSession The client session, or null if
107 * there is no connection. 108 * there is no connection.
108 */ 109 */
109 remoting.WindowFrame.prototype.setClientSession = function(clientSession) { 110 remoting.WindowFrame.prototype.setClientSession = function(clientSession) {
110 this.optionsMenu_.setClientSession(clientSession);
111 this.clientSession_ = clientSession; 111 this.clientSession_ = clientSession;
112 var windowTitle = document.head.querySelector('title'); 112 var windowTitle = document.head.querySelector('title');
113 if (this.clientSession_) { 113 if (this.clientSession_) {
114 this.title_.innerText = clientSession.getHostDisplayName(); 114 this.title_.innerText = clientSession.getHostDisplayName();
115 windowTitle.innerText = clientSession.getHostDisplayName() + ' - ' + 115 windowTitle.innerText = clientSession.getHostDisplayName() + ' - ' +
116 chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME'); 116 chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME');
117 } else { 117 } else {
118 this.title_.innerHTML = '&nbsp;'; 118 this.title_.innerHTML = '&nbsp;';
119 windowTitle.innerText = 119 windowTitle.innerText =
120 chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME'); 120 chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME');
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } else { 208 } else {
209 this.optionsMenuList_.classList.remove('right-align'); 209 this.optionsMenuList_.classList.remove('right-align');
210 } 210 }
211 }; 211 };
212 212
213 /** 213 /**
214 * Callback invoked when the options menu is shown. 214 * Callback invoked when the options menu is shown.
215 * @private 215 * @private
216 */ 216 */
217 remoting.WindowFrame.prototype.onShowOptionsMenu_ = function() { 217 remoting.WindowFrame.prototype.onShowOptionsMenu_ = function() {
218 this.optionsMenu_.onShow(); 218 remoting.optionsMenu.onShow();
219 this.titleBar_.classList.add('menu-opened'); 219 this.titleBar_.classList.add('menu-opened');
220 }; 220 };
221 221
222 /** 222 /**
223 * Callback invoked when the options menu is shown. 223 * Callback invoked when the options menu is shown.
224 * @private 224 * @private
225 */ 225 */
226 remoting.WindowFrame.prototype.onHideOptionsMenu_ = function() { 226 remoting.WindowFrame.prototype.onHideOptionsMenu_ = function() {
227 this.titleBar_.classList.remove('menu-opened'); 227 this.titleBar_.classList.remove('menu-opened');
228 }; 228 };
(...skipping 12 matching lines...) Expand all
241 var hidePreview = function() { 241 var hidePreview = function() {
242 target.classList.remove('preview'); 242 target.classList.remove('preview');
243 }; 243 };
244 target.classList.add('preview'); 244 target.classList.add('preview');
245 window.setTimeout(hidePreview, kPreviewTimeoutMs); 245 window.setTimeout(hidePreview, kPreviewTimeoutMs);
246 }; 246 };
247 247
248 248
249 /** @type {remoting.WindowFrame} */ 249 /** @type {remoting.WindowFrame} */
250 remoting.windowFrame = null; 250 remoting.windowFrame = null;
OLDNEW
« no previous file with comments | « remoting/webapp/toolbar.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698