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

Side by Side Diff: Source/devtools/front_end/emulation/OverridesUI.js

Issue 1186083003: [DevTools] Move network throttling to network panel. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Merged in device mode 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 WebInspector.OverridesUI = {} 5 WebInspector.OverridesUI = {}
6 6
7 /** 7 /**
8 * @return {!Element} 8 * @return {!Element}
9 */ 9 */
10 WebInspector.OverridesUI.createDeviceSelect = function() 10 WebInspector.OverridesUI.createDeviceSelect = function()
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 } 90 }
91 91
92 emulatedSettingChanged(); 92 emulatedSettingChanged();
93 } 93 }
94 94
95 return p; 95 return p;
96 } 96 }
97 97
98 /** 98 /**
99 * @return {!Element}
100 */
101 WebInspector.OverridesUI.createNetworkConditionsSelect = function()
102 {
103 var networkConditionsSetting = WebInspector.overridesSupport.settings.networ kConditions;
104 var conditionsSelectElement = createElement("select");
105 var presets = WebInspector.OverridesUI._networkConditionsPresets;
106 for (var i = 0; i < presets.length; ++i) {
107 var preset = presets[i];
108 var throughput = preset.throughput | 0;
109 var latency = preset.latency | 0;
110 var isThrottling = (throughput > 0) || latency;
111 if (!isThrottling) {
112 conditionsSelectElement.add(new Option(preset.title, preset.id));
113 } else {
114 var throughputText = (throughput < 1024) ? WebInspector.UIString("%d Kbps", throughput) : WebInspector.UIString("%d Mbps", (throughput / 1024) | 0);
115 var title = WebInspector.UIString("%s (%s %dms RTT)", preset.title, throughputText, latency);
116 var option = new Option(title, preset.id);
117 option.title = WebInspector.UIString("Maximum download throughput: % s.\r\nMinimum round-trip time: %dms.", throughputText, latency);
118 conditionsSelectElement.add(option);
119 }
120 }
121
122 settingChanged();
123 networkConditionsSetting.addChangeListener(settingChanged);
124 conditionsSelectElement.addEventListener("change", presetSelected, false);
125
126 function presetSelected()
127 {
128 var selectedOption = conditionsSelectElement.options[conditionsSelectEle ment.selectedIndex];
129 conditionsSelectElement.title = selectedOption.title;
130 var presetId = selectedOption.value;
131 var preset = presets[presets.length - 1];
132 for (var i = 0; i < presets.length; ++i) {
133 if (presets[i].id === presetId) {
134 preset = presets[i];
135 break;
136 }
137 }
138 var kbps = 1024 / 8;
139 networkConditionsSetting.removeChangeListener(settingChanged);
140 networkConditionsSetting.set({throughput: preset.throughput * kbps, late ncy: preset.latency});
141 networkConditionsSetting.addChangeListener(settingChanged);
142 }
143
144 function settingChanged()
145 {
146 var conditions = networkConditionsSetting.get();
147 var presetIndex = presets.length - 1;
148 var kbps = 1024 / 8;
149 for (var i = 0; i < presets.length; ++i) {
150 if (presets[i].throughput === conditions.throughput / kbps && preset s[i].latency === conditions.latency) {
151 presetIndex = i;
152 break;
153 }
154 }
155 conditionsSelectElement.selectedIndex = presetIndex;
156 conditionsSelectElement.title = conditionsSelectElement.options[presetIn dex].title;
157 }
158
159 return conditionsSelectElement;
160 }
161
162 /**
163 * @return {{select: !Element, input: !Element}} 99 * @return {{select: !Element, input: !Element}}
164 */ 100 */
165 WebInspector.OverridesUI.createUserAgentSelectAndInput = function() 101 WebInspector.OverridesUI.createUserAgentSelectAndInput = function()
166 { 102 {
167 var userAgentSetting = WebInspector.overridesSupport.settings.userAgent; 103 var userAgentSetting = WebInspector.overridesSupport.settings.userAgent;
168 const noOverride = {title: WebInspector.UIString("No override"), value: ""}; 104 const noOverride = {title: WebInspector.UIString("No override"), value: ""};
169 const customOverride = {title: WebInspector.UIString("Other"), value: "Other "}; 105 const customOverride = {title: WebInspector.UIString("Other"), value: "Other "};
170 var userAgents = [noOverride].concat(WebInspector.OverridesUI._userAgents).c oncat([customOverride]); 106 var userAgents = [noOverride].concat(WebInspector.OverridesUI._userAgents).c oncat([customOverride]);
171 107
172 var userAgentSelectElement = createElement("select"); 108 var userAgentSelectElement = createElement("select");
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 176
241 function textChanged() 177 function textChanged()
242 { 178 {
243 if (userAgentSetting.get() !== otherUserAgentElement.value) 179 if (userAgentSetting.get() !== otherUserAgentElement.value)
244 userAgentSetting.set(otherUserAgentElement.value); 180 userAgentSetting.set(otherUserAgentElement.value);
245 } 181 }
246 182
247 return { select: userAgentSelectElement, input: otherUserAgentElement }; 183 return { select: userAgentSelectElement, input: otherUserAgentElement };
248 } 184 }
249 185
250 /** @type {!Array.<!WebInspector.OverridesSupport.NetworkConditionsPreset>} */
251 WebInspector.OverridesUI._networkConditionsPresets = [
252 {id: "offline", title: "Offline", throughput: 0, latency: 0},
253 {id: "gprs", title: "GPRS", throughput: 50, latency: 500},
254 {id: "edge", title: "Regular 2G", throughput: 250, latency: 300},
255 {id: "2g+", title: "Good 2G", throughput: 450, latency: 150},
256 {id: "3g", title: "Regular 3G", throughput: 750, latency: 100},
257 {id: "3g+", title: "Good 3G", throughput: 1.5 * 1024, latency: 40},
258 {id: "4g", title: "Regular 4G", throughput: 4 * 1024, latency: 20},
259 {id: "dsl", title: "DSL", throughput: 2 * 1024, latency: 5},
260 {id: "wifi", title: "WiFi", throughput: 30 * 1024, latency: 2},
261 {id: "online", title: "No throttling", throughput: WebInspector.OverridesSup port.NetworkThroughputUnlimitedValue, latency: 0}
262 ];
263
264 /** @type {!Array.<{title: string, value: string}>} */ 186 /** @type {!Array.<{title: string, value: string}>} */
265 WebInspector.OverridesUI._userAgents = [ 187 WebInspector.OverridesUI._userAgents = [
266 {title: "Android 4.0.2 \u2014 Galaxy Nexus", value: "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"}, 188 {title: "Android 4.0.2 \u2014 Galaxy Nexus", value: "Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"},
267 {title: "Android 2.3 \u2014 Nexus S", value: "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Versi on/4.0 Mobile Safari/533.1"}, 189 {title: "Android 2.3 \u2014 Nexus S", value: "Mozilla/5.0 (Linux; U; Android 2.3.6; en-us; Nexus S Build/GRK39F) AppleWebKit/533.1 (KHTML, like Gecko) Versi on/4.0 Mobile Safari/533.1"},
268 {title: "BlackBerry \u2014 BB10", value: "Mozilla/5.0 (BB10; Touch) AppleWeb Kit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"}, 190 {title: "BlackBerry \u2014 BB10", value: "Mozilla/5.0 (BB10; Touch) AppleWeb Kit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+"},
269 {title: "BlackBerry \u2014 PlayBook 2.1", value: "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+"}, 191 {title: "BlackBerry \u2014 PlayBook 2.1", value: "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+"},
270 {title: "BlackBerry \u2014 9900", value: "Mozilla/5.0 (BlackBerry; U; BlackB erry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobi le Safari/534.11+"}, 192 {title: "BlackBerry \u2014 9900", value: "Mozilla/5.0 (BlackBerry; U; BlackB erry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0.187 Mobi le Safari/534.11+"},
271 {title: "Chrome 31 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537 .36"}, 193 {title: "Chrome 31 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537 .36"},
272 {title: "Chrome 31 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) App leWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"}, 194 {title: "Chrome 31 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) App leWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.16 Safari/537.36"},
273 {title: "Chrome \u2014 Android Tablet", value: "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0. 1025.166 Safari/535.19"}, 195 {title: "Chrome \u2014 Android Tablet", value: "Mozilla/5.0 (Linux; Android 4.1.2; Nexus 7 Build/JZ054K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0. 1025.166 Safari/535.19"},
(...skipping 19 matching lines...) Expand all
293 {title: "iPhone \u2014 iOS 7", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_ 0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/1 1A4449d Safari/9537.53"}, 215 {title: "iPhone \u2014 iOS 7", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 7_ 0_2 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/1 1A4449d Safari/9537.53"},
294 {title: "iPhone \u2014 iOS 6", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_ 0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A53 76e Safari/8536.25"}, 216 {title: "iPhone \u2014 iOS 6", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 6_ 0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A53 76e Safari/8536.25"},
295 {title: "MeeGo \u2014 Nokia N9", value: "Mozilla/5.0 (MeeGo; NokiaN9) AppleW ebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"}, 217 {title: "MeeGo \u2014 Nokia N9", value: "Mozilla/5.0 (MeeGo; NokiaN9) AppleW ebKit/534.13 (KHTML, like Gecko) NokiaBrowser/8.5.0 Mobile Safari/534.13"},
296 {title: "Opera 18 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537. 36 OPR/18.0.1284.68"}, 218 {title: "Opera 18 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537. 36 OPR/18.0.1284.68"},
297 {title: "Opera 18 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.12 84.68"}, 219 {title: "Opera 18 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 6.1) Appl eWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 OPR/18.0.12 84.68"},
298 {title: "Opera 12 \u2014 Mac", value: "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16"}, 220 {title: "Opera 12 \u2014 Mac", value: "Opera/9.80 (Macintosh; Intel Mac OS X 10.9.1) Presto/2.12.388 Version/12.16"},
299 {title: "Opera 12 \u2014 Windows", value: "Opera/9.80 (Windows NT 6.1) Prest o/2.12.388 Version/12.16"}, 221 {title: "Opera 12 \u2014 Windows", value: "Opera/9.80 (Windows NT 6.1) Prest o/2.12.388 Version/12.16"},
300 {title: "Silk \u2014 Kindle Fire (Desktop view)", value: "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"}, 222 {title: "Silk \u2014 Kindle Fire (Desktop view)", value: "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"},
301 {title: "Silk \u2014 Kindle Fire (Mobile view)", value: "Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Ge cko) Silk/3.13 Mobile Safari/535.19 Silk-Accelerated=true"} 223 {title: "Silk \u2014 Kindle Fire (Mobile view)", value: "Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; KFTHWI Build/JDQ39) AppleWebKit/535.19 (KHTML, like Ge cko) Silk/3.13 Mobile Safari/535.19 Silk-Accelerated=true"}
302 ]; 224 ];
OLDNEW
« no previous file with comments | « Source/devtools/front_end/emulation/OverridesSupport.js ('k') | Source/devtools/front_end/emulation/OverridesView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698