Chromium Code Reviews| Index: chrome/browser/profile_resetter/automatic_profile_resetter.cc |
| diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter.cc b/chrome/browser/profile_resetter/automatic_profile_resetter.cc |
| index d5dcf39e41ca468078e2badd8aa4a6c806277971..e271e4856feecb9920fdea57fb6b3f72c1046301 100644 |
| --- a/chrome/browser/profile_resetter/automatic_profile_resetter.cc |
| +++ b/chrome/browser/profile_resetter/automatic_profile_resetter.cc |
| @@ -133,18 +133,25 @@ bool ShouldPerformLiveRun() { |
| kAutomaticProfileResetStudyEnabledGroupName, true); |
| } |
| -// Returns whether or not the currently active experiment group prescribes the |
| -// program and hash seed to use instead of the baked-in ones. |
| -bool DoesExperimentOverrideProgramAndHashSeed() { |
| +// If the currently active experiment group prescribes a |program| and |
| +// |ħash_seed| to use instead of the baked-in ones, retrieves those and returns |
|
Alexei Svitkine (slow)
2013/11/06 17:30:29
Nit: Is the 'h' in hash_seed some accented one her
engedy
2013/11/06 18:14:28
Wow, I have no idea how that happened. Thanks for
|
| +// true. Otherwise, returns false. |
| +bool GetProgramAndHashSeedOverridesFromExperiment(std::string* program, |
| + std::string* hash_seed) { |
| + DCHECK(program); |
| + DCHECK(hash_seed); |
| #if defined(GOOGLE_CHROME_BUILD) |
| std::map<std::string, std::string> params; |
| chrome_variations::GetVariationParams(kAutomaticProfileResetStudyName, |
| ¶ms); |
| - return params.count(kAutomaticProfileResetStudyProgramParameterName) && |
| - params.count(kAutomaticProfileResetStudyHashSeedParameterName); |
| -#else |
| - return false; |
| + if (params.count(kAutomaticProfileResetStudyProgramParameterName) && |
| + params.count(kAutomaticProfileResetStudyHashSeedParameterName)) { |
| + program->swap(params[kAutomaticProfileResetStudyProgramParameterName]); |
| + hash_seed->swap(params[kAutomaticProfileResetStudyHashSeedParameterName]); |
| + return true; |
| + } |
| #endif |
| + return false; |
| } |
| // Deep-copies all preferences in |source| to a sub-tree named |value_tree_key| |
| @@ -209,24 +216,19 @@ void AutomaticProfileResetter::Initialize() { |
| return; |
| } |
| - ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance()); |
| - if (DoesExperimentOverrideProgramAndHashSeed()) { |
| - program_ = chrome_variations::GetVariationParamValue( |
| - kAutomaticProfileResetStudyName, |
| - kAutomaticProfileResetStudyProgramParameterName); |
| - hash_seed_ = chrome_variations::GetVariationParamValue( |
| - kAutomaticProfileResetStudyName, |
| - kAutomaticProfileResetStudyHashSeedParameterName); |
| - } else if (ShouldPerformLiveRun()) { |
| - program_ = resources.GetRawDataResource( |
| - IDR_AUTOMATIC_PROFILE_RESET_RULES).as_string(); |
| - hash_seed_ = resources.GetRawDataResource( |
| - IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED).as_string(); |
| - } else { // ShouldPerformDryRun() |
| - program_ = resources.GetRawDataResource( |
| - IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY).as_string(); |
| - hash_seed_ = resources.GetRawDataResource( |
| - IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY).as_string(); |
| + if (!GetProgramAndHashSeedOverridesFromExperiment(&program_, &hash_seed_)) { |
| + ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance()); |
| + if (ShouldPerformLiveRun()) { |
| + program_ = resources.GetRawDataResource( |
| + IDR_AUTOMATIC_PROFILE_RESET_RULES).as_string(); |
| + hash_seed_ = resources.GetRawDataResource( |
| + IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED).as_string(); |
| + } else { // ShouldPerformDryRun() |
| + program_ = resources.GetRawDataResource( |
| + IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY).as_string(); |
| + hash_seed_ = resources.GetRawDataResource( |
| + IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY).as_string(); |
| + } |
| } |
| delegate_.reset(new AutomaticProfileResetterDelegateImpl( |