| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 return 1; | 247 return 1; |
| 234 }, | 248 }, |
| 235 | 249 |
| 236 /** | 250 /** |
| 237 * Returns the i18n string for the text to be used for mirroring settings. | 251 * Returns the i18n string for the text to be used for mirroring settings. |
| 238 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 252 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 239 * @return {string} i18n string for mirroring settings text. | 253 * @return {string} i18n string for mirroring settings text. |
| 240 * @private | 254 * @private |
| 241 */ | 255 */ |
| 242 getDisplayMirrorText_: function(displays) { | 256 getDisplayMirrorText_: function(displays) { |
| 243 return this.i18n( | 257 return this.i18n(this.isMirrored_(displays) ? 'toggleOn' : 'toggleOff'); |
| 244 this.isMirrored_(displays) ? 'displayMirrorOn' : 'displayMirrorOff'); | |
| 245 }, | 258 }, |
| 246 | 259 |
| 247 /** | 260 /** |
| 261 * @param {boolean} unifiedDesktopAvailable |
| 262 * @param {boolean} unifiedDesktopMode |
| 248 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 263 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 249 * @return {boolean} | 264 * @return {boolean} |
| 250 * @private | 265 * @private |
| 251 */ | 266 */ |
| 252 showMirror_: function(displays) { | 267 showUnifiedDesktop_: function( |
| 253 return this.isMirrored_(displays) || displays.length == 2; | 268 unifiedDesktopAvailable, unifiedDesktopMode, displays) { |
| 269 return unifiedDesktopMode || |
| 270 (unifiedDesktopAvailable && displays.length > 1 && |
| 271 !this.isMirrored_(displays)); |
| 254 }, | 272 }, |
| 255 | 273 |
| 256 /** | 274 /** |
| 275 * @param {boolean} unifiedDesktopMode |
| 276 * @return {string} |
| 277 * @private |
| 278 */ |
| 279 getUnifiedDesktopText_: function(unifiedDesktopMode) { |
| 280 return this.i18n(unifiedDesktopMode ? 'toggleOn' : 'toggleOff'); |
| 281 }, |
| 282 |
| 283 /** |
| 284 * @param {boolean} unifiedDesktopMode |
| 285 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 286 * @return {boolean} |
| 287 * @private |
| 288 */ |
| 289 showMirror_: function(unifiedDesktopMode, displays) { |
| 290 return this.isMirrored_(displays) || |
| 291 (!unifiedDesktopMode && displays.length == 2); |
| 292 }, |
| 293 |
| 294 /** |
| 257 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays | 295 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays |
| 258 * @return {boolean} | 296 * @return {boolean} |
| 259 * @private | 297 * @private |
| 260 */ | 298 */ |
| 261 isMirrored_: function(displays) { | 299 isMirrored_: function(displays) { |
| 262 return displays.length > 0 && !!displays[0].mirroringSourceId; | 300 return displays.length > 0 && !!displays[0].mirroringSourceId; |
| 263 }, | 301 }, |
| 264 | 302 |
| 265 /** | 303 /** |
| 266 * @param {!chrome.system.display.DisplayUnitInfo} display | 304 * @param {!chrome.system.display.DisplayUnitInfo} display |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 id = display.id; | 454 id = display.id; |
| 417 break; | 455 break; |
| 418 } | 456 } |
| 419 } | 457 } |
| 420 properties.mirroringSourceId = this.primaryDisplayId; | 458 properties.mirroringSourceId = this.primaryDisplayId; |
| 421 } | 459 } |
| 422 settings.display.systemDisplayApi.setDisplayProperties( | 460 settings.display.systemDisplayApi.setDisplayProperties( |
| 423 id, properties, this.setPropertiesCallback_.bind(this)); | 461 id, properties, this.setPropertiesCallback_.bind(this)); |
| 424 }, | 462 }, |
| 425 | 463 |
| 464 /** @private */ |
| 465 onUnifiedDesktopTap_: function() { |
| 466 settings.display.systemDisplayApi.enableUnifiedDesktop( |
| 467 !this.unifiedDesktopMode_); |
| 468 }, |
| 469 |
| 426 /** | 470 /** |
| 427 * @param {!Event} e | 471 * @param {!Event} e |
| 428 * @private | 472 * @private |
| 429 */ | 473 */ |
| 430 onOverscanTap_: function(e) { | 474 onOverscanTap_: function(e) { |
| 431 e.preventDefault(); | 475 e.preventDefault(); |
| 432 this.overscanDisplayId = this.selectedDisplay.id; | 476 this.overscanDisplayId = this.selectedDisplay.id; |
| 433 this.showOverscanDialog_(true); | 477 this.showOverscanDialog_(true); |
| 434 }, | 478 }, |
| 435 | 479 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 447 primaryDisplay = display; | 491 primaryDisplay = display; |
| 448 if (this.selectedDisplay && display.id == this.selectedDisplay.id) | 492 if (this.selectedDisplay && display.id == this.selectedDisplay.id) |
| 449 selectedDisplay = display; | 493 selectedDisplay = display; |
| 450 } | 494 } |
| 451 this.displayIds = displayIds; | 495 this.displayIds = displayIds; |
| 452 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; | 496 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; |
| 453 selectedDisplay = selectedDisplay || primaryDisplay || | 497 selectedDisplay = selectedDisplay || primaryDisplay || |
| 454 (this.displays && this.displays[0]); | 498 (this.displays && this.displays[0]); |
| 455 this.setSelectedDisplay_(selectedDisplay); | 499 this.setSelectedDisplay_(selectedDisplay); |
| 456 | 500 |
| 501 this.unifiedDesktopMode_ = !!primaryDisplay && primaryDisplay.isUnified; |
| 502 |
| 457 this.$.displayLayout.updateDisplays(this.displays, this.layouts); | 503 this.$.displayLayout.updateDisplays(this.displays, this.layouts); |
| 458 }, | 504 }, |
| 459 | 505 |
| 460 /** @private */ | 506 /** @private */ |
| 461 setPropertiesCallback_: function() { | 507 setPropertiesCallback_: function() { |
| 462 if (chrome.runtime.lastError) { | 508 if (chrome.runtime.lastError) { |
| 463 console.error( | 509 console.error( |
| 464 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); | 510 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); |
| 465 } | 511 } |
| 466 }, | 512 }, |
| 467 }); | 513 }); |
| OLD | NEW |