| 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 NetworkConditions.NetworkConditionsSettingsTab = class extends UI.VBox { |
| 10 constructor() { | 10 constructor() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 } | 38 } |
| 39 | 39 |
| 40 _conditionsUpdated() { | 40 _conditionsUpdated() { |
| 41 this._list.clear(); | 41 this._list.clear(); |
| 42 | 42 |
| 43 var conditions = this._customSetting.get(); | 43 var conditions = this._customSetting.get(); |
| 44 for (var i = 0; i < conditions.length; ++i) | 44 for (var i = 0; i < conditions.length; ++i) |
| 45 this._list.appendItem(conditions[i], true); | 45 this._list.appendItem(conditions[i], true); |
| 46 | 46 |
| 47 this._list.appendSeparator(); | 47 this._list.appendSeparator(); |
| 48 | |
| 49 conditions = NetworkConditions.NetworkConditionsSelector.presets; | |
| 50 for (var i = 0; i < conditions.length; ++i) | |
| 51 this._list.appendItem(conditions[i], false); | |
| 52 } | 48 } |
| 53 | 49 |
| 54 _addButtonClicked() { | 50 _addButtonClicked() { |
| 55 this._list.addNewItem(this._customSetting.get().length, {title: '', download
: -1, upload: -1, latency: 0}); | 51 this._list.addNewItem(this._customSetting.get().length, {title: '', download
: -1, upload: -1, latency: 0}); |
| 56 } | 52 } |
| 57 | 53 |
| 58 /** | 54 /** |
| 59 * @override | 55 * @override |
| 60 * @param {*} item | 56 * @param {*} item |
| 61 * @param {boolean} editable | 57 * @param {boolean} editable |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 * @param {number} index | 192 * @param {number} index |
| 197 * @param {!HTMLInputElement|!HTMLSelectElement} input | 193 * @param {!HTMLInputElement|!HTMLSelectElement} input |
| 198 * @return {boolean} | 194 * @return {boolean} |
| 199 */ | 195 */ |
| 200 function latencyValidator(item, index, input) { | 196 function latencyValidator(item, index, input) { |
| 201 var value = input.value.trim(); | 197 var value = input.value.trim(); |
| 202 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000)
; | 198 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 1000000)
; |
| 203 } | 199 } |
| 204 } | 200 } |
| 205 }; | 201 }; |
| OLD | NEW |