Use default flag style for multi-value flags if no switches have been passed.
BUG=None
TEST=Multi value experiments on chrome://flags have same style as single value experiments when no overriding flags have been passed.
Review URL: https://codereview.chromium.org/1191493004
Cr-Commit-Position: refs/heads/master@{#335138}
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index e661e24..1f94e3b8 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2183,6 +2183,27 @@
result->swap(new_enabled_experiments);
}
+// Returns true if none of this experiment's options have been enabled.
+bool IsDefaultValue(
+ const Experiment& experiment,
+ const std::set<std::string>& enabled_experiments) {
+ switch (experiment.type) {
+ case Experiment::SINGLE_VALUE:
+ case Experiment::SINGLE_DISABLE_VALUE:
+ return enabled_experiments.count(experiment.internal_name) == 0;
+ case Experiment::MULTI_VALUE:
+ case Experiment::ENABLE_DISABLE_VALUE:
+ for (int i = 0; i < experiment.num_choices; ++i) {
+ if (enabled_experiments.count(experiment.NameForChoice(i)) > 0)
+ return false;
+ }
+ break;
+ default:
+ NOTREACHED();
+ }
+ return true;
+}
+
// Returns the Value representing the choice data in the specified experiment.
base::Value* CreateChoiceData(
const Experiment& experiment,
@@ -2291,14 +2312,12 @@
AddOsStrings(experiment.supported_platforms, supported_platforms);
data->Set("supported_platforms", supported_platforms);
// True if the switch is not currently passed.
- bool is_default_value =
- enabled_experiments.count(experiment.internal_name) == 0;
+ bool is_default_value = IsDefaultValue(experiment, enabled_experiments);
+ data->SetBoolean("is_default", is_default_value);
switch (experiment.type) {
case Experiment::SINGLE_VALUE:
case Experiment::SINGLE_DISABLE_VALUE:
- data->SetBoolean("is_default", is_default_value);
-
data->SetBoolean(
"enabled",
(!is_default_value &&