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

Side by Side Diff: chrome/browser/chrome_browser_main.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 and Lei's comments 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 | « chrome/browser/about_flags.cc ('k') | components/flags_ui/feature_entry.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chrome_browser_main.h" 5 #include "chrome/browser/chrome_browser_main.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 723
724 // Create field trials without activating them, so that this behaves in a 724 // Create field trials without activating them, so that this behaves in a
725 // consistent manner with field trials created from the server. 725 // consistent manner with field trials created from the server.
726 bool result = base::FieldTrialList::CreateTrialsFromString( 726 bool result = base::FieldTrialList::CreateTrialsFromString(
727 command_line->GetSwitchValueASCII(switches::kForceFieldTrials), 727 command_line->GetSwitchValueASCII(switches::kForceFieldTrials),
728 unforceable_field_trials); 728 unforceable_field_trials);
729 CHECK(result) << "Invalid --" << switches::kForceFieldTrials 729 CHECK(result) << "Invalid --" << switches::kForceFieldTrials
730 << " list specified."; 730 << " list specified.";
731 } 731 }
732 732
733 if (command_line->HasSwitch(switches::kForceVariationIds)) {
734 // Create default variation ids which will always be included in the
735 // X-Client-Data request header.
736 variations::VariationsHttpHeaderProvider* provider =
737 variations::VariationsHttpHeaderProvider::GetInstance();
738 bool result = provider->SetDefaultVariationIds(
739 command_line->GetSwitchValueASCII(switches::kForceVariationIds));
740 CHECK(result) << "Invalid --" << switches::kForceVariationIds
741 << " list specified.";
742 metrics->AddSyntheticTrialObserver(provider);
743 }
744
745 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList); 733 std::unique_ptr<base::FeatureList> feature_list(new base::FeatureList);
746 734
747 // Associate parameters chosen in about:flags and create trial/group for them. 735 // Associate parameters chosen in about:flags and create trial/group for them.
748 flags_ui::PrefServiceFlagsStorage flags_storage( 736 flags_ui::PrefServiceFlagsStorage flags_storage(
749 g_browser_process->local_state()); 737 g_browser_process->local_state());
750 about_flags::RegisterAllFeatureVariationParameters(&flags_storage, 738 std::vector<std::string> variation_ids =
751 feature_list.get()); 739 about_flags::RegisterAllFeatureVariationParameters(
740 &flags_storage, feature_list.get());
741
742 if (command_line->HasSwitch(switches::kForceVariationIds)) {
743 // Combine the variation ids from chrome://flags with the ones from the
744 // command-line flag.
745 std::vector<std::string> variation_ids_flags = base::SplitString(
746 command_line->GetSwitchValueASCII(switches::kForceVariationIds), ",",
747 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
748 variation_ids.insert(variation_ids.end(), variation_ids_flags.begin(),
749 variation_ids_flags.end());
750 }
Alexei Svitkine (slow) 2016/07/26 14:44:07 I still think all this work should be being done i
jkrcal 2016/07/26 15:50:39 Done. It was not super clear to me where to cut th
751
752 if (!variation_ids.empty()) {
753 // Create default variation ids which will always be included in the
754 // X-Client-Data request header.
755 variations::VariationsHttpHeaderProvider* provider =
756 variations::VariationsHttpHeaderProvider::GetInstance();
757 bool result = provider->SetDefaultVariationIds(variation_ids);
758 CHECK(result) << "Invalid list of variation ids specified (either in --"
759 << switches::kForceVariationIds << " or in chrome://flags)";
760 metrics->AddSyntheticTrialObserver(provider);
761 }
752 762
753 feature_list->InitializeFromCommandLine( 763 feature_list->InitializeFromCommandLine(
754 command_line->GetSwitchValueASCII(switches::kEnableFeatures), 764 command_line->GetSwitchValueASCII(switches::kEnableFeatures),
755 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); 765 command_line->GetSwitchValueASCII(switches::kDisableFeatures));
756 766
757 #if defined(FIELDTRIAL_TESTING_ENABLED) 767 #if defined(FIELDTRIAL_TESTING_ENABLED)
758 if (!command_line->HasSwitch(switches::kDisableFieldTrialTestingConfig) && 768 if (!command_line->HasSwitch(switches::kDisableFieldTrialTestingConfig) &&
759 !command_line->HasSwitch(switches::kForceFieldTrials) && 769 !command_line->HasSwitch(switches::kForceFieldTrials) &&
760 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { 770 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) {
761 chrome_variations::AssociateDefaultFieldTrialConfig(feature_list.get()); 771 chrome_variations::AssociateDefaultFieldTrialConfig(feature_list.get());
(...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 chromeos::CrosSettings::Shutdown(); 2065 chromeos::CrosSettings::Shutdown();
2056 #endif // defined(OS_CHROMEOS) 2066 #endif // defined(OS_CHROMEOS)
2057 #endif // defined(OS_ANDROID) 2067 #endif // defined(OS_ANDROID)
2058 } 2068 }
2059 2069
2060 // Public members: 2070 // Public members:
2061 2071
2062 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { 2072 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) {
2063 chrome_extra_parts_.push_back(parts); 2073 chrome_extra_parts_.push_back(parts);
2064 } 2074 }
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | components/flags_ui/feature_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698