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

Unified Diff: Source/devtools/front_end/sdk/OverridesSupport.js

Issue 302943002: DevTools: add device selector and touch checkbox into the responsive toolbar. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebaselined Created 6 years, 7 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
« no previous file with comments | « Source/devtools/front_end/responsiveDesignView.css ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sdk/OverridesSupport.js
diff --git a/Source/devtools/front_end/sdk/OverridesSupport.js b/Source/devtools/front_end/sdk/OverridesSupport.js
index 93a44466fe63b257b32fb5e6d1c67875be3a765d..e9217314b2589c1a7f1d2f782ac9823d692c85ee 100644
--- a/Source/devtools/front_end/sdk/OverridesSupport.js
+++ b/Source/devtools/front_end/sdk/OverridesSupport.js
@@ -264,6 +264,138 @@ WebInspector.OverridesSupport.inputValidator = function(value)
return WebInspector.UIString("Value must be non-negative integer");
}
+// Third element lists device metrics separated by 'x':
+// - screen width,
+// - screen height,
+// - device scale factor,
+WebInspector.OverridesSupport._phones = [
+ ["Apple iPhone 3GS",
+ "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
+ "320x480x1"],
+ ["Apple iPhone 4",
+ "Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148 Safari/6533.18.5",
+ "320x480x2"],
+ ["Apple iPhone 5",
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X; en-us) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
+ "320x568x2"],
+ ["BlackBerry Z10",
+ "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+",
+ "384x640x2"],
+ ["BlackBerry Z30",
+ "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.10+ (KHTML, like Gecko) Version/10.0.9.2372 Mobile Safari/537.10+",
+ "360x640x2"],
+ ["Google Nexus 4",
+ "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
+ "384x640x2"],
+ ["Google Nexus 5",
+ "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
+ "360x640x3"],
+ ["Google Nexus S",
+ "Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Nexus S Build/GRJ22) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "320x533x1.5"],
+ ["HTC Evo, Touch HD, Desire HD, Desire",
+ "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Sprint APA9292KT Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "320x533x1.5"],
+ ["HTC One X, EVO LTE",
+ "Mozilla/5.0 (Linux; Android 4.0.3; HTC One X Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19",
+ "360x640x2"],
+ ["HTC Sensation, Evo 3D",
+ "Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "360x640x1.5"],
+ ["LG Optimus 2X, Optimus 3D, Optimus Black",
+ "Mozilla/5.0 (Linux; U; Android 2.2; en-us; LG-P990/V08c Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 MMS/LG-Android-MMS-V1.0/1.2",
+ "320x533x1.5"],
+ ["LG Optimus G",
+ "Mozilla/5.0 (Linux; Android 4.0; LG-E975 Build/IMM76L) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19",
+ "384x640x2"],
+ ["LG Optimus LTE, Optimus 4X HD",
+ "Mozilla/5.0 (Linux; U; Android 2.3; en-us; LG-P930 Build/GRJ90) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "424x753x1.7"],
+ ["LG Optimus One",
+ "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; LG-MS690 Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "213x320x1.5"],
+ ["Motorola Defy, Droid, Droid X, Milestone",
+ "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Milestone Build/ SHOLS_U2_01.03.1) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17",
+ "320x569x1.5"],
+ ["Motorola Droid 3, Droid 4, Droid Razr, Atrix 4G, Atrix 2",
+ "Mozilla/5.0 (Linux; U; Android 2.2; en-us; Droid Build/FRG22D) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "540x960x1"],
+ ["Motorola Droid Razr HD",
+ "Mozilla/5.0 (Linux; U; Android 2.3; en-us; DROID RAZR 4G Build/6.5.1-73_DHD-11_M1-29) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "720x1280x1"],
+ ["Nokia C5, C6, C7, N97, N8, X7",
+ "NokiaN97/21.1.107 (SymbianOS/9.4; Series60/5.0 Mozilla/5.0; Profile/MIDP-2.1 Configuration/CLDC-1.1) AppleWebkit/525 (KHTML, like Gecko) BrowserNG/7.1.4",
+ "360x640x1"],
+ ["Nokia Lumia 7X0, Lumia 8XX, Lumia 900, N800, N810, N900",
+ "Mozilla/5.0 (compatible; MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; Lumia 820)",
+ "320x533x1.5"],
+ ["Samsung Galaxy Note 3",
+ "Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "540x960x2"],
+ ["Samsung Galaxy Note II",
+ "Mozilla/5.0 (Linux; U; Android 4.1; en-us; GT-N7100 Build/JRO03C) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "360x640x2"],
+ ["Samsung Galaxy Note",
+ "Mozilla/5.0 (Linux; U; Android 2.3; en-us; SAMSUNG-SGH-I717 Build/GINGERBREAD) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "400x640x2"],
+ ["Samsung Galaxy S III, Galaxy Nexus",
+ "Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "360x640x2"],
+ ["Samsung Galaxy S, S II, W",
+ "Mozilla/5.0 (Linux; U; Android 2.1; en-us; GT-I9000 Build/ECLAIR) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2",
+ "320x533x1.5"],
+ ["Samsung Galaxy S4",
+ "Mozilla/5.0 (Linux; Android 4.2.2; GT-I9505 Build/JDQ39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36",
+ "360x640x3"],
+ ["Sony Xperia S, Ion",
+ "Mozilla/5.0 (Linux; U; Android 4.0; en-us; LT28at Build/6.1.C.1.111) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "360x640x2"],
+ ["Sony Xperia Sola, U",
+ "Mozilla/5.0 (Linux; U; Android 2.3; en-us; SonyEricssonST25i Build/6.0.B.1.564) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "480x854x1"],
+ ["Sony Xperia Z, Z1",
+ "Mozilla/5.0 (Linux; U; Android 4.2; en-us; SonyC6903 Build/14.1.G.1.518) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
+ "360x640x3"],
+];
+
+WebInspector.OverridesSupport._tablets = [
+ ["Amazon Kindle Fire HDX 7\u2033",
+ "Mozilla/5.0 (Linux; U; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",
+ "1920x1200x2"],
+ ["Amazon Kindle Fire HDX 8.9\u2033",
+ "Mozilla/5.0 (Linux; U; en-us; KFAPWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Gecko) Silk/3.13 Safari/535.19 Silk-Accelerated=true",
+ "2560x1600x2"],
+ ["Amazon Kindle Fire (First Generation)",
+ "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.0.141.16-Gen4_11004310) AppleWebkit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true",
+ "1024x600x1"],
+ ["Apple iPad 1 / 2 / iPad Mini",
+ "Mozilla/5.0 (iPad; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5",
+ "1024x768x1"],
+ ["Apple iPad 3 / 4",
+ "Mozilla/5.0 (iPad; CPU OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53",
+ "1024x768x2"],
+ ["BlackBerry PlayBook",
+ "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML like Gecko) Version/7.2.1.0 Safari/536.2+",
+ "1024x600x1"],
+ ["Google Nexus 10",
+ "Mozilla/5.0 (Linux; Android 4.3; Nexus 10 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36",
+ "1280x800x2"],
+ ["Google Nexus 7 2",
+ "Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36",
+ "960x600x2"],
+ ["Google Nexus 7",
+ "Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.72 Safari/537.36",
+ "966x604x1.325"],
+ ["Motorola Xoom, Xyboard",
+ "Mozilla/5.0 (Linux; U; Android 3.0; en-us; Xoom Build/HRI39) AppleWebKit/525.10 (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2",
+ "1280x800x1"],
+ ["Samsung Galaxy Tab 7.7, 8.9, 10.1",
+ "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "1280x800x1"],
+ ["Samsung Galaxy Tab",
+ "Mozilla/5.0 (Linux; U; Android 2.2; en-us; SCH-I800 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
+ "1024x600x1"],
+];
WebInspector.OverridesSupport.prototype = {
/**
@@ -310,16 +442,13 @@ WebInspector.OverridesSupport.prototype = {
this._userAgentChanged();
},
- reset: function()
+ resetEmulatedDevice: function()
{
this._deviceMetricsChangedListenerMuted = true;
this._userAgentChangedListenerMuted = true;
this.settings.overrideDeviceResolution.set(false);
this.settings.overrideUserAgent.set(false);
this.settings.emulateTouchEvents.set(false);
- this.settings.overrideDeviceOrientation.set(false);
- this.settings.overrideGeolocation.set(false);
- this.settings.overrideCSSMedia.set(false);
this.settings.emulateViewport.set(false);
delete this._deviceMetricsChangedListenerMuted;
delete this._userAgentChangedListenerMuted;
@@ -327,6 +456,14 @@ WebInspector.OverridesSupport.prototype = {
this._userAgentChanged();
},
+ reset: function()
+ {
+ this.settings.overrideDeviceOrientation.set(false);
+ this.settings.overrideGeolocation.set(false);
+ this.settings.overrideCSSMedia.set(false);
+ this.resetEmulatedDevice();
+ },
+
applyInitialOverrides: function()
{
if (!this._target) {
@@ -626,6 +763,7 @@ WebInspector.OverridesSupport.prototype = {
this.settings.deviceOrientationOverride = WebInspector.settings.createSetting("deviceOrientationOverride", "");
this.settings.overrideCSSMedia = WebInspector.settings.createSetting("overrideCSSMedia", false);
this.settings.emulatedCSSMedia = WebInspector.settings.createSetting("emulatedCSSMedia", "print");
+ this.settings.emulatedDevice = WebInspector.settings.createSetting("emulatedDevice", "Google Nexus 5");
this.maybeHasActiveOverridesChanged();
@@ -730,6 +868,56 @@ WebInspector.OverridesSupport.prototype = {
return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
},
+ /**
+ * @param {!Document} document
+ * @return {!Element}
+ */
+ createDeviceSelect: function(document)
+ {
+ var deviceSelectElement = document.createElement("select");
+ deviceSelectElement.disabled = WebInspector.overridesSupport.isInspectingDevice();
+
+ var devices = WebInspector.OverridesSupport._phones.concat(WebInspector.OverridesSupport._tablets);
+ devices.sort();
+ for (var i = 0; i < devices.length; ++i) {
+ var device = devices[i];
+ var option = new Option(device[0], device[0]);
+ option.userAgent = device[1];
+ option.metrics = device[2];
+ deviceSelectElement.add(option);
+ }
+
+ settingChanged();
+ WebInspector.overridesSupport.settings.emulatedDevice.addChangeListener(settingChanged);
+ deviceSelectElement.addEventListener("change", deviceSelected, false);
+
+ function deviceSelected()
+ {
+ var option = deviceSelectElement.options[deviceSelectElement.selectedIndex];
+ WebInspector.overridesSupport.settings.emulatedDevice.removeChangeListener(settingChanged);
+ WebInspector.overridesSupport.settings.emulatedDevice.set(option.value);
+ WebInspector.overridesSupport.settings.emulatedDevice.addChangeListener(settingChanged);
+ }
+
+ function settingChanged()
+ {
+ var selectionRestored = false;
+ for (var i = 0; i < devices.length; ++i) {
+ var device = devices[i];
+ if (WebInspector.overridesSupport.settings.emulatedDevice.get() === device[0]) {
+ deviceSelectElement.selectedIndex = i;
+ selectionRestored = true;
+ break;
+ }
+ }
+
+ if (!selectionRestored)
+ deviceSelectElement.selectedIndex = devices.length - 1;
+ }
+
+ return deviceSelectElement;
+ },
+
__proto__: WebInspector.Object.prototype
}
« no previous file with comments | « Source/devtools/front_end/responsiveDesignView.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698