| 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 /** | 10 /** |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 /** @private */ | 102 /** @private */ |
| 103 unifiedDesktopMode_: { | 103 unifiedDesktopMode_: { |
| 104 type: Boolean, | 104 type: Boolean, |
| 105 value: false, | 105 value: false, |
| 106 }, | 106 }, |
| 107 | 107 |
| 108 /** @private */ | 108 /** @private */ |
| 109 scheduleTypesList_: { | 109 scheduleTypesList_: { |
| 110 type: Array, | 110 type: Array, |
| 111 value: function() { | 111 value: function() { |
| 112 return [{ | 112 return [ |
| 113 name: loadTimeData.getString('displayNightLightScheduleNever'), | 113 { |
| 114 value: NightLightScheduleType.NEVER }, { | 114 name: loadTimeData.getString('displayNightLightScheduleNever'), |
| 115 name: loadTimeData.getString( | 115 value: NightLightScheduleType.NEVER |
| 116 'displayNightLightScheduleSunsetToSunRise'), | 116 }, |
| 117 value: NightLightScheduleType.SUNSET_TO_SUNRISE }, { | 117 { |
| 118 name: loadTimeData.getString('displayNightLightScheduleCustom'), | 118 name: loadTimeData.getString( |
| 119 value: NightLightScheduleType.CUSTOM }]; | 119 'displayNightLightScheduleSunsetToSunRise'), |
| 120 value: NightLightScheduleType.SUNSET_TO_SUNRISE |
| 121 }, |
| 122 { |
| 123 name: loadTimeData.getString('displayNightLightScheduleCustom'), |
| 124 value: NightLightScheduleType.CUSTOM |
| 125 } |
| 126 ]; |
| 120 }, | 127 }, |
| 121 }, | 128 }, |
| 122 | 129 |
| 123 /** @private */ | 130 /** @private */ |
| 124 shouldOpenCustomScheduleCollapse_: { | 131 shouldOpenCustomScheduleCollapse_: { |
| 125 type: Boolean, | 132 type: Boolean, |
| 126 value: false, | 133 value: false, |
| 127 }, | 134 }, |
| 128 }, | 135 }, |
| 129 | 136 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 */ | 239 */ |
| 233 setSelectedDisplay_: function(selectedDisplay) { | 240 setSelectedDisplay_: function(selectedDisplay) { |
| 234 // Set |currentSelectedModeIndex_| and |modeValues_| first since these | 241 // Set |currentSelectedModeIndex_| and |modeValues_| first since these |
| 235 // are not used directly in data binding. | 242 // are not used directly in data binding. |
| 236 var numModes = selectedDisplay.modes.length; | 243 var numModes = selectedDisplay.modes.length; |
| 237 if (numModes == 0) { | 244 if (numModes == 0) { |
| 238 this.modeValues_ = []; | 245 this.modeValues_ = []; |
| 239 this.currentSelectedModeIndex_ = 0; | 246 this.currentSelectedModeIndex_ = 0; |
| 240 } else { | 247 } else { |
| 241 this.modeValues_ = Array.from(Array(numModes).keys()); | 248 this.modeValues_ = Array.from(Array(numModes).keys()); |
| 242 this.currentSelectedModeIndex_ = this.getSelectedModeIndex_( | 249 this.currentSelectedModeIndex_ = |
| 243 selectedDisplay); | 250 this.getSelectedModeIndex_(selectedDisplay); |
| 244 } | 251 } |
| 245 // Set |selectedDisplay| first since only the resolution slider depends | 252 // Set |selectedDisplay| first since only the resolution slider depends |
| 246 // on |selectedModePref_|. | 253 // on |selectedModePref_|. |
| 247 this.selectedDisplay = selectedDisplay; | 254 this.selectedDisplay = selectedDisplay; |
| 248 this.set('selectedModePref_.value', this.currentSelectedModeIndex_); | 255 this.set('selectedModePref_.value', this.currentSelectedModeIndex_); |
| 249 }, | 256 }, |
| 250 | 257 |
| 251 /** | 258 /** |
| 252 * Returns true if the given display has touch support and is not an internal | 259 * Returns true if the given display has touch support and is not an internal |
| 253 * display. If the feature is not enabled via the switch, this will return | 260 * display. If the feature is not enabled via the switch, this will return |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 getResolutionText_: function() { | 382 getResolutionText_: function() { |
| 376 if (this.selectedDisplay.modes.length == 0 || | 383 if (this.selectedDisplay.modes.length == 0 || |
| 377 this.currentSelectedModeIndex_ == -1) { | 384 this.currentSelectedModeIndex_ == -1) { |
| 378 // If currentSelectedModeIndex_ == -1, selectedDisplay and | 385 // If currentSelectedModeIndex_ == -1, selectedDisplay and |
| 379 // |selectedModePref_.value| are not in sync. | 386 // |selectedModePref_.value| are not in sync. |
| 380 return this.i18n( | 387 return this.i18n( |
| 381 'displayResolutionText', this.selectedDisplay.bounds.width.toString(), | 388 'displayResolutionText', this.selectedDisplay.bounds.width.toString(), |
| 382 this.selectedDisplay.bounds.height.toString()); | 389 this.selectedDisplay.bounds.height.toString()); |
| 383 } | 390 } |
| 384 var mode = this.selectedDisplay.modes[ | 391 var mode = this.selectedDisplay.modes[ |
| 385 /** @type {number} */(this.selectedModePref_.value)]; | 392 /** @type {number} */ (this.selectedModePref_.value)]; |
| 386 assert(mode); | 393 assert(mode); |
| 387 var best = | 394 var best = |
| 388 this.selectedDisplay.isInternal ? mode.uiScale == 1.0 : mode.isNative; | 395 this.selectedDisplay.isInternal ? mode.uiScale == 1.0 : mode.isNative; |
| 389 var widthStr = mode.width.toString(); | 396 var widthStr = mode.width.toString(); |
| 390 var heightStr = mode.height.toString(); | 397 var heightStr = mode.height.toString(); |
| 391 if (best) | 398 if (best) |
| 392 return this.i18n('displayResolutionTextBest', widthStr, heightStr); | 399 return this.i18n('displayResolutionTextBest', widthStr, heightStr); |
| 393 else if (mode.isNative) | 400 else if (mode.isNative) |
| 394 return this.i18n('displayResolutionTextNative', widthStr, heightStr); | 401 return this.i18n('displayResolutionTextNative', widthStr, heightStr); |
| 395 return this.i18n('displayResolutionText', widthStr, heightStr); | 402 return this.i18n('displayResolutionText', widthStr, heightStr); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 */ | 467 */ |
| 461 onSelectedModeChange_: function() { | 468 onSelectedModeChange_: function() { |
| 462 if (this.currentSelectedModeIndex_ == -1 || | 469 if (this.currentSelectedModeIndex_ == -1 || |
| 463 this.currentSelectedModeIndex_ == this.selectedModePref_.value) { | 470 this.currentSelectedModeIndex_ == this.selectedModePref_.value) { |
| 464 // Don't change the selected display mode until we have received an update | 471 // Don't change the selected display mode until we have received an update |
| 465 // from Chrome and the mode differs from the current mode. | 472 // from Chrome and the mode differs from the current mode. |
| 466 return; | 473 return; |
| 467 } | 474 } |
| 468 /** @type {!chrome.system.display.DisplayProperties} */ var properties = { | 475 /** @type {!chrome.system.display.DisplayProperties} */ var properties = { |
| 469 displayMode: this.selectedDisplay.modes[ | 476 displayMode: this.selectedDisplay.modes[ |
| 470 /** @type {number} */(this.selectedModePref_.value)] | 477 /** @type {number} */ (this.selectedModePref_.value)] |
| 471 }; | 478 }; |
| 472 settings.display.systemDisplayApi.setDisplayProperties( | 479 settings.display.systemDisplayApi.setDisplayProperties( |
| 473 this.selectedDisplay.id, properties, | 480 this.selectedDisplay.id, properties, |
| 474 this.setPropertiesCallback_.bind(this)); | 481 this.setPropertiesCallback_.bind(this)); |
| 475 }, | 482 }, |
| 476 | 483 |
| 477 /** | 484 /** |
| 478 * @param {!Event} event | 485 * @param {!Event} event |
| 479 * @private | 486 * @private |
| 480 */ | 487 */ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 if (chrome.runtime.lastError) { | 573 if (chrome.runtime.lastError) { |
| 567 console.error( | 574 console.error( |
| 568 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); | 575 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); |
| 569 } | 576 } |
| 570 }, | 577 }, |
| 571 | 578 |
| 572 /** @private */ | 579 /** @private */ |
| 573 onScheduleTypeChanged_: function() { | 580 onScheduleTypeChanged_: function() { |
| 574 this.shouldOpenCustomScheduleCollapse_ = | 581 this.shouldOpenCustomScheduleCollapse_ = |
| 575 this.getPref('ash.night_light.schedule_type').value == | 582 this.getPref('ash.night_light.schedule_type').value == |
| 576 NightLightScheduleType.CUSTOM; | 583 NightLightScheduleType.CUSTOM; |
| 577 }, | 584 }, |
| 578 }); | 585 }); |
| OLD | NEW |