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

Unified Diff: chrome/browser/about_flags.cc

Issue 1191493004: Use default flag style for multi-value flags if no switches have been passed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/about_flags.cc
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 0aeb725b9c378af1fb1afa8850405a38e5e4b095..008e67e45d3ec1e4e325f25674be8fa5dcaedb9e 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2180,6 +2180,27 @@ void GetSanitizedEnabledFlagsForCurrentPlatform(
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,
@@ -2288,14 +2309,12 @@ void GetFlagsExperimentsData(FlagsStorage* flags_storage,
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 &&
« 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