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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/NetworkConfigView.js

Issue 2300403003: DevTools: patch browser's Chrome version into Chrome user agents for emulation (Closed)
Patch Set: Removed old stuff Created 4 years, 3 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 (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 * @constructor 6 * @constructor
7 * @extends {WebInspector.VBox} 7 * @extends {WebInspector.VBox}
8 */ 8 */
9 WebInspector.NetworkConfigView = function() 9 WebInspector.NetworkConfigView = function()
10 { 10 {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 * @return {{select: !Element, input: !Element}} 90 * @return {{select: !Element, input: !Element}}
91 */ 91 */
92 WebInspector.NetworkConfigView.createUserAgentSelectAndInput = function() 92 WebInspector.NetworkConfigView.createUserAgentSelectAndInput = function()
93 { 93 {
94 var userAgentSetting = WebInspector.settings.createSetting("customUserAgent" , ""); 94 var userAgentSetting = WebInspector.settings.createSetting("customUserAgent" , "");
95 var userAgentSelectElement = createElement("select"); 95 var userAgentSelectElement = createElement("select");
96 96
97 const customOverride = {title: WebInspector.UIString("Custom..."), value: "c ustom"}; 97 const customOverride = {title: WebInspector.UIString("Custom..."), value: "c ustom"};
98 userAgentSelectElement.appendChild(new Option(customOverride.title, customOv erride.value)); 98 userAgentSelectElement.appendChild(new Option(customOverride.title, customOv erride.value));
99 99
100 var groups = WebInspector.NetworkConfigView._userAgentGroups; 100 var groups = WebInspector.NetworkConfigView.UserAgentGroups();
101 for (var userAgentDescriptor of WebInspector.NetworkConfigView._userAgentGro ups) { 101 for (var userAgentDescriptor of groups) {
102 var groupElement = userAgentSelectElement.createChild("optgroup"); 102 var groupElement = userAgentSelectElement.createChild("optgroup");
103 groupElement.label = userAgentDescriptor.title; 103 groupElement.label = userAgentDescriptor.title;
104 for (var userAgentVersion of userAgentDescriptor.values) 104 for (var userAgentVersion of userAgentDescriptor.values)
105 groupElement.appendChild(new Option(userAgentVersion.title, userAgen tVersion.value)); 105 groupElement.appendChild(new Option(userAgentVersion.title, userAgen tVersion.value));
dgozman 2016/09/07 22:06:28 Why not patch right here with a single call?
luoe 2016/09/07 22:46:32 I think it makes a readable, self-contained unit t
106 } 106 }
107 107
108 userAgentSelectElement.selectedIndex = 0; 108 userAgentSelectElement.selectedIndex = 0;
109 109
110 var otherUserAgentElement = createElement("input"); 110 var otherUserAgentElement = createElement("input");
111 otherUserAgentElement.type = "text"; 111 otherUserAgentElement.type = "text";
112 otherUserAgentElement.value = userAgentSetting.get(); 112 otherUserAgentElement.value = userAgentSetting.get();
113 otherUserAgentElement.title = userAgentSetting.get(); 113 otherUserAgentElement.title = userAgentSetting.get();
114 otherUserAgentElement.placeholder = WebInspector.UIString("Enter a custom us er agent"); 114 otherUserAgentElement.placeholder = WebInspector.UIString("Enter a custom us er agent");
115 otherUserAgentElement.required = true; 115 otherUserAgentElement.required = true;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 if (userAgentSetting.get() !== otherUserAgentElement.value) { 152 if (userAgentSetting.get() !== otherUserAgentElement.value) {
153 userAgentSetting.set(otherUserAgentElement.value); 153 userAgentSetting.set(otherUserAgentElement.value);
154 otherUserAgentElement.title = otherUserAgentElement.value; 154 otherUserAgentElement.title = otherUserAgentElement.value;
155 settingChanged(); 155 settingChanged();
156 } 156 }
157 } 157 }
158 158
159 return { select: userAgentSelectElement, input: otherUserAgentElement }; 159 return { select: userAgentSelectElement, input: otherUserAgentElement };
160 } 160 }
161 161
162 /**
163 * @return {!Array.<{title: string, values: !Array.<{title: string, value: strin g}>}>}
164 */
165 WebInspector.NetworkConfigView.UserAgentGroups = function()
166 {
167 return WebInspector.NetworkConfigView._userAgentGroups.map(patchGroups);
168
169 /**
170 * @param {!Object.<string, !Array.<{title: string, value: string}>>} group
171 * @return {!Object.<string, !Array.<{title: string, value: string}>>}
172 */
173 function patchGroups(group)
174 {
175 if (group.title !== "Chrome")
176 return group;
177
178 for (var i = 0; i < group.values.length; i++)
179 group.values[i].value = WebInspector.BrowserVersionInfo.patchUserAge ntWithCurrentVersion(group.values[i].value);
180 return group;
181 }
182 }
162 183
163 /** @type {!Array.<{title: string, values: !Array.<{title: string, value: string }>}>} */ 184 /** @type {!Array.<{title: string, values: !Array.<{title: string, value: string }>}>} */
164 WebInspector.NetworkConfigView._userAgentGroups = [ 185 WebInspector.NetworkConfigView._userAgentGroups = [
165 { 186 {
166 title: "Android", 187 title: "Android",
167 values: [ 188 values: [
168 {title: "Android (4.0.2) Browser \u2014 Galaxy Nexus", value: "Mozil la/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/5 34.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"}, 189 {title: "Android (4.0.2) Browser \u2014 Galaxy Nexus", value: "Mozil la/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL53F) AppleWebKit/5 34.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"},
169 {title: "Android (2.3) Browser \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) Version/4.0 Mobile Safari/533.1"} 190 {title: "Android (2.3) Browser \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) Version/4.0 Mobile Safari/533.1"}
170 ] 191 ]
171 }, 192 },
172 { 193 {
173 title: "BlackBerry", 194 title: "BlackBerry",
174 values: [ 195 values: [
175 {title: "BlackBerry \u2014 BB10", value: "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+" }, 196 {title: "BlackBerry \u2014 BB10", value: "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+" },
176 {title: "BlackBerry \u2014 PlayBook 2.1", value: "Mozilla/5.0 (PlayB ook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Versi on/7.2.1.0 Safari/536.2+"}, 197 {title: "BlackBerry \u2014 PlayBook 2.1", value: "Mozilla/5.0 (PlayB ook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Versi on/7.2.1.0 Safari/536.2+"},
177 {title: "BlackBerry \u2014 9900", value: "Mozilla/5.0 (BlackBerry; U ; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0. 187 Mobile Safari/534.11+"} 198 {title: "BlackBerry \u2014 9900", value: "Mozilla/5.0 (BlackBerry; U ; BlackBerry 9900; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/7.0.0. 187 Mobile Safari/534.11+"}
178 ] 199 ]
179 }, 200 },
180 { 201 {
181 title: "Chrome", 202 title: "Chrome",
182 values: [ 203 values: [
183 {title: "Chrome 52 \u2014 Android Mobile", value: "Mozilla/5.0 (Linu x; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chr ome/52.0.2725.0 Mobile Safari/537.36"}, 204 {title: "Chrome \u2014 Android Mobile", value: "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome /%s Mobile Safari/537.36"},
184 {title: "Chrome 52 \u2014 Android Tablet", value: "Mozilla/5.0 (Linu x; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chr ome/52.0.2725.0 Safari/537.36"}, 205 {title: "Chrome \u2014 Android Tablet", value: "Mozilla/5.0 (Linux; Android 4.3; Nexus 7 Build/JSS15Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome /%s Safari/537.36"},
185 {title: "Chrome 52 \u2014 iPhone", value: "Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/52.0.27 25.0 Mobile/13B143 Safari/601.1.46"}, 206 {title: "Chrome \u2014 iPhone", value: "Mozilla/5.0 (iPhone; CPU iPh one OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/%s Mobile/ 13B143 Safari/601.1.46"},
186 {title: "Chrome 52 \u2014 iPad", value: "Mozilla/5.0 (iPad; CPU OS 9 _1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/52.0.2725.0 Mobile /13B143 Safari/601.1.46"}, 207 {title: "Chrome \u2014 iPad", value: "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1 (KHTML, like Gecko) CriOS/%s Mobile/13B143 Safa ri/601.1.46"},
187 {title: "Chrome 52 \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Inte l Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2725.0 Sa fari/537.36"}, 208 {title: "Chrome \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel M ac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36" },
188 {title: "Chrome 52 \u2014 Windows", value: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2725.0 Safari/53 7.36"} 209 {title: "Chrome \u2014 Windows", value: "Mozilla/5.0 (Windows NT 10. 0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/%s Safari/537.36"}
189 ] 210 ]
190 }, 211 },
191 { 212 {
192 title: "Edge", 213 title: "Edge",
193 values: [ 214 values: [
194 {title: "Edge \u2014 Windows", value: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/ 537.36 Edge/12.10240"}, 215 {title: "Edge \u2014 Windows", value: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/ 537.36 Edge/12.10240"},
195 {title: "Edge \u2014 Mobile", value: "Mozilla/5.0 (Windows Phone 10. 0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like G ecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166"}, 216 {title: "Edge \u2014 Mobile", value: "Mozilla/5.0 (Windows Phone 10. 0; Android 4.2.1; Microsoft; Lumia 640 XL LTE) AppleWebKit/537.36 (KHTML, like G ecko) Chrome/42.0.2311.135 Mobile Safari/537.36 Edge/12.10166"},
196 {title: "Edge \u2014 XBox", value: "Mozilla/5.0 (Windows NT 10.0; Wi n64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.231 1.135 Safari/537.36 Edge/13.10586"} 217 {title: "Edge \u2014 XBox", value: "Mozilla/5.0 (Windows NT 10.0; Wi n64; x64; Xbox; Xbox One) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.231 1.135 Safari/537.36 Edge/13.10586"}
197 ] 218 ]
198 }, 219 },
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 }, 258 },
238 { 259 {
239 title: "Safari", 260 title: "Safari",
240 values: [ 261 values: [
241 {title: "Safari \u2014 iPad iOS 9", value: "Mozilla/5.0 (iPad; CPU O S 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile /13B137 Safari/601.1"}, 262 {title: "Safari \u2014 iPad iOS 9", value: "Mozilla/5.0 (iPad; CPU O S 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile /13B137 Safari/601.1"},
242 {title: "Safari \u2014 iPhone iOS 9", value: "Mozilla/5.0 (iPhone; C PU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version /9.0 Mobile/13B137 Safari/601.1"}, 263 {title: "Safari \u2014 iPhone iOS 9", value: "Mozilla/5.0 (iPhone; C PU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version /9.0 Mobile/13B137 Safari/601.1"},
243 {title: "Safari \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel M ac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7 046A194A"} 264 {title: "Safari \u2014 Mac", value: "Mozilla/5.0 (Macintosh; Intel M ac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7 046A194A"}
244 ] 265 ]
245 } 266 }
246 ] 267 ]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698