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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/NetworkConditionsSelector.js

Issue 1801393002: [DevTools] When selected network preset is remove, select another one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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 * @param {function(!Array<!WebInspector.NetworkConditionsGroup>):!Array<?WebIns pector.NetworkManager.Conditions>} populateCallback 7 * @param {function(!Array<!WebInspector.NetworkConditionsGroup>):!Array<?WebIns pector.NetworkManager.Conditions>} populateCallback
8 * @param {function(number)} selectCallback 8 * @param {function(number)} selectCallback
9 */ 9 */
10 WebInspector.NetworkConditionsSelector = function(populateCallback, selectCallba ck) 10 WebInspector.NetworkConditionsSelector = function(populateCallback, selectCallba ck)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return {text: title, title: WebInspector.UIString("Maximum download throughp ut: %s.\r\nMaximum upload throughput: %s.\r\nMinimum round-trip time: %dms.", do wnloadText, uploadText, conditions.latency)}; 69 return {text: title, title: WebInspector.UIString("Maximum download throughp ut: %s.\r\nMaximum upload throughput: %s.\r\nMinimum round-trip time: %dms.", do wnloadText, uploadText, conditions.latency)};
70 } 70 }
71 71
72 WebInspector.NetworkConditionsSelector.prototype = { 72 WebInspector.NetworkConditionsSelector.prototype = {
73 _populateOptions: function() 73 _populateOptions: function()
74 { 74 {
75 var customGroup = {title: WebInspector.UIString("Custom"), items: this._ customSetting.get()}; 75 var customGroup = {title: WebInspector.UIString("Custom"), items: this._ customSetting.get()};
76 var presetsGroup = {title: WebInspector.UIString("Presets"), items: WebI nspector.NetworkConditionsSelector._presets}; 76 var presetsGroup = {title: WebInspector.UIString("Presets"), items: WebI nspector.NetworkConditionsSelector._presets};
77 var disabledGroup = {title: WebInspector.UIString("Disabled"), items: [W ebInspector.NetworkManager.NoThrottlingConditions]}; 77 var disabledGroup = {title: WebInspector.UIString("Disabled"), items: [W ebInspector.NetworkManager.NoThrottlingConditions]};
78 this._options = this._populateCallback([customGroup, presetsGroup, disab ledGroup]); 78 this._options = this._populateCallback([customGroup, presetsGroup, disab ledGroup]);
79 this._conditionsChanged(); 79 if (!this._conditionsChanged()) {
80 for (var i = this._options.length - 1; i >= 0; i--) {
81 if (this._options[i]) {
82 this.optionSelected(/** @type {!WebInspector.NetworkManager. Conditions} */ (this._options[i]));
83 break;
84 }
85 }
86 }
80 }, 87 },
81 88
82 revealAndUpdate: function() 89 revealAndUpdate: function()
83 { 90 {
84 WebInspector.Revealer.reveal(this._customSetting); 91 WebInspector.Revealer.reveal(this._customSetting);
85 this._conditionsChanged(); 92 this._conditionsChanged();
86 }, 93 },
87 94
88 /** 95 /**
89 * @param {!WebInspector.NetworkManager.Conditions} conditions 96 * @param {!WebInspector.NetworkManager.Conditions} conditions
90 */ 97 */
91 optionSelected: function(conditions) 98 optionSelected: function(conditions)
92 { 99 {
93 this._manager.setNetworkConditions(conditions); 100 this._manager.setNetworkConditions(conditions);
94 }, 101 },
95 102
103 /**
104 * @return {boolean}
105 */
96 _conditionsChanged: function() 106 _conditionsChanged: function()
97 { 107 {
98 var value = this._manager.networkConditions(); 108 var value = this._manager.networkConditions();
99 for (var index = 0; index < this._options.length; ++index) { 109 for (var index = 0; index < this._options.length; ++index) {
100 var option = this._options[index]; 110 var option = this._options[index];
101 if (!option) 111 if (option && option.download === value.download && option.upload == = value.upload && option.latency === value.latency && option.title === value.tit le) {
102 continue;
103 if (option.download === value.download && option.upload === value.up load && option.latency === value.latency && option.title === value.title)
104 this._selectCallback(index); 112 this._selectCallback(index);
113 return true;
114 }
105 } 115 }
116 return false;
106 } 117 }
107 } 118 }
108 119
109 /** 120 /**
110 * @param {!HTMLSelectElement} selectElement 121 * @param {!HTMLSelectElement} selectElement
111 */ 122 */
112 WebInspector.NetworkConditionsSelector.decorateSelect = function(selectElement) 123 WebInspector.NetworkConditionsSelector.decorateSelect = function(selectElement)
113 { 124 {
114 var options = []; 125 var options = [];
115 var selector = new WebInspector.NetworkConditionsSelector(populate, select); 126 var selector = new WebInspector.NetworkConditionsSelector(populate, select);
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 */ 427 */
417 function latencyValidator(item, index, input) 428 function latencyValidator(item, index, input)
418 { 429 {
419 var value = input.value.trim(); 430 var value = input.value.trim();
420 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 10 00000); 431 return !value || (/^[\d]+$/.test(value) && value >= 0 && value <= 10 00000);
421 } 432 }
422 }, 433 },
423 434
424 __proto__: WebInspector.VBox.prototype 435 __proto__: WebInspector.VBox.prototype
425 } 436 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698