| Index: Source/devtools/front_end/components/NetworkConditionsSelector.js
|
| diff --git a/Source/devtools/front_end/components/NetworkConditionsSelector.js b/Source/devtools/front_end/components/NetworkConditionsSelector.js
|
| index 86c338e9d55bd21e944b9e67aaf4cc09f9717a99..3ee74687bbc349154ea5f0934401a0b19d81470f 100644
|
| --- a/Source/devtools/front_end/components/NetworkConditionsSelector.js
|
| +++ b/Source/devtools/front_end/components/NetworkConditionsSelector.js
|
| @@ -64,36 +64,63 @@ WebInspector.NetworkConditionsSelector._networkConditionsPresets = [
|
| {title: "Good 3G", value: {throughput: 1.5 * 1024 * 1024 / 8, latency: 40}},
|
| {title: "Regular 4G", value: {throughput: 4 * 1024 * 1024 / 8, latency: 20}},
|
| {title: "DSL", value: {throughput: 2 * 1024 * 1024 / 8, latency: 5}},
|
| - {title: "WiFi", value: {throughput: 30 * 1024 * 1024 / 8, latency: 2}},
|
| - {title: "No throttling", value: {throughput: -1, latency: 0}}
|
| + {title: "WiFi", value: {throughput: 30 * 1024 * 1024 / 8, latency: 2}}
|
| ];
|
|
|
| +/** @type {!WebInspector.NetworkConditionsProfile} */
|
| +WebInspector.NetworkConditionsSelector._disabledPreset = {title: "No throttling", value: {throughput: -1, latency: 0}};
|
| +
|
| WebInspector.NetworkConditionsSelector.prototype = {
|
| _populateOptions: function()
|
| {
|
| this._selectElement.removeChildren();
|
| - var presets = this._customSetting.get().concat(WebInspector.NetworkConditionsSelector._networkConditionsPresets);
|
| + this._addGroup(this._customSetting.get(), WebInspector.UIString("Custom"));
|
| + this._addGroup(WebInspector.NetworkConditionsSelector._networkConditionsPresets, WebInspector.UIString("Presets"));
|
| + this._addGroup([WebInspector.NetworkConditionsSelector._disabledPreset], WebInspector.UIString("Disabled"));
|
| +
|
| + var editOption = new Option(WebInspector.UIString("Edit..."), WebInspector.UIString("Edit..."));
|
| + this._selectElement.appendChild(editOption);
|
| +
|
| + this._settingChanged();
|
| + },
|
| +
|
| + /**
|
| + * @param {!Array.<!WebInspector.NetworkConditionsProfile>} presets
|
| + * @param {string} groupName
|
| + */
|
| + _addGroup: function(presets, groupName)
|
| + {
|
| + if (!presets.length)
|
| + return;
|
| + var groupElement = this._selectElement.createChild("optgroup");
|
| + groupElement.label = groupName;
|
| for (var i = 0; i < presets.length; ++i) {
|
| var preset = presets[i];
|
| var throughputInKbps = preset.value.throughput / (1024 / 8);
|
| var isThrottling = (throughputInKbps > 0) || preset.value.latency;
|
| var option;
|
| + var presetTitle = WebInspector.UIString(preset.title);
|
| if (!isThrottling) {
|
| - option = new Option(preset.title, preset.title);
|
| + option = new Option(presetTitle, presetTitle);
|
| } else {
|
| var throughputText = WebInspector.NetworkConditionsSelector.throughputText(preset.value);
|
| - var title = WebInspector.UIString("%s (%s %dms RTT)", preset.title, throughputText, preset.value.latency);
|
| - option = new Option(title, preset.title);
|
| + var title = WebInspector.UIString("%s (%s %dms RTT)", presetTitle, throughputText, preset.value.latency);
|
| + option = new Option(title, presetTitle);
|
| option.title = WebInspector.UIString("Maximum download throughput: %s.\r\nMinimum round-trip time: %dms.", throughputText, preset.value.latency);
|
| }
|
| option.settingValue = preset.value;
|
| - this._selectElement.appendChild(option);
|
| + groupElement.appendChild(option);
|
| }
|
| - this._settingChanged();
|
| },
|
|
|
| _optionSelected: function()
|
| {
|
| + if (this._selectElement.selectedIndex === this._selectElement.options.length - 1) {
|
| + WebInspector.Revealer.reveal(this._customSetting);
|
| + this._settingChanged();
|
| + return;
|
| + }
|
| +
|
| this._setting.removeChangeListener(this._settingChanged, this);
|
| this._setting.set(this._selectElement.options[this._selectElement.selectedIndex].settingValue);
|
| this._setting.addChangeListener(this._settingChanged, this);
|
| @@ -103,7 +130,7 @@ WebInspector.NetworkConditionsSelector.prototype = {
|
| {
|
| var value = this._setting.get();
|
| var options = this._selectElement.options;
|
| - for (var index = 0; index < options.length; ++index) {
|
| + for (var index = 0; index < options.length - 1; ++index) {
|
| var option = options[index];
|
| if (option.settingValue.throughput === value.throughput && option.settingValue.latency === value.latency)
|
| this._selectElement.selectedIndex = index;
|
|
|