Commit 5b05040b authored by Weidong Guo's avatar Weidong Guo Committed by Commit Bot

Use setMirrorMode in display settings

Changes:
Using system display api setDisplayProperties to turn on mirror mode is
deprecated. Replace the usage in display.js with the new api
setMirrorMode.

BUG=807825

Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: I86458ebf7aaa446d6ff23cde05c7eae819d11558
Reviewed-on: https://chromium-review.googlesource.com/896796
Commit-Queue: Weidong Guo <weidongg@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534185}
parent 8829d676
...@@ -3670,7 +3670,7 @@ const FeatureEntry kFeatureEntries[] = { ...@@ -3670,7 +3670,7 @@ const FeatureEntry kFeatureEntries[] = {
SINGLE_VALUE_TYPE(network::switches::kLogNetLog)}, SINGLE_VALUE_TYPE(network::switches::kLogNetLog)},
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
{"enable-multi-mirroring", flag_descriptions::kDisableMultiMirroringName, {"disable-multi-mirroring", flag_descriptions::kDisableMultiMirroringName,
flag_descriptions::kDisableMultiMirroringDescription, kOsCrOS, flag_descriptions::kDisableMultiMirroringDescription, kOsCrOS,
SINGLE_VALUE_TYPE(switches::kDisableMultiMirroring)}, SINGLE_VALUE_TYPE(switches::kDisableMultiMirroring)},
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
......
...@@ -699,25 +699,18 @@ Polymer({ ...@@ -699,25 +699,18 @@ Polymer({
// Blur the control so that when the transition animation completes and the // Blur the control so that when the transition animation completes and the
// UI is focused, the control does not receive focus. crbug.com/785070 // UI is focused, the control does not receive focus. crbug.com/785070
event.target.blur(); event.target.blur();
let id = '';
/** @type {!chrome.system.display.DisplayProperties} */ /** @type {!chrome.system.display.MirrorModeInfo} */
const properties = {}; let mirrorModeInfo = {
if (this.isMirrored_(this.displays)) { mode: this.isMirrored_(this.displays) ?
id = this.primaryDisplayId; chrome.system.display.MirrorMode.OFF :
properties.mirroringSourceId = ''; chrome.system.display.MirrorMode.NORMAL
} else { };
// Set the mirroringSourceId of the secondary (first non-primary) display. settings.display.systemDisplayApi.setMirrorMode(mirrorModeInfo, () => {
for (let i = 0; i < this.displays.length; ++i) { let error = chrome.runtime.lastError;
const display = this.displays[i]; if (error)
if (display.id != this.primaryDisplayId) { console.error('setMirrorMode Error: ' + error.message);
id = display.id; });
break;
}
}
properties.mirroringSourceId = this.primaryDisplayId;
}
settings.display.systemDisplayApi.setDisplayProperties(
id, properties, this.setPropertiesCallback_.bind(this));
}, },
/** @private */ /** @private */
......
...@@ -101,6 +101,23 @@ cr.define('settings', function() { ...@@ -101,6 +101,23 @@ cr.define('settings', function() {
callback(); callback();
}, },
/** @override */
setMirrorMode(info, callback) {
let mirroringSourceId = '';
if (info.mode == chrome.system.display.MirrorMode.NORMAL) {
// Select the primary display as the mirroring source.
for (let d of this.fakeDisplays) {
if (d.isPrimary) {
mirroringSourceId = d.id;
break;
}
}
}
for (let d of this.fakeDisplays)
d.mirroringSourceId = mirroringSourceId;
callback();
},
/** @override */ /** @override */
onDisplayChanged: new FakeChromeEvent(), onDisplayChanged: new FakeChromeEvent(),
......
...@@ -197,7 +197,7 @@ namespace system.display { ...@@ -197,7 +197,7 @@ namespace system.display {
// other properties may not apply. This is has no effect if not provided. // other properties may not apply. This is has no effect if not provided.
boolean? isUnified; boolean? isUnified;
// Depracated. Please use SetMirrorMode() instead. // Deprecated. Please use setMirrorMode() instead.
// Chrome OS only. If set and not empty, enables mirroring for this display. // Chrome OS only. If set and not empty, enables mirroring for this display.
// Otherwise disables mirroring for this display. This value should indicate // Otherwise disables mirroring for this display. This value should indicate
// the id of the source display to mirror, which must not be the same as the // the id of the source display to mirror, which must not be the same as the
......
...@@ -159,6 +159,26 @@ chrome.system.display.DisplayProperties; ...@@ -159,6 +159,26 @@ chrome.system.display.DisplayProperties;
*/ */
chrome.system.display.GetInfoFlags; chrome.system.display.GetInfoFlags;
/**
* @enum {string}
* @see https://developer.chrome.com/extensions/system.display#type-MirrorMode
*/
chrome.system.display.MirrorMode = {
OFF: 'off',
NORMAL: 'normal',
MIXED: 'mixed',
};
/**
* @typedef {{
* mode: !chrome.system.display.MirrorMode,
* mirroringSourceId: (string|undefined),
* mirroringDestinationIds: (!Array<string>|undefined),
* }}
* @see https://developer.chrome.com/extensions/system.display#type-MirrorModeInfo
*/
chrome.system.display.MirrorModeInfo;
/** /**
* Requests the information for all attached display devices. * Requests the information for all attached display devices.
* @param {!chrome.system.display.GetInfoFlags} flags Options affecting how the * @param {!chrome.system.display.GetInfoFlags} flags Options affecting how the
...@@ -301,6 +321,20 @@ chrome.system.display.completeCustomTouchCalibration = function(pairs, bounds) { ...@@ -301,6 +321,20 @@ chrome.system.display.completeCustomTouchCalibration = function(pairs, bounds) {
*/ */
chrome.system.display.clearTouchCalibration = function(id) {}; chrome.system.display.clearTouchCalibration = function(id) {};
/**
* Sets the display mode to the specified mirror mode. Each call resets the
* state from previous calls. Calling setDisplayProperties() will fail for
* the mirroring destination displays.
* NOTE: This is only available to Chrome OS Kiosk apps and Web UI.
* @param {!chrome.system.display.MirrorModeInfo} info The information of the
* mirror mode that should be applied to the display mode.
* @param {function():void=} callback Empty function called when the function
* finishes. To find out whether the function succeeded,
* $(ref:runtime.lastError) should be queried.
* @see https://developer.chrome.com/extensions/system.display#method-setMirrorMode
*/
chrome.system.display.setMirrorMode = function(info, callback) {};
/** /**
* Fired when anything changes to the display configuration. * Fired when anything changes to the display configuration.
* @type {!ChromeEvent} * @type {!ChromeEvent}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment