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

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

Issue 2802603005: MD Settings: Display: Add unified desktop control and modify api (Closed)
Patch Set: Created 3 years, 8 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 */ 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
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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
244 this.isMirrored_(displays) ? 'displayMirrorOn' : 'displayMirrorOff'); 258 this.isMirrored_(displays) ? 'displayMirrorOn' : 'displayMirrorOff');
245 }, 259 },
246 260
247 /** 261 /**
262 * @param {boolean} unifiedDesktopAvailable
263 * @param {boolean} unifiedDesktopMode
248 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays 264 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays
249 * @return {boolean} 265 * @return {boolean}
250 * @private 266 * @private
251 */ 267 */
252 showMirror_: function(displays) { 268 showUnifiedDesktop_: function(
269 unifiedDesktopAvailable, unifiedDesktopMode, displays) {
270 return unifiedDesktopMode ||
271 (unifiedDesktopAvailable && displays.length > 1 &&
272 !this.isMirrored_(displays));
273 },
274
275 /**
276 * @param {boolean} unifiedDesktopMode
277 * @return {string}
278 * @private
279 */
280 getUnifiedDesktopText_: function(unifiedDesktopMode) {
281 return this.i18n(
282 unifiedDesktopMode ? 'displayMirrorOn' : 'displayMirrorOff');
malaykeshav 2017/04/05 23:02:57 Shouldn't they have a string of their own? i18n pr
stevenjb 2017/04/06 01:56:08 Actually, we should use the more generic phase tha
283 },
284
285 /**
286 * @param {boolean} unifiedDesktopMode
287 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays
288 * @return {boolean}
289 * @private
290 */
291 showMirror_: function(unifiedDesktopMode, displays) {
malaykeshav 2017/04/05 23:02:57 'unifiedDesktopMode' unused?
stevenjb 2017/04/06 01:56:08 Oops, it should be, thanks for catching. Done.
253 return this.isMirrored_(displays) || displays.length == 2; 292 return this.isMirrored_(displays) || displays.length == 2;
254 }, 293 },
255 294
256 /** 295 /**
257 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays 296 * @param {!Array<!chrome.system.display.DisplayUnitInfo>} displays
258 * @return {boolean} 297 * @return {boolean}
259 * @private 298 * @private
260 */ 299 */
261 isMirrored_: function(displays) { 300 isMirrored_: function(displays) {
262 return displays.length > 0 && !!displays[0].mirroringSourceId; 301 return displays.length > 0 && !!displays[0].mirroringSourceId;
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 id = display.id; 455 id = display.id;
417 break; 456 break;
418 } 457 }
419 } 458 }
420 properties.mirroringSourceId = this.primaryDisplayId; 459 properties.mirroringSourceId = this.primaryDisplayId;
421 } 460 }
422 settings.display.systemDisplayApi.setDisplayProperties( 461 settings.display.systemDisplayApi.setDisplayProperties(
423 id, properties, this.setPropertiesCallback_.bind(this)); 462 id, properties, this.setPropertiesCallback_.bind(this));
424 }, 463 },
425 464
465 /** @private */
466 onUnifiedDesktopTap_: function() {
467 settings.display.systemDisplayApi.enableUnifiedDesktop(
468 !this.unifiedDesktopMode_);
469 },
470
426 /** 471 /**
427 * @param {!Event} e 472 * @param {!Event} e
428 * @private 473 * @private
429 */ 474 */
430 onOverscanTap_: function(e) { 475 onOverscanTap_: function(e) {
431 e.preventDefault(); 476 e.preventDefault();
432 this.overscanDisplayId = this.selectedDisplay.id; 477 this.overscanDisplayId = this.selectedDisplay.id;
433 this.showOverscanDialog_(true); 478 this.showOverscanDialog_(true);
434 }, 479 },
435 480
(...skipping 11 matching lines...) Expand all
447 primaryDisplay = display; 492 primaryDisplay = display;
448 if (this.selectedDisplay && display.id == this.selectedDisplay.id) 493 if (this.selectedDisplay && display.id == this.selectedDisplay.id)
449 selectedDisplay = display; 494 selectedDisplay = display;
450 } 495 }
451 this.displayIds = displayIds; 496 this.displayIds = displayIds;
452 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || ''; 497 this.primaryDisplayId = (primaryDisplay && primaryDisplay.id) || '';
453 selectedDisplay = selectedDisplay || primaryDisplay || 498 selectedDisplay = selectedDisplay || primaryDisplay ||
454 (this.displays && this.displays[0]); 499 (this.displays && this.displays[0]);
455 this.setSelectedDisplay_(selectedDisplay); 500 this.setSelectedDisplay_(selectedDisplay);
456 501
502 this.unifiedDesktopMode_ = primaryDisplay && primaryDisplay.isUnified;
503
457 this.$.displayLayout.updateDisplays(this.displays, this.layouts); 504 this.$.displayLayout.updateDisplays(this.displays, this.layouts);
458 }, 505 },
459 506
460 /** @private */ 507 /** @private */
461 setPropertiesCallback_: function() { 508 setPropertiesCallback_: function() {
462 if (chrome.runtime.lastError) { 509 if (chrome.runtime.lastError) {
463 console.error( 510 console.error(
464 'setDisplayProperties Error: ' + chrome.runtime.lastError.message); 511 'setDisplayProperties Error: ' + chrome.runtime.lastError.message);
465 } 512 }
466 }, 513 },
467 }); 514 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698