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

Unified Diff: Source/devtools/front_end/emulation/EmulatedDevices.js

Issue 1160323004: [DevTools] Move emulated devices to separate module. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed compile Created 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/emulation/EmulatedDevices.js
diff --git a/Source/devtools/front_end/emulation/EmulatedDevices.js b/Source/devtools/front_end/emulation/EmulatedDevices.js
index d9a992c493e605d8f439b343724887ba8fe21272..87157758240acfe5da1ce49751c63b5624bedc04 100644
--- a/Source/devtools/front_end/emulation/EmulatedDevices.js
+++ b/Source/devtools/front_end/emulation/EmulatedDevices.js
@@ -28,6 +28,9 @@ WebInspector.EmulatedDevice = function()
this._show = WebInspector.EmulatedDevice._Show.Default;
/** @type {boolean} */
this._showByDefault = true;
+
+ /** @type {?Runtime.Extension} */
+ this._extension = null;
}
/** @typedef {!{title: string, orientation: string, pageRect: !WebInspector.Geometry.Rect, images: !WebInspector.EmulatedDevice.Images}} */
@@ -260,6 +263,22 @@ WebInspector.EmulatedDevice.compareByTitle = function(device1, device2)
WebInspector.EmulatedDevice.prototype = {
/**
+ * @return {?Runtime.Extension}
+ */
+ extension: function()
+ {
+ return this._extension;
+ },
+
+ /**
+ * @param {?Runtime.Extension} extension
+ */
+ setExtension: function(extension)
+ {
+ this._extension = extension;
+ },
+
+ /**
* @return {*}
*/
_toJSON: function()
@@ -421,30 +440,11 @@ WebInspector.EmulatedDevicesList = function()
{
WebInspector.Object.call(this);
- /**
- * @param {!Array.<*>} list
- * @param {string} type
- * @return {!Array.<*>}
- */
- function convert(list, type)
- {
- var result = [];
- for (var i = 0; i < list.length; ++i) {
- var device = WebInspector.EmulatedDevice.fromOverridesDevice(/** @type {!WebInspector.OverridesSupport.Device} */ (list[i]), list[i].title, type);
- result.push(device._toJSON());
- }
- return result;
- }
-
- // FIXME: shrink default list once external list is good enough.
- var defaultValue = convert(WebInspector.OverridesUI._phones, "phone")
- .concat(convert(WebInspector.OverridesUI._tablets, "tablet"))
- .concat(convert(WebInspector.OverridesUI._notebooks, "notebook"));
-
/** @type {!WebInspector.Setting} */
- this._standardSetting = WebInspector.settings.createSetting("standardEmulatedDeviceList", defaultValue);
+ this._standardSetting = WebInspector.settings.createSetting("standardEmulatedDeviceList", []);
/** @type {!Array.<!WebInspector.EmulatedDevice>} */
this._standard = this._listFromJSONV1(this._standardSetting.get());
+ this._updateStandardDevices();
/** @type {!WebInspector.Setting} */
this._customSetting = WebInspector.settings.createSetting("customEmulatedDeviceList", []);
@@ -458,6 +458,20 @@ WebInspector.EmulatedDevicesList.Events = {
}
WebInspector.EmulatedDevicesList.prototype = {
+ _updateStandardDevices: function()
+ {
+ var devices = [];
+ var extensions = self.runtime.extensions("emulated-device");
+ for (var i = 0; i < extensions.length; ++i) {
+ var device = WebInspector.EmulatedDevice.fromJSONV1(extensions[i].descriptor()["device"]);
+ device.setExtension(extensions[i]);
+ devices.push(device);
+ }
+ this._copyShowValues(this._standard, devices);
+ this._standard = devices;
+ this.saveStandardDevices();
+ },
+
/**
* @param {!Array.<*>} jsonArray
* @return {!Array.<!WebInspector.EmulatedDevice>}
« no previous file with comments | « Source/devtools/front_end/emulated_devices/module.json ('k') | Source/devtools/front_end/emulation/OverridesUI.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698