Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: chrome/browser/resources/settings/device_page/display.js

Issue 2084673003: MD Settings: Add display layout (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_547080_display_settings6
Patch Set: Feedback Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 *
9 * @group Chrome Settings Elements
10 */ 8 */
11 9
12 cr.define('settings.display', function() { 10 cr.define('settings.display', function() {
13 var systemDisplayApi = /** @type {!SystemDisplay} */ (chrome.system.display); 11 var systemDisplayApi = /** @type {!SystemDisplay} */ (chrome.system.display);
14 12
15 return { 13 return {
16 systemDisplayApi: systemDisplayApi, 14 systemDisplayApi: systemDisplayApi,
17 }; 15 };
18 }); 16 });
19 17
20 Polymer({ 18 Polymer({
21 is: 'settings-display', 19 is: 'settings-display',
22 20
23 behaviors: [ 21 behaviors: [
24 I18nBehavior, 22 I18nBehavior,
25 ], 23 ],
26 24
27 properties: { 25 properties: {
28 /** 26 /**
29 * Array of displays. 27 * Array of displays.
30 * @type {!Array<!chrome.system.display.DisplayUnitInfo>} 28 * @type {!Array<!chrome.system.display.DisplayUnitInfo>}
31 */ 29 */
32 displays: Array, 30 displays: Array,
33 31
34 /** 32 /**
33 * Array of display layouts.
34 * @type {!Array<!chrome.system.display.DisplayLayout>}
35 */
36 layouts: Array,
37
38 /**
35 * String listing the ids in displays. Used to observe changes to the 39 * String listing the ids in displays. Used to observe changes to the
36 * display configuration (i.e. when a display is added or removed). 40 * display configuration (i.e. when a display is added or removed).
37 */ 41 */
38 displayIds: {type: String, observer: 'onDisplayIdsChanged_'}, 42 displayIds: {type: String, observer: 'onDisplayIdsChanged_'},
39 43
40 /** Primary display id */ 44 /** Primary display id */
41 primaryDisplayId: String, 45 primaryDisplayId: String,
42 46
43 /** @type {!chrome.system.display.DisplayUnitInfo|undefined} */ 47 /** @type {!chrome.system.display.DisplayUnitInfo|undefined} */
44 selectedDisplay: {type: Object, observer: 'selectedDisplayChanged_'}, 48 selectedDisplay: {type: Object, observer: 'selectedDisplayChanged_'},
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 onDisplayIdsChanged_: function() { 104 onDisplayIdsChanged_: function() {
101 // Close any overscan dialog (which will cancel any overscan operation) 105 // Close any overscan dialog (which will cancel any overscan operation)
102 // if displayIds changes. 106 // if displayIds changes.
103 this.showOverscanDialog_(false); 107 this.showOverscanDialog_(false);
104 }, 108 },
105 109
106 /** @private */ 110 /** @private */
107 getDisplayInfo_: function() { 111 getDisplayInfo_: function() {
108 settings.display.systemDisplayApi.getInfo( 112 settings.display.systemDisplayApi.getInfo(
109 this.updateDisplayInfo_.bind(this)); 113 this.updateDisplayInfo_.bind(this));
114 settings.display.systemDisplayApi.getDisplayLayout(
115 this.updateDisplayLayout_.bind(this));
110 }, 116 },
111 117
112 /** 118 /**
113 * @param {!chrome.system.display.DisplayUnitInfo} selectedDisplay 119 * @param {!chrome.system.display.DisplayUnitInfo} selectedDisplay
114 * @return {number} 120 * @return {number}
115 * @private 121 * @private
116 */ 122 */
117 getSelectedModeIndex_: function(selectedDisplay) { 123 getSelectedModeIndex_: function(selectedDisplay) {
118 for (var i = 0; i < selectedDisplay.modes.length; ++i) { 124 for (var i = 0; i < selectedDisplay.modes.length; ++i) {
119 if (selectedDisplay.modes[i].isSelected) 125 if (selectedDisplay.modes[i].isSelected)
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 var widthStr = mode.width.toString(); 206 var widthStr = mode.width.toString();
201 var heightStr = mode.height.toString(); 207 var heightStr = mode.height.toString();
202 if (best) 208 if (best)
203 return this.i18n('displayResolutionTextBest', widthStr, heightStr); 209 return this.i18n('displayResolutionTextBest', widthStr, heightStr);
204 else if (mode.isNative) 210 else if (mode.isNative)
205 return this.i18n('displayResolutionTextNative', widthStr, heightStr); 211 return this.i18n('displayResolutionTextNative', widthStr, heightStr);
206 return this.i18n('displayResolutionText', widthStr, heightStr); 212 return this.i18n('displayResolutionText', widthStr, heightStr);
207 }, 213 },
208 214
209 /** 215 /**
210 * @param {!{model: !{index: number}, target: !PaperButtonElement}} e 216 * @param {!{detail: number}} e
211 * @private 217 * @private
212 */ 218 */
213 onSelectDisplayTap_: function(e) { 219 onSelectDisplay_: function(e) {
214 this.selectedDisplay = this.displays[e.model.index]; 220 var index = e.detail;
221 assert(index >= 0);
222 if (index >= this.displays.length)
223 return;
224 this.selectedDisplay = this.displays[e.detail];
215 // Force active in case selected display was clicked. 225 // Force active in case selected display was clicked.
216 e.target.active = true; 226 e.target.active = true;
217 }, 227 },
218 228
219 /** @private */ 229 /** @private */
220 onMakePrimaryTap_: function() { 230 onMakePrimaryTap_: function() {
221 if (!this.selectedDisplay) 231 if (!this.selectedDisplay)
222 return; 232 return;
223 if (this.selectedDisplay.id == this.primaryDisplayId) 233 if (this.selectedDisplay.id == this.primaryDisplayId)
224 return; 234 return;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 primaryDisplay = display; 316 primaryDisplay = display;
307 if (this.selectedDisplay && display.id == this.selectedDisplay.id) 317 if (this.selectedDisplay && display.id == this.selectedDisplay.id)
308 selectedDisplay = display; 318 selectedDisplay = display;
309 } 319 }
310 this.displayIds = displayIds; 320 this.displayIds = displayIds;
311 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; 321 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || '';
312 this.selectedDisplay = selectedDisplay || primaryDisplay || 322 this.selectedDisplay = selectedDisplay || primaryDisplay ||
313 (this.displays && this.displays[0]); 323 (this.displays && this.displays[0]);
314 }, 324 },
315 325
326 /**
327 * @param {!Array<!chrome.system.display.DisplayLayout>} layouts
328 * @private
329 */
330 updateDisplayLayout_(layouts) {
331 this.layouts = layouts;
332 },
333
316 /** @private */ 334 /** @private */
317 setPropertiesCallback_: function() { 335 setPropertiesCallback_: function() {
318 if (chrome.runtime.lastError) { 336 if (chrome.runtime.lastError) {
319 console.error( 337 console.error(
320 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); 338 'setDisplayProperties Error: ' + chrome.runtime.lastError.message);
321 } 339 }
322 }, 340 },
323 }); 341 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698