Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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::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)) { | |
|
Lei Zhang
2016/07/25 17:37:20
The command line can have the switch but its value
jkrcal
2016/07/26 09:00:21
Thanks for pointing out! Such a case in handled (a
| |
| 743 // Combine the variation ids from chrome://flags with the once from the | |
| 744 // command-line flag. | |
| 745 if (!variation_ids.empty()) { | |
| 746 variation_ids += | |
| 747 "," + command_line->GetSwitchValueASCII(switches::kForceVariationIds); | |
| 748 } else { | |
| 749 variation_ids = | |
| 750 command_line->GetSwitchValueASCII(switches::kForceVariationIds); | |
| 751 } | |
| 752 } | |
|
Alexei Svitkine (slow)
2016/07/25 19:15:50
Instead of all this extra work in chrome_browser_m
jkrcal
2016/07/26 09:00:21
I tried to simplify it. Do not like the idea of mo
| |
| 753 | |
| 754 if (!variation_ids.empty()) { | |
| 755 // Create default variation ids which will always be included in the | |
| 756 // X-Client-Data request header. | |
| 757 variations::VariationsHttpHeaderProvider* provider = | |
| 758 variations::VariationsHttpHeaderProvider::GetInstance(); | |
| 759 bool result = provider->SetDefaultVariationIds(variation_ids); | |
| 760 CHECK(result) << "Invalid list of variation ids specified (either in --" | |
| 761 << switches::kForceVariationIds << " or in chrome://flags)"; | |
| 762 metrics->AddSyntheticTrialObserver(provider); | |
| 763 } | |
| 752 | 764 |
| 753 feature_list->InitializeFromCommandLine( | 765 feature_list->InitializeFromCommandLine( |
| 754 command_line->GetSwitchValueASCII(switches::kEnableFeatures), | 766 command_line->GetSwitchValueASCII(switches::kEnableFeatures), |
| 755 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); | 767 command_line->GetSwitchValueASCII(switches::kDisableFeatures)); |
| 756 | 768 |
| 757 #if defined(FIELDTRIAL_TESTING_ENABLED) | 769 #if defined(FIELDTRIAL_TESTING_ENABLED) |
| 758 if (!command_line->HasSwitch(switches::kDisableFieldTrialTestingConfig) && | 770 if (!command_line->HasSwitch(switches::kDisableFieldTrialTestingConfig) && |
| 759 !command_line->HasSwitch(switches::kForceFieldTrials) && | 771 !command_line->HasSwitch(switches::kForceFieldTrials) && |
| 760 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { | 772 !command_line->HasSwitch(variations::switches::kVariationsServerURL)) { |
| 761 chrome_variations::AssociateDefaultFieldTrialConfig(feature_list.get()); | 773 chrome_variations::AssociateDefaultFieldTrialConfig(feature_list.get()); |
| (...skipping 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2055 chromeos::CrosSettings::Shutdown(); | 2067 chromeos::CrosSettings::Shutdown(); |
| 2056 #endif // defined(OS_CHROMEOS) | 2068 #endif // defined(OS_CHROMEOS) |
| 2057 #endif // defined(OS_ANDROID) | 2069 #endif // defined(OS_ANDROID) |
| 2058 } | 2070 } |
| 2059 | 2071 |
| 2060 // Public members: | 2072 // Public members: |
| 2061 | 2073 |
| 2062 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { | 2074 void ChromeBrowserMainParts::AddParts(ChromeBrowserMainExtraParts* parts) { |
| 2063 chrome_extra_parts_.push_back(parts); | 2075 chrome_extra_parts_.push_back(parts); |
| 2064 } | 2076 } |
| OLD | NEW |