Chromium Code Reviews| Index: remoting/webapp/window_frame.js |
| diff --git a/remoting/webapp/window_frame.js b/remoting/webapp/window_frame.js |
| index 45dc18ef5182cb87f035bfc5c3752bc372f5e91a..7c6a75706482f478acd2ea968a32fd20378ee809 100644 |
| --- a/remoting/webapp/window_frame.js |
| +++ b/remoting/webapp/window_frame.js |
| @@ -18,10 +18,10 @@ var remoting = remoting || {}; |
| */ |
| remoting.WindowFrame = function(titleBar) { |
| /** |
| - * @type {boolean} |
| + * @type {remoting.ClientSession} |
| * @private |
| */ |
| - this.isConnected_ = false; |
| + this.clientSession_ = null; |
| /** |
| * @type {HTMLElement} |
| @@ -38,6 +38,26 @@ remoting.WindowFrame = function(titleBar) { |
| base.debug.assert(this.hoverTarget_ != null); |
| /** |
| + * @type {remoting.OptionsMenu} |
| + * @private |
| + */ |
| + this.optionsMenu_ = new remoting.OptionsMenu( |
| + titleBar.querySelector('.menu-send-ctrl-alt-del'), |
| + titleBar.querySelector('.menu-send-print-screen'), |
| + titleBar.querySelector('.menu-resize-to-client'), |
| + titleBar.querySelector('.menu-shrink-to-fit'), |
| + titleBar.querySelector('.menu-new-connection'), |
| + null); |
| + |
| + /** |
| + * @type {HTMLElement} |
| + * @private |
| + */ |
| + this.title_ = /** @type {HTMLElement} */ |
| + (titleBar.querySelector('.window-title')); |
| + base.debug.assert(this.title_ != null); |
| + |
| + /** |
| * @type {HTMLElement} |
| * @private |
| */ |
| @@ -45,6 +65,13 @@ remoting.WindowFrame = function(titleBar) { |
| (titleBar.querySelector('.window-maximize-restore')); |
| base.debug.assert(this.maximizeRestoreControl_ != null); |
| + var optionsButton = titleBar.querySelector('.window-options'); |
| + base.debug.assert(optionsButton != null); |
| + this.optionMenuButton_ = new remoting.MenuButton( |
| + optionsButton, |
| + this.onShowOptionsMenu_.bind(this), |
| + this.onHideOptionsMenu_.bind(this)); |
| + |
| /** |
| * @type {Array.<{cls:string, fn: function()}>} |
| */ |
| @@ -73,14 +100,23 @@ remoting.WindowFrame = function(titleBar) { |
| }; |
| /** |
| - * @param {boolean} isConnected True if there is a connection active. |
| + * @param {remoting.ClientSession} clientSession The client session, or null if |
| + * there is no connection. |
| */ |
| -remoting.WindowFrame.prototype.setConnected = function(isConnected) { |
| - this.isConnected_ = isConnected; |
| - if (this.isConnected_) { |
| +remoting.WindowFrame.prototype.setClientSession = function(clientSession) { |
| + this.optionsMenu_.setClientSession(clientSession); |
| + this.clientSession_ = clientSession; |
|
kelvinp
2014/07/23 18:49:08
It seems like clientSession_ is only used as a boo
Jamie
2014/07/23 20:00:38
We need a ClientSession in order to set the window
|
| + var windowTitle = document.head.querySelector('title'); |
| + if (this.clientSession_) { |
| document.body.classList.add('connected'); |
| + this.title_.innerText = clientSession.getHostDisplayName(); |
| + windowTitle.innerText = clientSession.getHostDisplayName() + ' - ' + |
| + chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME'); |
| } else { |
| document.body.classList.remove('connected'); |
| + this.title_.innerHTML = ' '; |
| + windowTitle.innerText = |
| + chrome.i18n.getMessage(/*i18n-content*/'PRODUCT_NAME'); |
| } |
| this.updateMaximizeOrRestoreIconTitle_(); |
| }; |
| @@ -129,7 +165,8 @@ remoting.WindowFrame.prototype.maximizeOrRestoreWindow_ = function() { |
| // If the app is not full-screen, or went full-screen without first |
| // being maximized, then the second restore has no effect. |
| chrome.app.window.current().restore(); |
| - } else if (this.isConnected_) { |
| + chrome.app.window.current().restore(); |
| + } else if (this.clientSession_) { |
| chrome.app.window.current().fullscreen(); |
| } else { |
| chrome.app.window.current().maximize(); |
| @@ -163,7 +200,7 @@ remoting.WindowFrame.prototype.updateMaximizeOrRestoreIconTitle_ = function() { |
| tag = /*i18n-content*/'EXIT_FULL_SCREEN'; |
| } else if (chrome.app.window.current().isMaximized()) { |
| tag = /*i18n-content*/'RESTORE_WINDOW'; |
| - } else if (this.isConnected_) { |
| + } else if (this.clientSession_) { |
| tag = /*i18n-content*/'FULL_SCREEN'; |
| } else { |
| tag = /*i18n-content*/'MAXIMIZE_WINDOW'; |
| @@ -171,5 +208,23 @@ remoting.WindowFrame.prototype.updateMaximizeOrRestoreIconTitle_ = function() { |
| this.maximizeRestoreControl_.title = l10n.getTranslationOrError(tag); |
| }; |
| +/** |
| + * Callback invoked when the options menu is shown. |
| + * @private |
| + */ |
| +remoting.WindowFrame.prototype.onShowOptionsMenu_ = function() { |
| + this.optionsMenu_.onShow(); |
| + this.hoverTarget_.classList.add('menu-opened'); |
| +}; |
| + |
| +/** |
| + * Callback invoked when the options menu is shown. |
| + * @private |
| + */ |
| +remoting.WindowFrame.prototype.onHideOptionsMenu_ = function() { |
| + this.hoverTarget_.classList.remove('menu-opened'); |
| +}; |
| + |
| + |
| /** @type {remoting.WindowFrame} */ |
| -remoting.windowFrame = null; |
| +remoting.windowFrame = null; |