| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * 'settings-display' is the settings subpage for display settings. | 7 * 'settings-display' is the settings subpage for display settings. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 cr.define('settings.display', function() { | 10 cr.define('settings.display', function() { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 selectedDisplay: Object, | 63 selectedDisplay: Object, |
| 64 | 64 |
| 65 /** Id passed to the overscan dialog. */ | 65 /** Id passed to the overscan dialog. */ |
| 66 overscanDisplayId: { | 66 overscanDisplayId: { |
| 67 type: String, | 67 type: String, |
| 68 notify: true, | 68 notify: true, |
| 69 }, | 69 }, |
| 70 | 70 |
| 71 /** @private {!Array<number>} Mode index values for slider. */ | 71 /** @private {!Array<number>} Mode index values for slider. */ |
| 72 modeValues_: Array, | 72 modeValues_: Array, |
| 73 |
| 74 /** @private */ |
| 75 unifiedDesktopAvailable_: { |
| 76 type: Boolean, |
| 77 value: function() { |
| 78 return loadTimeData.getBoolean('unifiedDesktopAvailable'); |
| 79 } |
| 80 }, |
| 81 |
| 82 /** @private */ |
| 83 unifiedDesktopMode_: { |
| 84 type: Boolean, |
| 85 value: false, |
| 86 }, |
| 73 }, | 87 }, |
| 74 | 88 |
| 75 /** @private {number} Selected mode index received from chrome. */ | 89 /** @private {number} Selected mode index received from chrome. */ |
| 76 currentSelectedModeIndex_: -1, | 90 currentSelectedModeIndex_: -1, |
| 77 | 91 |
| 78 /** | 92 /** |
| 79 * Listener for chrome.system.display.onDisplayChanged events. | 93 * Listener for chrome.system.display.onDisplayChanged events. |
| 80 * @type {function(void)|undefined} | 94 * @type {function(void)|undefined} |
| 81 * @private | 95 * @private |
| 82 */ | 96 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 129 |
| 116 /** @private */ | 130 /** @private */ |
| 117 onDisplayIdsChanged_: function() { | 131 onDisplayIdsChanged_: function() { |
| 118 // Close any overscan dialog (which will cancel any overscan operation) | 132 // Close any overscan dialog (which will cancel any overscan operation) |
| 119 // if displayIds changes. | 133 // if displayIds changes. |
| 120 this.showOverscanDialog_(false); | 134 this.showOverscanDialog_(false); |
| 121 }, | 135 }, |
| 122 | 136 |
| 123 /** @private */ | 137 /** @private */ |
| 124 getDisplayInfo_: function() { | 138 getDisplayInfo_: function() { |
| 139 /** @type {chrome.system.display.GetInfoFlags} */ var flags = { |
| 140 singleUnified: true |
| 141 }; |
| 125 settings.display.systemDisplayApi.getInfo( | 142 settings.display.systemDisplayApi.getInfo( |
| 126 this.displayInfoFetched_.bind(this)); | 143 flags, this.displayInfoFetched_.bind(this)); |
| 127 }, | 144 }, |
| 128 | 145 |
| 129 /** | 146 /** |
| 130 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 147 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 131 * @private | 148 * @private |
| 132 */ | 149 */ |
| 133 displayInfoFetched_: function(displays) { | 150 displayInfoFetched_: function(displays) { |
| 134 if (!displays.length) | 151 if (!displays.length) |
| 135 return; | 152 return; |
| 136 settings.display.systemDisplayApi.getDisplayLayout( | 153 settings.display.systemDisplayApi.getDisplayLayout( |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return 1; | 250 return 1; |
| 234 }, | 251 }, |
| 235 | 252 |
| 236 /** | 253 /** |
| 237 * Returns the i18n string for the text to be used for mirroring settings. | 254 * Returns the i18n string for the text to be used for mirroring settings. |
| 238 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 255 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 239 * @return {string} i18n string for mirroring settings text. | 256 * @return {string} i18n string for mirroring settings text. |
| 240 * @private | 257 * @private |
| 241 */ | 258 */ |
| 242 getDisplayMirrorText_: function(displays) { | 259 getDisplayMirrorText_: function(displays) { |
| 243 return this.i18n( | 260 return this.i18n(this.isMirrored_(displays) ? 'toggleOn' : 'toggleOff'); |
| 244 this.isMirrored_(displays) ? 'displayMirrorOn' : 'displayMirrorOff'); | |
| 245 }, | 261 }, |
| 246 | 262 |
| 247 /** | 263 /** |
| 264 * @param {boolean} unifiedDesktopAvailable |
| 265 * @param {boolean} unifiedDesktopMode |
| 248 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 266 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 249 * @return {boolean} | 267 * @return {boolean} |
| 250 * @private | 268 * @private |
| 251 */ | 269 */ |
| 252 showMirror_: function(displays) { | 270 showUnifiedDesktop_: function( |
| 253 return this.isMirrored_(displays) || displays.length == 2; | 271 unifiedDesktopAvailable, unifiedDesktopMode, displays) { |
| 272 return unifiedDesktopMode || |
| 273 (unifiedDesktopAvailable && displays.length > 1 && |
| 274 !this.isMirrored_(displays)); |
| 254 }, | 275 }, |
| 255 | 276 |
| 256 /** | 277 /** |
| 278 * @param {boolean} unifiedDesktopMode |
| 279 * @return {string} |
| 280 * @private |
| 281 */ |
| 282 getUnifiedDesktopText_: function(unifiedDesktopMode) { |
| 283 return this.i18n(unifiedDesktopMode ? 'toggleOn' : 'toggleOff'); |
| 284 }, |
| 285 |
| 286 /** |
| 287 * @param {boolean} unifiedDesktopMode |
| 288 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 289 * @return {boolean} |
| 290 * @private |
| 291 */ |
| 292 showMirror_: function(unifiedDesktopMode, displays) { |
| 293 return this.isMirrored_(displays) || |
| 294 (!unifiedDesktopMode && displays.length == 2); |
| 295 }, |
| 296 |
| 297 /** |
| 257 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 298 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 258 * @return {boolean} | 299 * @return {boolean} |
| 259 * @private | 300 * @private |
| 260 */ | 301 */ |
| 261 isMirrored_: function(displays) { | 302 isMirrored_: function(displays) { |
| 262 return displays.length > 0 && !!displays[0].mirroringSourceId; | 303 return displays.length > 0 && !!displays[0].mirroringSourceId; |
| 263 }, | 304 }, |
| 264 | 305 |
| 265 /** | 306 /** |
| 266 * @param {!chrome.system.display.DisplayUnitInfo} display | 307 * @param {!chrome.system.display.DisplayUnitInfo} display |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 id = display.id; | 457 id = display.id; |
| 417 break; | 458 break; |
| 418 } | 459 } |
| 419 } | 460 } |
| 420 properties.mirroringSourceId = this.primaryDisplayId; | 461 properties.mirroringSourceId = this.primaryDisplayId; |
| 421 } | 462 } |
| 422 settings.display.systemDisplayApi.setDisplayProperties( | 463 settings.display.systemDisplayApi.setDisplayProperties( |
| 423 id, properties, this.setPropertiesCallback_.bind(this)); | 464 id, properties, this.setPropertiesCallback_.bind(this)); |
| 424 }, | 465 }, |
| 425 | 466 |
| 467 /** @private */ |
| 468 onUnifiedDesktopTap_: function() { |
| 469 /** @type {!chrome.system.display.DisplayProperties} */ var properties = { |
| 470 isUnified: !this.unifiedDesktopMode_, |
| 471 }; |
| 472 settings.display.systemDisplayApi.setDisplayProperties( |
| 473 this.primaryDisplayId, properties, |
| 474 this.setPropertiesCallback_.bind(this)); |
| 475 }, |
| 476 |
| 426 /** | 477 /** |
| 427 * @param {!Event} e | 478 * @param {!Event} e |
| 428 * @private | 479 * @private |
| 429 */ | 480 */ |
| 430 onOverscanTap_: function(e) { | 481 onOverscanTap_: function(e) { |
| 431 e.preventDefault(); | 482 e.preventDefault(); |
| 432 this.overscanDisplayId = this.selectedDisplay.id; | 483 this.overscanDisplayId = this.selectedDisplay.id; |
| 433 this.showOverscanDialog_(true); | 484 this.showOverscanDialog_(true); |
| 434 }, | 485 }, |
| 435 | 486 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 447 primaryDisplay = display; | 498 primaryDisplay = display; |
| 448 if (this.selectedDisplay && display.id == this.selectedDisplay.id) | 499 if (this.selectedDisplay && display.id == this.selectedDisplay.id) |
| 449 selectedDisplay = display; | 500 selectedDisplay = display; |
| 450 } | 501 } |
| 451 this.displayIds = displayIds; | 502 this.displayIds = displayIds; |
| 452 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; | 503 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; |
| 453 selectedDisplay = selectedDisplay || primaryDisplay || | 504 selectedDisplay = selectedDisplay || primaryDisplay || |
| 454 (this.displays && this.displays[0]); | 505 (this.displays && this.displays[0]); |
| 455 this.setSelectedDisplay_(selectedDisplay); | 506 this.setSelectedDisplay_(selectedDisplay); |
| 456 | 507 |
| 508 this.unifiedDesktopMode_ = !!primaryDisplay && primaryDisplay.isUnified; |
| 509 |
| 457 this.$.displayLayout.updateDisplays(this.displays, this.layouts); | 510 this.$.displayLayout.updateDisplays(this.displays, this.layouts); |
| 458 }, | 511 }, |
| 459 | 512 |
| 460 /** @private */ | 513 /** @private */ |
| 461 setPropertiesCallback_: function() { | 514 setPropertiesCallback_: function() { |
| 462 if (chrome.runtime.lastError) { | 515 if (chrome.runtime.lastError) { |
| 463 console.error( | 516 console.error( |
| 464 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); | 517 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); |
| 465 } | 518 } |
| 466 }, | 519 }, |
| 467 }); | 520 }); |
| OLD | NEW |