OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 * @implements {UI.ListWidget.Delegate} | 6 * @implements {UI.ListWidget.Delegate} |
7 * @unrestricted | 7 * @unrestricted |
8 */ | 8 */ |
9 NetworkConditions.NetworkConditionsSettingsTab = class extends UI.VBox { | 9 MobileThrottling.NetworkConditionsSettingsTab = class extends UI.VBox { |
10 constructor() { | 10 constructor() { |
11 super(true); | 11 super(true); |
12 this.registerRequiredCSS('network_conditions/networkConditionsSettingsTab.cs
s'); | 12 this.registerRequiredCSS('mobile_throttling/networkConditionsSettingsTab.css
'); |
13 | 13 |
14 this.contentElement.createChild('div', 'header').textContent = Common.UIStri
ng('Network Throttling Profiles'); | 14 this.contentElement.createChild('div', 'header').textContent = Common.UIStri
ng('Network Throttling Profiles'); |
15 | 15 |
16 var addButton = UI.createTextButton( | 16 var addButton = UI.createTextButton( |
17 Common.UIString('Add custom profile...'), this._addButtonClicked.bind(th
is), 'add-conditions-button'); | 17 Common.UIString('Add custom profile...'), this._addButtonClicked.bind(th
is), 'add-conditions-button'); |
18 this.contentElement.appendChild(addButton); | 18 this.contentElement.appendChild(addButton); |
19 | 19 |
20 this._list = new UI.ListWidget(this); | 20 this._list = new UI.ListWidget(this); |
21 this._list.element.classList.add('conditions-list'); | 21 this._list.element.classList.add('conditions-list'); |
22 this._list.registerRequiredCSS('network_conditions/networkConditionsSettings
Tab.css'); | 22 this._list.registerRequiredCSS('mobile_throttling/networkConditionsSettingsT
ab.css'); |
23 this._list.show(this.contentElement); | 23 this._list.show(this.contentElement); |
24 | 24 |
25 this._customSetting = Common.moduleSetting('customNetworkConditions'); | 25 this._customSetting = Common.moduleSetting('customNetworkConditions'); |
26 this._customSetting.addChangeListener(this._conditionsUpdated, this); | 26 this._customSetting.addChangeListener(this._conditionsUpdated, this); |
27 | 27 |
28 this.setDefaultFocusedElement(addButton); | 28 this.setDefaultFocusedElement(addButton); |
29 this.contentElement.tabIndex = 0; | 29 this.contentElement.tabIndex = 0; |
30 } | 30 } |
31 | 31 |
32 /** | 32 /** |
(...skipping 26 matching lines...) Expand all Loading... |
59 */ | 59 */ |
60 renderItem(item, editable) { | 60 renderItem(item, editable) { |
61 var conditions = /** @type {!SDK.NetworkManager.Conditions} */ (item); | 61 var conditions = /** @type {!SDK.NetworkManager.Conditions} */ (item); |
62 var element = createElementWithClass('div', 'conditions-list-item'); | 62 var element = createElementWithClass('div', 'conditions-list-item'); |
63 var title = element.createChild('div', 'conditions-list-text conditions-list
-title'); | 63 var title = element.createChild('div', 'conditions-list-text conditions-list
-title'); |
64 var titleText = title.createChild('div', 'conditions-list-title-text'); | 64 var titleText = title.createChild('div', 'conditions-list-title-text'); |
65 titleText.textContent = conditions.title; | 65 titleText.textContent = conditions.title; |
66 titleText.title = conditions.title; | 66 titleText.title = conditions.title; |
67 element.createChild('div', 'conditions-list-separator'); | 67 element.createChild('div', 'conditions-list-separator'); |
68 element.createChild('div', 'conditions-list-text').textContent = | 68 element.createChild('div', 'conditions-list-text').textContent = |
69 NetworkConditions.NetworkConditionsSelector.throughputText(conditions.do
wnload); | 69 MobileThrottling.NetworkConditionsSelector.throughputText(conditions.dow
nload); |
70 element.createChild('div', 'conditions-list-separator'); | 70 element.createChild('div', 'conditions-list-separator'); |
71 element.createChild('div', 'conditions-list-text').textContent = | 71 element.createChild('div', 'conditions-list-text').textContent = |
72 NetworkConditions.NetworkConditionsSelector.throughputText(conditions.up
load); | 72 MobileThrottling.NetworkConditionsSelector.throughputText(conditions.upl
oad); |
73 element.createChild('div', 'conditions-list-separator'); | 73 element.createChild('div', 'conditions-list-separator'); |
74 element.createChild('div', 'conditions-list-text').textContent = Common.UISt
ring('%dms', conditions.latency); | 74 element.createChild('div', 'conditions-list-text').textContent = Common.UISt
ring('%dms', conditions.latency); |
75 return element; | 75 return element; |
76 } | 76 } |
77 | 77 |
78 /** | 78 /** |
79 * @override | 79 * @override |
80 * @param {*} item | 80 * @param {*} item |
81 * @param {number} index | 81 * @param {number} index |
82 */ | 82 */ |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 * @param {number} index | 192 * @param {number} index |
193 * @param {!HTMLInputElement|!HTMLSelectElement} input | 193 * @param {!HTMLInputElement|!HTMLSelectElement} input |
194 * @return {boolean} | 194 * @return {boolean} |
195 */ | 195 */ |
196 function latencyValidator(item, index, input) { | 196 function latencyValidator(item, index, input) { |
197 var value = input.value.trim(); | 197 var value = input.value.trim(); |
198 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000)
; | 198 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000)
; |
199 } | 199 } |
200 } | 200 } |
201 }; | 201 }; |
OLD | NEW |