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

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: Remove an empty line (added by mistake) 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 unified diff | Download patch
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::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.empty())
466 variation_ids.push_back(variation->variation_id);
463 } 467 }
464 } 468 }
465 } 469 }
466 } 470 }
471
472 return base::JoinString(variation_ids, ",");
467 } 473 }
468 474
469 void FlagsState::GetFlagFeatureEntries( 475 void FlagsState::GetFlagFeatureEntries(
470 FlagsStorage* flags_storage, 476 FlagsStorage* flags_storage,
471 FlagAccess access, 477 FlagAccess access,
472 base::ListValue* supported_entries, 478 base::ListValue* supported_entries,
473 base::ListValue* unsupported_entries, 479 base::ListValue* unsupported_entries,
474 base::Callback<bool(const FeatureEntry&)> skip_feature_entry) { 480 base::Callback<bool(const FeatureEntry&)> skip_feature_entry) {
475 std::set<std::string> enabled_entries; 481 std::set<std::string> enabled_entries;
476 GetSanitizedEnabledFlags(flags_storage, &enabled_entries); 482 GetSanitizedEnabledFlags(flags_storage, &enabled_entries);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
721 } 727 }
722 728
723 std::set<std::string> new_enabled_entries = 729 std::set<std::string> new_enabled_entries =
724 base::STLSetIntersection<std::set<std::string>>(platform_entries, 730 base::STLSetIntersection<std::set<std::string>>(platform_entries,
725 *result); 731 *result);
726 732
727 result->swap(new_enabled_entries); 733 result->swap(new_enabled_entries);
728 } 734 }
729 735
730 } // namespace flags_ui 736 } // namespace flags_ui
OLDNEW
« chrome/browser/chrome_browser_main.cc ('K') | « components/flags_ui/flags_state.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698