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

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

Issue 2493373002: DevTools: rename WebInspector into modules. (Closed)
Patch Set: for bots Created 4 years, 1 month 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 WebInspector.NetworkConfigView = class extends WebInspector.VBox { 7 Network.NetworkConfigView = class extends UI.VBox {
8 constructor() { 8 constructor() {
9 super(true); 9 super(true);
10 this.registerRequiredCSS('network/networkConfigView.css'); 10 this.registerRequiredCSS('network/networkConfigView.css');
11 this.contentElement.classList.add('network-config'); 11 this.contentElement.classList.add('network-config');
12 12
13 this._createCacheSection(); 13 this._createCacheSection();
14 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 14 this.contentElement.createChild('div').classList.add('panel-section-separato r');
15 this._createNetworkThrottlingSection(); 15 this._createNetworkThrottlingSection();
16 this.contentElement.createChild('div').classList.add('panel-section-separato r'); 16 this.contentElement.createChild('div').classList.add('panel-section-separato r');
17 this._createUserAgentSection(); 17 this._createUserAgentSection();
18 } 18 }
19 19
20 /** 20 /**
21 * @return {{select: !Element, input: !Element}} 21 * @return {{select: !Element, input: !Element}}
22 */ 22 */
23 static createUserAgentSelectAndInput() { 23 static createUserAgentSelectAndInput() {
24 var userAgentSetting = WebInspector.settings.createSetting('customUserAgent' , ''); 24 var userAgentSetting = Common.settings.createSetting('customUserAgent', '');
25 var userAgentSelectElement = createElement('select'); 25 var userAgentSelectElement = createElement('select');
26 26
27 const customOverride = {title: WebInspector.UIString('Custom...'), value: 'c ustom'}; 27 const customOverride = {title: Common.UIString('Custom...'), value: 'custom' };
28 userAgentSelectElement.appendChild(new Option(customOverride.title, customOv erride.value)); 28 userAgentSelectElement.appendChild(new Option(customOverride.title, customOv erride.value));
29 29
30 var groups = WebInspector.NetworkConfigView._userAgentGroups; 30 var groups = Network.NetworkConfigView._userAgentGroups;
31 for (var userAgentDescriptor of groups) { 31 for (var userAgentDescriptor of groups) {
32 var groupElement = userAgentSelectElement.createChild('optgroup'); 32 var groupElement = userAgentSelectElement.createChild('optgroup');
33 groupElement.label = userAgentDescriptor.title; 33 groupElement.label = userAgentDescriptor.title;
34 for (var userAgentVersion of userAgentDescriptor.values) { 34 for (var userAgentVersion of userAgentDescriptor.values) {
35 var userAgentValue = 35 var userAgentValue =
36 WebInspector.MultitargetNetworkManager.patchUserAgentWithChromeVersi on(userAgentVersion.value); 36 SDK.MultitargetNetworkManager.patchUserAgentWithChromeVersion(userAg entVersion.value);
37 groupElement.appendChild(new Option(userAgentVersion.title, userAgentVal ue)); 37 groupElement.appendChild(new Option(userAgentVersion.title, userAgentVal ue));
38 } 38 }
39 } 39 }
40 40
41 userAgentSelectElement.selectedIndex = 0; 41 userAgentSelectElement.selectedIndex = 0;
42 42
43 var otherUserAgentElement = createElement('input'); 43 var otherUserAgentElement = createElement('input');
44 otherUserAgentElement.type = 'text'; 44 otherUserAgentElement.type = 'text';
45 otherUserAgentElement.value = userAgentSetting.get(); 45 otherUserAgentElement.value = userAgentSetting.get();
46 otherUserAgentElement.title = userAgentSetting.get(); 46 otherUserAgentElement.title = userAgentSetting.get();
47 otherUserAgentElement.placeholder = WebInspector.UIString('Enter a custom us er agent'); 47 otherUserAgentElement.placeholder = Common.UIString('Enter a custom user age nt');
48 otherUserAgentElement.required = true; 48 otherUserAgentElement.required = true;
49 49
50 settingChanged(); 50 settingChanged();
51 userAgentSelectElement.addEventListener('change', userAgentSelected, false); 51 userAgentSelectElement.addEventListener('change', userAgentSelected, false);
52 otherUserAgentElement.addEventListener('input', applyOtherUserAgent, false); 52 otherUserAgentElement.addEventListener('input', applyOtherUserAgent, false);
53 53
54 function userAgentSelected() { 54 function userAgentSelected() {
55 var value = userAgentSelectElement.options[userAgentSelectElement.selected Index].value; 55 var value = userAgentSelectElement.options[userAgentSelectElement.selected Index].value;
56 if (value !== customOverride.value) { 56 if (value !== customOverride.value) {
57 userAgentSetting.set(value); 57 userAgentSetting.set(value);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 */ 96 */
97 _createSection(title, className) { 97 _createSection(title, className) {
98 var section = this.contentElement.createChild('section', 'network-config-gro up'); 98 var section = this.contentElement.createChild('section', 'network-config-gro up');
99 if (className) 99 if (className)
100 section.classList.add(className); 100 section.classList.add(className);
101 section.createChild('div', 'network-config-title').textContent = title; 101 section.createChild('div', 'network-config-title').textContent = title;
102 return section.createChild('div', 'network-config-fields'); 102 return section.createChild('div', 'network-config-fields');
103 } 103 }
104 104
105 _createCacheSection() { 105 _createCacheSection() {
106 var section = this._createSection(WebInspector.UIString('Caching'), 'network -config-disable-cache'); 106 var section = this._createSection(Common.UIString('Caching'), 'network-confi g-disable-cache');
107 section.appendChild(WebInspector.SettingsUI.createSettingCheckbox( 107 section.appendChild(UI.SettingsUI.createSettingCheckbox(
108 WebInspector.UIString('Disable cache'), WebInspector.moduleSetting('cach eDisabled'), true)); 108 Common.UIString('Disable cache'), Common.moduleSetting('cacheDisabled'), true));
109 } 109 }
110 110
111 _createNetworkThrottlingSection() { 111 _createNetworkThrottlingSection() {
112 var section = this._createSection(WebInspector.UIString('Network throttling' ), 'network-config-throttling'); 112 var section = this._createSection(Common.UIString('Network throttling'), 'ne twork-config-throttling');
113 WebInspector.NetworkConditionsSelector.decorateSelect( 113 Components.NetworkConditionsSelector.decorateSelect(
114 /** @type {!HTMLSelectElement} */ (section.createChild('select', 'chrome -select'))); 114 /** @type {!HTMLSelectElement} */ (section.createChild('select', 'chrome -select')));
115 } 115 }
116 116
117 _createUserAgentSection() { 117 _createUserAgentSection() {
118 var section = this._createSection(WebInspector.UIString('User agent'), 'netw ork-config-ua'); 118 var section = this._createSection(Common.UIString('User agent'), 'network-co nfig-ua');
119 var checkboxLabel = createCheckboxLabel(WebInspector.UIString('Select automa tically'), true); 119 var checkboxLabel = createCheckboxLabel(Common.UIString('Select automaticall y'), true);
120 section.appendChild(checkboxLabel); 120 section.appendChild(checkboxLabel);
121 this._autoCheckbox = checkboxLabel.checkboxElement; 121 this._autoCheckbox = checkboxLabel.checkboxElement;
122 this._autoCheckbox.addEventListener('change', this._userAgentTypeChanged.bin d(this)); 122 this._autoCheckbox.addEventListener('change', this._userAgentTypeChanged.bin d(this));
123 123
124 this._customUserAgentSetting = WebInspector.settings.createSetting('customUs erAgent', ''); 124 this._customUserAgentSetting = Common.settings.createSetting('customUserAgen t', '');
125 this._customUserAgentSetting.addChangeListener(this._customUserAgentChanged, this); 125 this._customUserAgentSetting.addChangeListener(this._customUserAgentChanged, this);
126 126
127 this._customUserAgent = section.createChild('div', 'network-config-ua-custom '); 127 this._customUserAgent = section.createChild('div', 'network-config-ua-custom ');
128 this._customSelectAndInput = WebInspector.NetworkConfigView.createUserAgentS electAndInput(); 128 this._customSelectAndInput = Network.NetworkConfigView.createUserAgentSelect AndInput();
129 this._customSelectAndInput.select.classList.add('chrome-select'); 129 this._customSelectAndInput.select.classList.add('chrome-select');
130 this._customUserAgent.appendChild(this._customSelectAndInput.select); 130 this._customUserAgent.appendChild(this._customSelectAndInput.select);
131 this._customUserAgent.appendChild(this._customSelectAndInput.input); 131 this._customUserAgent.appendChild(this._customSelectAndInput.input);
132 this._userAgentTypeChanged(); 132 this._userAgentTypeChanged();
133 } 133 }
134 134
135 _customUserAgentChanged() { 135 _customUserAgentChanged() {
136 if (this._autoCheckbox.checked) 136 if (this._autoCheckbox.checked)
137 return; 137 return;
138 WebInspector.multitargetNetworkManager.setCustomUserAgentOverride(this._cust omUserAgentSetting.get()); 138 SDK.multitargetNetworkManager.setCustomUserAgentOverride(this._customUserAge ntSetting.get());
139 } 139 }
140 140
141 _userAgentTypeChanged() { 141 _userAgentTypeChanged() {
142 var useCustomUA = !this._autoCheckbox.checked; 142 var useCustomUA = !this._autoCheckbox.checked;
143 this._customUserAgent.classList.toggle('checked', useCustomUA); 143 this._customUserAgent.classList.toggle('checked', useCustomUA);
144 this._customSelectAndInput.select.disabled = !useCustomUA; 144 this._customSelectAndInput.select.disabled = !useCustomUA;
145 this._customSelectAndInput.input.disabled = !useCustomUA; 145 this._customSelectAndInput.input.disabled = !useCustomUA;
146 var customUA = useCustomUA ? this._customUserAgentSetting.get() : ''; 146 var customUA = useCustomUA ? this._customUserAgentSetting.get() : '';
147 WebInspector.multitargetNetworkManager.setCustomUserAgentOverride(customUA); 147 SDK.multitargetNetworkManager.setCustomUserAgentOverride(customUA);
148 } 148 }
149 }; 149 };
150 150
151 151
152 /** @type {!Array.<{title: string, values: !Array.<{title: string, value: string }>}>} */ 152 /** @type {!Array.<{title: string, values: !Array.<{title: string, value: string }>}>} */
153 WebInspector.NetworkConfigView._userAgentGroups = [ 153 Network.NetworkConfigView._userAgentGroups = [
154 { 154 {
155 title: 'Android', 155 title: 'Android',
156 values: [ 156 values: [
157 { 157 {
158 title: 'Android (4.0.2) Browser \u2014 Galaxy Nexus', 158 title: 'Android (4.0.2) Browser \u2014 Galaxy Nexus',
159 value: 159 value:
160 'Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL 53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30' 160 'Mozilla/5.0 (Linux; U; Android 4.0.2; en-us; Galaxy Nexus Build/ICL 53F) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30'
161 }, 161 },
162 { 162 {
163 title: 'Android (2.3) Browser \u2014 Nexus S', 163 title: 'Android (2.3) Browser \u2014 Nexus S',
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 value: 'UCWEB/2.0 (iPad; U; CPU OS 7_1 like Mac OS X; en; iPad3,6) U2/1. 0.0 UCBrowser/9.3.1.344' 351 value: 'UCWEB/2.0 (iPad; U; CPU OS 7_1 like Mac OS X; en; iPad3,6) U2/1. 0.0 UCBrowser/9.3.1.344'
352 }, 352 },
353 { 353 {
354 title: 'UC Browser \u2014 Windows Phone', 354 title: 'UC Browser \u2014 Windows Phone',
355 value: 355 value:
356 'NokiaX2-02/2.0 (11.79) Profile/MIDP-2.1 Configuration/CLDC-1.1 Mozi lla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;.NET CLR 2.0.5 0727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2) U CBrowser8.4.0.159/70/352' 356 'NokiaX2-02/2.0 (11.79) Profile/MIDP-2.1 Configuration/CLDC-1.1 Mozi lla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;.NET CLR 2.0.5 0727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2) U CBrowser8.4.0.159/70/352'
357 } 357 }
358 ] 358 ]
359 } 359 }
360 ]; 360 ];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698