Chromium Code Reviews| Index: chrome/browser/resources/options/chromeos/display_options.js |
| diff --git a/chrome/browser/resources/options/chromeos/display_options.js b/chrome/browser/resources/options/chromeos/display_options.js |
| index 3eeaf0a80a343e601d4e0a2c4164f5df30de3b61..d4e555f2d233982456b757d3131134c092d931a0 100644 |
| --- a/chrome/browser/resources/options/chromeos/display_options.js |
| +++ b/chrome/browser/resources/options/chromeos/display_options.js |
| @@ -116,6 +116,18 @@ cr.define('options', function() { |
| */ |
| mirroring_: false, |
| + /* |
| + * Whether the unified desktop is enable or not. |
| + * @private |
| + */ |
| + unified_desktop_enabled_: false, |
| + |
| + /* |
| + * Whether the unified desktop option should be present. |
| + * @private |
| + */ |
| + show_unified_desktop_option_: false, |
| + |
| /** |
| * The current secondary display layout. |
| * @private |
| @@ -220,6 +232,12 @@ cr.define('options', function() { |
| $('display-options-done').onclick = function() { |
| PageManager.closeOverlay(); |
| }; |
| + |
| + $('display-options-toggle-unified-desktop').onclick = (function() { |
| + this.unified_desktop_enabled_ = !this.unified_desktop_enabled_; |
| + chrome.send('setUnifiedDesktopEnabled', |
| + [this.unified_desktop_enabled_]); |
| + }).bind(this); |
| }, |
| /** @override */ |
| @@ -243,11 +261,16 @@ cr.define('options', function() { |
| * Enables or disables the page. When disabled, the page will not be able to |
| * open, and will close if currently opened. |
| * @param {boolean} enabled Whether the page should be enabled. |
| + * @param {boolean} showUnifiedDesktop Whether the unified desktop option |
| + * should be present. |
| */ |
| - setEnabled: function(enabled) { |
| - if (this.enabled_ == enabled) |
| + setEnabled: function(enabled, showUnifiedDesktop) { |
| + if (this.enabled_ == enabled && |
| + this.show_unified_desktop_option_ == showUnifiedDesktop) { |
|
Jun Mukai
2015/05/20 02:47:49
name should be camelcased. showUnifiedDesktopOptio
oshima
2015/05/20 06:40:01
Done.
|
| return; |
| + } |
| this.enabled_ = enabled; |
| + this.show_unified_desktop_option_ = showUnifiedDesktop; |
| if (!enabled && this.visible) |
| PageManager.closeOverlay(); |
| }, |
| @@ -931,14 +954,15 @@ cr.define('options', function() { |
| /** |
| * Called when the display arrangement has changed. |
| - * @param {boolean} mirroring Whether current mode is mirroring or not. |
| + * @param {string} multi display mode: one of 'mirror', 'unified', |
|
Jun Mukai
2015/05/20 02:47:49
It's better to be an enum rather than a string. S
oshima
2015/05/20 06:40:01
Done.
|
| + * 'extended'. |
| * @param {Array<options.DisplayInfo>} displays The list of the display |
| * information. |
| * @param {options.SecondaryDisplayLayout} layout The layout strategy. |
| * @param {number} offset The offset of the secondary display. |
| * @private |
| */ |
| - onDisplayChanged_: function(mirroring, displays, layout, offset) { |
| + onDisplayChanged_: function(mode, displays, layout, offset) { |
| if (!this.visible) |
| return; |
| @@ -952,20 +976,25 @@ cr.define('options', function() { |
| this.layout_ = layout; |
| + var mirroring = mode == 'mirror'; |
| + var unifiedDesktopEnabled = mode == 'unified'; |
| + |
| $('display-options-toggle-mirroring').textContent = |
| loadTimeData.getString( |
| mirroring ? 'stopMirroring' : 'startMirroring'); |
| // Focus to the first display next to the primary one when |displays| list |
| // is updated. |
| - if (mirroring) { |
| + if (mirroring || unifiedDesktopEnabled) { |
| this.focusedIndex_ = null; |
| } else if (this.mirroring_ != mirroring || |
| + this.unified_desktop_enabled_ != unifiedDesktopEnabled || |
| this.displays_.length != displays.length) { |
| this.focusedIndex_ = 0; |
| } |
| this.mirroring_ = mirroring; |
| + this.unified_desktop_enabled_ = unifiedDesktopEnabled; |
| this.displays_ = displays; |
| this.resetDisplaysView_(); |
| @@ -974,14 +1003,28 @@ cr.define('options', function() { |
| else |
| this.layoutDisplays_(); |
| + $('display-options-unified-desktop').hidden = |
| + !this.show_unified_desktop_option_; |
| + |
| + $('display-options-toggle-unified-desktop').checked = |
| + this.unified_desktop_enabled_; |
| + |
| + var disableUnifiedDesktopOption = |
| + (this.mirroring_ || |
| + (!this.unified_desktop_enabled_ && |
| + this.displays_.length == 1)); |
| + |
| + $('display-options-toggle-unified-desktop').disabled = |
| + disableUnifiedDesktopOption; |
| + |
| this.updateSelectedDisplayDescription_(); |
| } |
| }; |
| DisplayOptions.setDisplayInfo = function( |
| - mirroring, displays, layout, offset) { |
| + mode, displays, layout, offset) { |
| DisplayOptions.getInstance().onDisplayChanged_( |
| - mirroring, displays, layout, offset); |
| + mode, displays, layout, offset); |
| }; |
| // Export |