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 * @group Chrome Settings Elements | 9 * @group Chrome Settings Elements |
10 */ | 10 */ |
(...skipping 14 matching lines...) Expand all Loading... |
25 ], | 25 ], |
26 | 26 |
27 properties: { | 27 properties: { |
28 /** | 28 /** |
29 * Array of displays. | 29 * Array of displays. |
30 * @type {!Array<!chrome.system.display.DisplayUnitInfo>} | 30 * @type {!Array<!chrome.system.display.DisplayUnitInfo>} |
31 */ | 31 */ |
32 displays: Array, | 32 displays: Array, |
33 | 33 |
34 /** | 34 /** |
| 35 * Array of display layouts. |
| 36 * @type {!Array<!chrome.system.display.DisplayLayout>} |
| 37 */ |
| 38 layouts: Array, |
| 39 |
| 40 /** |
35 * String listing the ids in displays. Used to observe changes to the | 41 * String listing the ids in displays. Used to observe changes to the |
36 * display configuration (i.e. when a display is added or removed). | 42 * display configuration (i.e. when a display is added or removed). |
37 */ | 43 */ |
38 displayIds: {type: String, observer: 'onDisplayIdsChanged_'}, | 44 displayIds: {type: String, observer: 'onDisplayIdsChanged_'}, |
39 | 45 |
40 /** Primary display id */ | 46 /** Primary display id */ |
41 primaryDisplayId: String, | 47 primaryDisplayId: String, |
42 | 48 |
43 /** @type {!chrome.system.display.DisplayUnitInfo|undefined} */ | 49 /** @type {!chrome.system.display.DisplayUnitInfo|undefined} */ |
44 selectedDisplay: {type: Object, observer: 'selectedDisplayChanged_'}, | 50 selectedDisplay: {type: Object, observer: 'selectedDisplayChanged_'}, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 onDisplayIdsChanged_: function() { | 106 onDisplayIdsChanged_: function() { |
101 // Close any overscan dialog (which will cancel any overscan operation) | 107 // Close any overscan dialog (which will cancel any overscan operation) |
102 // if displayIds changes. | 108 // if displayIds changes. |
103 this.showOverscanDialog_(false); | 109 this.showOverscanDialog_(false); |
104 }, | 110 }, |
105 | 111 |
106 /** @private */ | 112 /** @private */ |
107 getDisplayInfo_: function() { | 113 getDisplayInfo_: function() { |
108 settings.display.systemDisplayApi.getInfo( | 114 settings.display.systemDisplayApi.getInfo( |
109 this.updateDisplayInfo_.bind(this)); | 115 this.updateDisplayInfo_.bind(this)); |
| 116 settings.display.systemDisplayApi.getDisplayLayout( |
| 117 this.updateDisplayLayout_.bind(this)); |
110 }, | 118 }, |
111 | 119 |
112 /** | 120 /** |
113 * @param {!chrome.system.display.DisplayUnitInfo} selectedDisplay | 121 * @param {!chrome.system.display.DisplayUnitInfo} selectedDisplay |
114 * @return {number} | 122 * @return {number} |
115 * @private | 123 * @private |
116 */ | 124 */ |
117 getSelectedModeIndex_: function(selectedDisplay) { | 125 getSelectedModeIndex_: function(selectedDisplay) { |
118 for (var i = 0; i < selectedDisplay.modes.length; ++i) { | 126 for (var i = 0; i < selectedDisplay.modes.length; ++i) { |
119 if (selectedDisplay.modes[i].isSelected) | 127 if (selectedDisplay.modes[i].isSelected) |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 var widthStr = mode.width.toString(); | 208 var widthStr = mode.width.toString(); |
201 var heightStr = mode.height.toString(); | 209 var heightStr = mode.height.toString(); |
202 if (best) | 210 if (best) |
203 return this.i18n('displayResolutionTextBest', widthStr, heightStr); | 211 return this.i18n('displayResolutionTextBest', widthStr, heightStr); |
204 else if (mode.isNative) | 212 else if (mode.isNative) |
205 return this.i18n('displayResolutionTextNative', widthStr, heightStr); | 213 return this.i18n('displayResolutionTextNative', widthStr, heightStr); |
206 return this.i18n('displayResolutionText', widthStr, heightStr); | 214 return this.i18n('displayResolutionText', widthStr, heightStr); |
207 }, | 215 }, |
208 | 216 |
209 /** | 217 /** |
210 * @param {!{model: !{index: number}, target: !PaperButtonElement}} e | 218 * @param {!{detail: number}} e |
211 * @private | 219 * @private |
212 */ | 220 */ |
213 onSelectDisplayTap_: function(e) { | 221 onSelectDisplay_: function(e) { |
214 this.selectedDisplay = this.displays[e.model.index]; | 222 var index = e.detail; |
| 223 assert(index >= 0); |
| 224 if (index >= this.displays.length) |
| 225 return; |
| 226 this.selectedDisplay = this.displays[e.detail]; |
215 // Force active in case selected display was clicked. | 227 // Force active in case selected display was clicked. |
216 e.target.active = true; | 228 e.target.active = true; |
217 }, | 229 }, |
218 | 230 |
219 /** @private */ | 231 /** @private */ |
220 onMakePrimaryTap_: function() { | 232 onMakePrimaryTap_: function() { |
221 if (!this.selectedDisplay) | 233 if (!this.selectedDisplay) |
222 return; | 234 return; |
223 if (this.selectedDisplay.id == this.primaryDisplayId) | 235 if (this.selectedDisplay.id == this.primaryDisplayId) |
224 return; | 236 return; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 primaryDisplay = display; | 318 primaryDisplay = display; |
307 if (this.selectedDisplay && display.id == this.selectedDisplay.id) | 319 if (this.selectedDisplay && display.id == this.selectedDisplay.id) |
308 selectedDisplay = display; | 320 selectedDisplay = display; |
309 } | 321 } |
310 this.displayIds = displayIds; | 322 this.displayIds = displayIds; |
311 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; | 323 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; |
312 this.selectedDisplay = selectedDisplay || primaryDisplay || | 324 this.selectedDisplay = selectedDisplay || primaryDisplay || |
313 (this.displays && this.displays[0]); | 325 (this.displays && this.displays[0]); |
314 }, | 326 }, |
315 | 327 |
| 328 /** |
| 329 * @param {!Array<!chrome.system.display.DisplayLayout>} layouts |
| 330 * @private |
| 331 */ |
| 332 updateDisplayLayout_(layouts) { |
| 333 this.layouts = layouts; |
| 334 }, |
| 335 |
316 /** @private */ | 336 /** @private */ |
317 setPropertiesCallback_: function() { | 337 setPropertiesCallback_: function() { |
318 if (chrome.runtime.lastError) { | 338 if (chrome.runtime.lastError) { |
319 console.error( | 339 console.error( |
320 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); | 340 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); |
321 } | 341 } |
322 }, | 342 }, |
323 }); | 343 }); |
OLD | NEW |