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

Unified Diff: components/flags_ui/flags_state.cc

Issue 2146903002: Clean-up the code for default variations in chrome://flags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iOS test crash fix? #2 Created 4 years, 5 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 | « components/flags_ui/feature_entry_macros.h ('k') | components/flags_ui/flags_state_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/flags_ui/flags_state.cc
diff --git a/components/flags_ui/flags_state.cc b/components/flags_ui/flags_state.cc
index cadb8ee140137388db6ffb2bd33d001dad07430c..441949bcbc49a75abbcb3218995ff541c8df7ed0 100644
--- a/components/flags_ui/flags_state.cc
+++ b/components/flags_ui/flags_state.cc
@@ -199,11 +199,14 @@ base::Value* CreateOptionsData(const FeatureEntry& entry,
// |kTrialGroupAboutFlags|.
void RegisterFeatureVariationParameters(
const std::string& feature_trial_name,
- const FeatureEntry::FeatureVariation& feature_variation) {
+ const FeatureEntry::FeatureVariation* feature_variation) {
std::map<std::string, std::string> params;
- for (int i = 0; i < feature_variation.num_params; ++i) {
- params[feature_variation.params[i].param_name] =
- feature_variation.params[i].param_value;
+ if (feature_variation) {
+ // Copy the parameters for non-null variations.
+ for (int i = 0; i < feature_variation->num_params; ++i) {
+ params[feature_variation->params[i].param_name] =
+ feature_variation->params[i].param_value;
+ }
}
bool success = variations::AssociateVariationParams(
@@ -443,9 +446,10 @@ void FlagsState::RegisterAllFeatureVariationParameters(
for (int j = 0; j < e.num_options; ++j) {
const FeatureEntry::FeatureVariation* variation =
e.VariationForOption(j);
- if (variation != nullptr && enabled_entries.count(e.NameForOption(j))) {
- // If the option is selected by the user & has variation, register it.
- RegisterFeatureVariationParameters(e.feature_trial_name, *variation);
+ if (e.StateForOption(j) == FeatureEntry::FeatureState::ENABLED &&
+ enabled_entries.count(e.NameForOption(j))) {
+ // If the option is enabled by the user, register it.
+ RegisterFeatureVariationParameters(e.feature_trial_name, variation);
// TODO(jkrcal) The code does not associate the feature with the field
// trial |e.feature_trial_name|. The reason is that features
// overridden in chrome://flags are translated to command-line flags
« no previous file with comments | « components/flags_ui/feature_entry_macros.h ('k') | components/flags_ui/flags_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698