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

Unified Diff: Source/devtools/front_end/components/NetworkConditionsSelector.js

Issue 1292673002: [DevTools] Group options in network presets select. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated visual design Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/devtools/front_end/components/module.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..08cc91dcd44943afa065a5e463a1b1ce4529d262 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);
+
+ var customGroup = this._addGroup(this._customSetting.get(), WebInspector.UIString("Custom"));
+ customGroup.insertBefore(new Option(WebInspector.UIString("Add..."), WebInspector.UIString("Add...")), customGroup.firstChild);
pfeldman 2015/08/17 19:00:12 Use ellipsis from the unicode set.
dgozman 2015/08/19 01:59:11 Done.
+
+ this._addGroup(WebInspector.NetworkConditionsSelector._networkConditionsPresets, WebInspector.UIString("Presets"));
+ this._addGroup([WebInspector.NetworkConditionsSelector._disabledPreset], WebInspector.UIString("Disabled"));
+
+ this._settingChanged();
+ },
+
+ /**
+ * @param {!Array.<!WebInspector.NetworkConditionsProfile>} presets
+ * @param {string} groupName
+ * @return {!Element}
+ */
+ _addGroup: function(presets, groupName)
+ {
+ 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();
+ return groupElement;
},
_optionSelected: function()
{
+ if (this._selectElement.selectedIndex === 0) {
+ 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 = 1; index < options.length; ++index) {
var option = options[index];
if (option.settingValue.throughput === value.throughput && option.settingValue.latency === value.latency)
this._selectElement.selectedIndex = index;
« no previous file with comments | « no previous file | Source/devtools/front_end/components/module.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698