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

Side by Side Diff: components/flags_ui/flags_state.cc

Issue 2182553002: Add other variations (with ids) for NTPSnippets to chrome://flags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alexei's comment #5 + fix a bug Created 4 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 unified diff | Download patch
« no previous file with comments | « components/flags_ui/flags_state.h ('k') | components/flags_ui/flags_state_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/flags_ui/flags_state.h" 5 #include "components/flags_ui/flags_state.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 std::set<std::string> no_entries; 429 std::set<std::string> no_entries;
430 flags_storage->SetFlags(no_entries); 430 flags_storage->SetFlags(no_entries);
431 } 431 }
432 432
433 void FlagsState::Reset() { 433 void FlagsState::Reset() {
434 needs_restart_ = false; 434 needs_restart_ = false;
435 flags_switches_.clear(); 435 flags_switches_.clear();
436 appended_switches_.clear(); 436 appended_switches_.clear();
437 } 437 }
438 438
439 void FlagsState::RegisterAllFeatureVariationParameters( 439 std::vector<std::string> FlagsState::RegisterAllFeatureVariationParameters(
440 FlagsStorage* flags_storage, 440 FlagsStorage* flags_storage,
441 base::FeatureList* feature_list) { 441 base::FeatureList* feature_list) {
442 std::set<std::string> enabled_entries; 442 std::set<std::string> enabled_entries;
443 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage, &enabled_entries); 443 GetSanitizedEnabledFlagsForCurrentPlatform(flags_storage, &enabled_entries);
444 std::vector<std::string> variation_ids;
444 445
445 for (size_t i = 0; i < num_feature_entries_; ++i) { 446 for (size_t i = 0; i < num_feature_entries_; ++i) {
446 const FeatureEntry& e = feature_entries_[i]; 447 const FeatureEntry& e = feature_entries_[i];
447 if (e.type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE) { 448 if (e.type == FeatureEntry::FEATURE_WITH_VARIATIONS_VALUE) {
448 for (int j = 0; j < e.num_options; ++j) { 449 for (int j = 0; j < e.num_options; ++j) {
449 const FeatureEntry::FeatureVariation* variation = 450 const FeatureEntry::FeatureVariation* variation =
450 e.VariationForOption(j); 451 e.VariationForOption(j);
451 if (e.StateForOption(j) == FeatureEntry::FeatureState::ENABLED && 452 if (e.StateForOption(j) == FeatureEntry::FeatureState::ENABLED &&
452 enabled_entries.count(e.NameForOption(j))) { 453 enabled_entries.count(e.NameForOption(j))) {
453 // If the option is selected by the user & has variation, register it. 454 // If the option is selected by the user & has variation, register it.
454 base::FieldTrial* field_trial = RegisterFeatureVariationParameters( 455 base::FieldTrial* field_trial = RegisterFeatureVariationParameters(
455 e.feature_trial_name, variation); 456 e.feature_trial_name, variation);
456 457
457 if (!field_trial) 458 if (!field_trial)
458 continue; 459 continue;
459 feature_list->RegisterFieldTrialOverride( 460 feature_list->RegisterFieldTrialOverride(
460 e.feature->name, 461 e.feature->name,
461 base::FeatureList::OverrideState::OVERRIDE_ENABLE_FEATURE, 462 base::FeatureList::OverrideState::OVERRIDE_ENABLE_FEATURE,
462 field_trial); 463 field_trial);
464
465 if (variation && variation->variation_id)
466 variation_ids.push_back(variation->variation_id);
463 } 467 }
464 } 468 }
465 } 469 }
466 } 470 }
471 return variation_ids;
467 } 472 }
468 473
469 void FlagsState::GetFlagFeatureEntries( 474 void FlagsState::GetFlagFeatureEntries(
470 FlagsStorage* flags_storage, 475 FlagsStorage* flags_storage,
471 FlagAccess access, 476 FlagAccess access,
472 base::ListValue* supported_entries, 477 base::ListValue* supported_entries,
473 base::ListValue* unsupported_entries, 478 base::ListValue* unsupported_entries,
474 base::Callback<bool(const FeatureEntry&)> skip_feature_entry) { 479 base::Callback<bool(const FeatureEntry&)> skip_feature_entry) {
475 std::set<std::string> enabled_entries; 480 std::set<std::string> enabled_entries;
476 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); 481 GetSanitizedEnabledFlags(flags_storage, &enabled_entries);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 726 }
722 727
723 std::set<std::string> new_enabled_entries = 728 std::set<std::string> new_enabled_entries =
724 base::STLSetIntersection<std::set<std::string>>(platform_entries, 729 base::STLSetIntersection<std::set<std::string>>(platform_entries,
725 *result); 730 *result);
726 731
727 result->swap(new_enabled_entries); 732 result->swap(new_enabled_entries);
728 } 733 }
729 734
730 } // namespace flags_ui 735 } // namespace flags_ui
OLDNEW
« no previous file with comments | « components/flags_ui/flags_state.h ('k') | components/flags_ui/flags_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698