| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_resetter/automatic_profile_resetter.h" | 5 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h" |
| 6 | 6 |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_number_conversions.h" |
| 13 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
| 14 #include "base/task_runner_util.h" | 15 #include "base/task_runner_util.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
| 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h" |
| 16 #include "chrome/browser/profile_resetter/jtl_interpreter.h" | 19 #include "chrome/browser/profile_resetter/jtl_interpreter.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 18 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
| 19 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
| 20 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 21 | 24 |
| 22 namespace { | 25 namespace { |
| 23 | 26 |
| 24 // Number of bits, and maximum value (exclusive) for the mask whose bits | |
| 25 // indicate which of reset criteria were satisfied. | |
| 26 const size_t kSatisfiedCriteriaMaskBits = 2; | |
| 27 const uint32 kSatisfiedCriteriaMaskMaximumValue = | |
| 28 (1 << kSatisfiedCriteriaMaskBits); | |
| 29 | |
| 30 // Number of bits, and maximum value (exclusive) for the mask whose bits | |
| 31 // indicate if any of reset criteria were satisfied, and which of the mementos | |
| 32 // were already present. | |
| 33 const size_t kCombinedStatusMaskBits = 4; | |
| 34 const uint32 kCombinedStatusMaskMaximumValue = (1 << kCombinedStatusMaskBits); | |
| 35 | |
| 36 // Name constants for the field trial behind which we enable this feature. | 27 // Name constants for the field trial behind which we enable this feature. |
| 37 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; | 28 const char kAutomaticProfileResetStudyName[] = "AutomaticProfileReset"; |
| 38 const char kAutomaticProfileResetStudyDryRunGroupName[] = "DryRun"; | 29 const char kAutomaticProfileResetStudyDryRunGroupName[] = "DryRun"; |
| 39 const char kAutomaticProfileResetStudyEnabledGroupName[] = "Enabled"; | 30 const char kAutomaticProfileResetStudyEnabledGroupName[] = "Enabled"; |
| 40 | 31 |
| 41 // Keys used in the input dictionary of the program. | 32 // Keys used in the input dictionary of the program. |
| 42 // TODO(engedy): Add these here on an as-needed basis. | 33 const char kUserPreferencesKey[] = "preferences"; |
| 34 const char kUserPreferencesIsUserControlledKey[] = "preferences_iuc"; |
| 35 const char kLocalStateKey[] = "local_state"; |
| 36 const char kLocalStateIsUserControlledKey[] = "local_state_iuc"; |
| 37 const char kSearchProvidersKey[] = "search_providers"; |
| 38 const char kDefaultSearchProviderKey[] = "default_search_provider"; |
| 39 const char kDefaultSearchProviderIsUserControlledKey[] = |
| 40 "default_search_provider_iuc"; |
| 43 | 41 |
| 44 // Keys used in the output dictionary of the program. | 42 // Keys used in the output dictionary of the program. |
| 45 const char kHadPromptedAlreadyKey[] = "had_prompted_already"; | 43 const char kHadPromptedAlreadyKey[] = "had_prompted_already"; |
| 46 const char kSatisfiedCriteriaMaskKeys[][29] = {"satisfied_criteria_mask_bit1", | 44 const char kSatisfiedCriteriaMaskKeys[][29] = {"satisfied_criteria_mask_bit1", |
| 47 "satisfied_criteria_mask_bit2"}; | 45 "satisfied_criteria_mask_bit2"}; |
| 48 const char kCombinedStatusMaskKeys[][26] = { | 46 const char kCombinedStatusMaskKeys[][26] = { |
| 49 "combined_status_mask_bit1", "combined_status_mask_bit2", | 47 "combined_status_mask_bit1", "combined_status_mask_bit2", |
| 50 "combined_status_mask_bit3", "combined_status_mask_bit4"}; | 48 "combined_status_mask_bit3", "combined_status_mask_bit4"}; |
| 51 | 49 |
| 52 // Keys used in both the input and output dictionary of the program. | 50 // Keys used in both the input and output dictionary of the program. |
| 53 const char kMementoValueInPrefsKey[] = "memento_value_in_prefs"; | 51 const char kMementoValueInPrefsKey[] = "memento_value_in_prefs"; |
| 54 const char kMementoValueInLocalStateKey[] = "memento_value_in_local_state"; | 52 const char kMementoValueInLocalStateKey[] = "memento_value_in_local_state"; |
| 55 const char kMementoValueInFileKey[] = "memento_value_in_file"; | 53 const char kMementoValueInFileKey[] = "memento_value_in_file"; |
| 56 | 54 |
| 57 COMPILE_ASSERT( | 55 // Implementation details ------------------------------------------------------ |
| 58 arraysize(kSatisfiedCriteriaMaskKeys) == kSatisfiedCriteriaMaskBits, | |
| 59 satisfied_criteria_mask_bits_mismatch); | |
| 60 COMPILE_ASSERT(arraysize(kCombinedStatusMaskKeys) == kCombinedStatusMaskBits, | |
| 61 combined_status_mask_bits_mismatch); | |
| 62 | |
| 63 // Implementation detail classes --------------------------------------------- | |
| 64 | |
| 65 class AutomaticProfileResetterDelegateImpl | |
| 66 : public AutomaticProfileResetterDelegate { | |
| 67 public: | |
| 68 AutomaticProfileResetterDelegateImpl() {} | |
| 69 virtual ~AutomaticProfileResetterDelegateImpl() {} | |
| 70 | |
| 71 // AutomaticProfileResetterDelegate overrides: | |
| 72 | |
| 73 virtual void ShowPrompt() OVERRIDE { | |
| 74 // TODO(engedy): Call the UI from here once we have it. | |
| 75 } | |
| 76 | |
| 77 virtual void ReportStatistics(uint32 satisfied_criteria_mask, | |
| 78 uint32 combined_status_mask) OVERRIDE { | |
| 79 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.SatisfiedCriteriaMask", | |
| 80 satisfied_criteria_mask, | |
| 81 kSatisfiedCriteriaMaskMaximumValue); | |
| 82 UMA_HISTOGRAM_ENUMERATION("AutomaticProfileReset.CombinedStatusMask", | |
| 83 combined_status_mask, | |
| 84 kCombinedStatusMaskMaximumValue); | |
| 85 } | |
| 86 | |
| 87 private: | |
| 88 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); | |
| 89 }; | |
| 90 | 56 |
| 91 // Enumeration of the possible outcomes of showing the profile reset prompt. | 57 // Enumeration of the possible outcomes of showing the profile reset prompt. |
| 92 enum PromptResult { | 58 enum PromptResult { |
| 93 // Prompt was not shown because only a dry-run was performed. | 59 // Prompt was not shown because only a dry-run was performed. |
| 94 PROMPT_NOT_SHOWN, | 60 PROMPT_NOT_SHOWN, |
| 95 PROMPT_ACTION_RESET, | 61 PROMPT_ACTION_RESET, |
| 96 PROMPT_ACTION_NO_RESET, | 62 PROMPT_ACTION_NO_RESET, |
| 97 PROMPT_DISMISSED, | 63 PROMPT_DISMISSED, |
| 98 // Prompt was still shown (not dismissed by the user) when Chrome was closed. | 64 // Prompt was still shown (not dismissed by the user) when Chrome was closed. |
| 99 PROMPT_IGNORED, | 65 PROMPT_IGNORED, |
| 100 PROMPT_RESULT_MAX | 66 PROMPT_RESULT_MAX |
| 101 }; | 67 }; |
| 102 | 68 |
| 69 // Deep-copies all preferences in |source| to a sub-tree named |value_tree_key| |
| 70 // in |target_dictionary|, with path expansion, and also creates an isomorphic |
| 71 // sub-tree under the key |is_user_controlled_tree_key| that contains only |
| 72 // Boolean values, indicating whether or not the corresponding preferences are |
| 73 // coming from the 'user' PrefStore. |
| 74 void BuildSubTreesFromPreferences(const PrefService* source, |
| 75 base::DictionaryValue* target_dictionary, |
| 76 const char* value_tree_key, |
| 77 const char* is_user_controlled_tree_key) { |
| 78 scoped_ptr<base::DictionaryValue> pref_name_to_value_map( |
| 79 source->GetPreferenceValuesWithoutPathExpansion()); |
| 80 std::vector<std::string> pref_names; |
| 81 pref_names.reserve(pref_name_to_value_map->size()); |
| 82 for (base::DictionaryValue::Iterator it(*pref_name_to_value_map); |
| 83 !it.IsAtEnd(); |
| 84 it.Advance()) { |
| 85 pref_names.push_back(it.key()); |
| 86 } |
| 87 base::DictionaryValue* value_tree = new base::DictionaryValue; |
| 88 base::DictionaryValue* is_user_controlled_tree = new base::DictionaryValue; |
| 89 for (std::vector<std::string>::const_iterator it = pref_names.begin(); |
| 90 it != pref_names.end(); |
| 91 ++it) { |
| 92 scoped_ptr<Value> pref_value_owned; |
| 93 if (pref_name_to_value_map->RemoveWithoutPathExpansion(*it, |
| 94 &pref_value_owned)) { |
| 95 value_tree->Set(*it, pref_value_owned.release()); |
| 96 const PrefService::Preference* pref = source->FindPreference(it->c_str()); |
| 97 is_user_controlled_tree->Set( |
| 98 *it, new base::FundamentalValue(pref->IsUserControlled())); |
| 99 } |
| 100 } |
| 101 target_dictionary->Set(value_tree_key, value_tree); |
| 102 target_dictionary->Set(is_user_controlled_tree_key, is_user_controlled_tree); |
| 103 } |
| 104 |
| 103 } // namespace | 105 } // namespace |
| 104 | 106 |
| 105 // AutomaticProfileResetter::EvaluationResults ------------------------------- | 107 // AutomaticProfileResetter::EvaluationResults ------------------------------- |
| 106 | 108 |
| 107 // Encapsulates the output values extracted from the evaluator program. | 109 // Encapsulates the output values extracted from the evaluator program. |
| 108 struct AutomaticProfileResetter::EvaluationResults { | 110 struct AutomaticProfileResetter::EvaluationResults { |
| 109 EvaluationResults() | 111 EvaluationResults() |
| 110 : had_prompted_already(false), | 112 : had_prompted_already(false), |
| 111 satisfied_criteria_mask(0), | 113 satisfied_criteria_mask(0), |
| 112 combined_status_mask(0) {} | 114 combined_status_mask(0) {} |
| 113 | 115 |
| 114 std::string memento_value_in_prefs; | 116 std::string memento_value_in_prefs; |
| 115 std::string memento_value_in_local_state; | 117 std::string memento_value_in_local_state; |
| 116 std::string memento_value_in_file; | 118 std::string memento_value_in_file; |
| 117 | 119 |
| 118 bool had_prompted_already; | 120 bool had_prompted_already; |
| 119 uint32 satisfied_criteria_mask; | 121 uint32 satisfied_criteria_mask; |
| 120 uint32 combined_status_mask; | 122 uint32 combined_status_mask; |
| 121 }; | 123 }; |
| 122 | 124 |
| 123 // AutomaticProfileResetter -------------------------------------------------- | 125 // AutomaticProfileResetter -------------------------------------------------- |
| 124 | 126 |
| 127 const size_t AutomaticProfileResetter::kSatisfiedCriteriaMaskBits = 2; |
| 128 const uint32 AutomaticProfileResetter::kSatisfiedCriteriaMaskMaximumValue = |
| 129 (1 << AutomaticProfileResetter::kSatisfiedCriteriaMaskBits); |
| 130 |
| 131 const size_t AutomaticProfileResetter::kCombinedStatusMaskBits = 4; |
| 132 const uint32 AutomaticProfileResetter::kCombinedStatusMaskMaximumValue = |
| 133 (1 << AutomaticProfileResetter::kCombinedStatusMaskBits); |
| 134 |
| 135 COMPILE_ASSERT(arraysize(kSatisfiedCriteriaMaskKeys) == |
| 136 ::AutomaticProfileResetter::kSatisfiedCriteriaMaskBits, |
| 137 satisfied_criteria_mask_bits_mismatch); |
| 138 COMPILE_ASSERT(arraysize(kCombinedStatusMaskKeys) == |
| 139 ::AutomaticProfileResetter::kCombinedStatusMaskBits, |
| 140 combined_status_mask_bits_mismatch); |
| 141 |
| 125 AutomaticProfileResetter::AutomaticProfileResetter(Profile* profile) | 142 AutomaticProfileResetter::AutomaticProfileResetter(Profile* profile) |
| 126 : profile_(profile), | 143 : profile_(profile), |
| 127 state_(STATE_UNINITIALIZED), | 144 state_(STATE_UNINITIALIZED), |
| 128 memento_in_prefs_(profile_), | 145 memento_in_prefs_(profile_), |
| 129 memento_in_local_state_(profile_), | 146 memento_in_local_state_(profile_), |
| 130 memento_in_file_(profile_), | 147 memento_in_file_(profile_), |
| 131 weak_ptr_factory_(this) { | 148 weak_ptr_factory_(this) { |
| 132 DCHECK(profile_); | 149 DCHECK(profile_); |
| 150 Initialize(); |
| 133 } | 151 } |
| 134 | 152 |
| 135 AutomaticProfileResetter::~AutomaticProfileResetter() {} | 153 AutomaticProfileResetter::~AutomaticProfileResetter() {} |
| 136 | 154 |
| 137 void AutomaticProfileResetter::Initialize() { | 155 void AutomaticProfileResetter::Initialize() { |
| 138 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 156 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 139 DCHECK_EQ(state_, STATE_UNINITIALIZED); | 157 DCHECK_EQ(state_, STATE_UNINITIALIZED); |
| 140 | 158 |
| 141 if (ShouldPerformDryRun() || ShouldPerformLiveRun()) { | 159 if (ShouldPerformDryRun() || ShouldPerformLiveRun()) { |
| 142 ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance()); | 160 ui::ResourceBundle& resources(ui::ResourceBundle::GetSharedInstance()); |
| 143 if (ShouldPerformLiveRun()) { | 161 if (ShouldPerformLiveRun()) { |
| 144 program_ = | 162 program_ = |
| 145 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_RULES); | 163 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_RULES); |
| 146 hash_seed_ = | 164 hash_seed_ = |
| 147 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED); | 165 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED); |
| 148 } else { // ShouldPerformDryRun() | 166 } else { // ShouldPerformDryRun() |
| 149 program_ = | 167 program_ = |
| 150 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY); | 168 resources.GetRawDataResource(IDR_AUTOMATIC_PROFILE_RESET_RULES_DRY); |
| 151 hash_seed_ = resources.GetRawDataResource( | 169 hash_seed_ = resources.GetRawDataResource( |
| 152 IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY); | 170 IDR_AUTOMATIC_PROFILE_RESET_HASH_SEED_DRY); |
| 153 } | 171 } |
| 154 delegate_.reset(new AutomaticProfileResetterDelegateImpl()); | 172 delegate_.reset(new AutomaticProfileResetterDelegateImpl(profile_)); |
| 155 | 173 state_ = STATE_INITIALIZED; |
| 156 state_ = STATE_READY; | |
| 157 | |
| 158 content::BrowserThread::PostTask( | |
| 159 content::BrowserThread::UI, | |
| 160 FROM_HERE, | |
| 161 base::Bind(&AutomaticProfileResetter::BeginEvaluationFlow, | |
| 162 weak_ptr_factory_.GetWeakPtr())); | |
| 163 } else { | 174 } else { |
| 164 state_ = STATE_DISABLED; | 175 state_ = STATE_DISABLED; |
| 165 } | 176 } |
| 166 } | 177 } |
| 167 | 178 |
| 179 void AutomaticProfileResetter::Activate() { |
| 180 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 181 DCHECK(state_ == STATE_INITIALIZED || state_ == STATE_DISABLED); |
| 182 |
| 183 if (state_ == STATE_INITIALIZED) { |
| 184 if (!program_.empty()) { |
| 185 state_ = STATE_WAITING_ON_SERVICES; |
| 186 delegate_->WaitOnTemplateURLService( |
| 187 base::Bind(&AutomaticProfileResetter::OnTemplateURLServiceBecameReady, |
| 188 weak_ptr_factory_.GetWeakPtr())); |
| 189 delegate_->LoadTemplateURLServiceIfNeeded(); |
| 190 } else { |
| 191 // Terminate early if there is no program included (nor set by tests). |
| 192 state_ = STATE_DISABLED; |
| 193 } |
| 194 } |
| 195 } |
| 196 |
| 168 bool AutomaticProfileResetter::ShouldPerformDryRun() const { | 197 bool AutomaticProfileResetter::ShouldPerformDryRun() const { |
| 169 return base::FieldTrialList::FindFullName(kAutomaticProfileResetStudyName) == | 198 return base::FieldTrialList::FindFullName(kAutomaticProfileResetStudyName) == |
| 170 kAutomaticProfileResetStudyDryRunGroupName; | 199 kAutomaticProfileResetStudyDryRunGroupName; |
| 171 } | 200 } |
| 172 | 201 |
| 173 bool AutomaticProfileResetter::ShouldPerformLiveRun() const { | 202 bool AutomaticProfileResetter::ShouldPerformLiveRun() const { |
| 174 return base::FieldTrialList::FindFullName(kAutomaticProfileResetStudyName) == | 203 return base::FieldTrialList::FindFullName(kAutomaticProfileResetStudyName) == |
| 175 kAutomaticProfileResetStudyEnabledGroupName; | 204 kAutomaticProfileResetStudyEnabledGroupName; |
| 176 } | 205 } |
| 177 | 206 |
| 207 void AutomaticProfileResetter::OnTemplateURLServiceBecameReady() { |
| 208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 209 DCHECK_EQ(state_, STATE_WAITING_ON_SERVICES); |
| 210 |
| 211 state_ = STATE_READY; |
| 212 content::BrowserThread::PostTask( |
| 213 content::BrowserThread::UI, |
| 214 FROM_HERE, |
| 215 base::Bind(&AutomaticProfileResetter::BeginEvaluationFlow, |
| 216 weak_ptr_factory_.GetWeakPtr())); |
| 217 } |
| 218 |
| 178 void AutomaticProfileResetter::BeginEvaluationFlow() { | 219 void AutomaticProfileResetter::BeginEvaluationFlow() { |
| 179 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 220 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 180 DCHECK_EQ(state_, STATE_READY); | 221 DCHECK_EQ(state_, STATE_READY); |
| 222 DCHECK(!program_.empty()); |
| 181 | 223 |
| 182 if (!program_.empty()) { | 224 state_ = STATE_WORKING; |
| 183 state_ = STATE_WORKING; | 225 memento_in_file_.ReadValue( |
| 184 memento_in_file_.ReadValue( | 226 base::Bind(&AutomaticProfileResetter::ContinueWithEvaluationFlow, |
| 185 base::Bind(&AutomaticProfileResetter::ContinueWithEvaluationFlow, | 227 weak_ptr_factory_.GetWeakPtr())); |
| 186 weak_ptr_factory_.GetWeakPtr())); | |
| 187 } else { | |
| 188 // Terminate early if there is no program included (nor set by tests). | |
| 189 state_ = STATE_DISABLED; | |
| 190 } | |
| 191 } | 228 } |
| 192 | 229 |
| 193 scoped_ptr<base::DictionaryValue> | 230 scoped_ptr<base::DictionaryValue> |
| 194 AutomaticProfileResetter::BuildEvaluatorProgramInput( | 231 AutomaticProfileResetter::BuildEvaluatorProgramInput( |
| 195 const std::string& memento_value_in_file) { | 232 const std::string& memento_value_in_file) { |
| 196 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 233 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 197 // TODO(engedy): Add any additional state here that is needed by the program. | 234 |
| 198 scoped_ptr<base::DictionaryValue> input(new base::DictionaryValue); | 235 scoped_ptr<base::DictionaryValue> input(new base::DictionaryValue); |
| 236 |
| 237 // Include memento values (or empty strings in case mementos are not there). |
| 199 input->SetString(kMementoValueInPrefsKey, memento_in_prefs_.ReadValue()); | 238 input->SetString(kMementoValueInPrefsKey, memento_in_prefs_.ReadValue()); |
| 200 input->SetString(kMementoValueInLocalStateKey, | 239 input->SetString(kMementoValueInLocalStateKey, |
| 201 memento_in_local_state_.ReadValue()); | 240 memento_in_local_state_.ReadValue()); |
| 202 input->SetString(kMementoValueInFileKey, memento_value_in_file); | 241 input->SetString(kMementoValueInFileKey, memento_value_in_file); |
| 242 |
| 243 // Include all user (i.e. profile-specific) preferences, along with |
| 244 // information about whether the value is coming from the 'user' PrefStore. |
| 245 PrefService* prefs = profile_->GetPrefs(); |
| 246 DCHECK(prefs); |
| 247 BuildSubTreesFromPreferences(prefs, |
| 248 input.get(), |
| 249 kUserPreferencesKey, |
| 250 kUserPreferencesIsUserControlledKey); |
| 251 |
| 252 // Include all local state (i.e. shared) preferences, along with information |
| 253 // about whether the value is coming from the 'user' PrefStore. |
| 254 PrefService* local_state = g_browser_process->local_state(); |
| 255 DCHECK(local_state); |
| 256 BuildSubTreesFromPreferences( |
| 257 local_state, input.get(), kLocalStateKey, kLocalStateIsUserControlledKey); |
| 258 |
| 259 // Include all information related to search engines. |
| 260 base::DictionaryValue* default_search_provider_details = |
| 261 delegate_->GetDefaultSearchProviderDetails(); |
| 262 if (default_search_provider_details) |
| 263 input->Set(kDefaultSearchProviderKey, default_search_provider_details); |
| 264 |
| 265 base::ListValue* search_providers_details = |
| 266 delegate_->GetPrepopulatedSearchProvidersDetails(); |
| 267 if (search_providers_details) |
| 268 input->Set(kSearchProvidersKey, search_providers_details); |
| 269 |
| 270 input->SetBoolean(kDefaultSearchProviderIsUserControlledKey, |
| 271 !delegate_->IsDefaultSearchProviderManaged()); |
| 272 |
| 203 return input.Pass(); | 273 return input.Pass(); |
| 204 } | 274 } |
| 205 | 275 |
| 206 void AutomaticProfileResetter::ContinueWithEvaluationFlow( | 276 void AutomaticProfileResetter::ContinueWithEvaluationFlow( |
| 207 const std::string& memento_value_in_file) { | 277 const std::string& memento_value_in_file) { |
| 208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 278 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 209 DCHECK_EQ(state_, STATE_WORKING); | 279 DCHECK_EQ(state_, STATE_WORKING); |
| 210 PrefService* prefs = profile_->GetPrefs(); | 280 PrefService* prefs = profile_->GetPrefs(); |
| 211 DCHECK(prefs); | 281 DCHECK(prefs); |
| 212 | 282 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 delegate_.reset(delegate); | 379 delegate_.reset(delegate); |
| 310 } | 380 } |
| 311 | 381 |
| 312 void AutomaticProfileResetter::Shutdown() { | 382 void AutomaticProfileResetter::Shutdown() { |
| 313 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 383 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 314 | 384 |
| 315 state_ = STATE_DISABLED; | 385 state_ = STATE_DISABLED; |
| 316 delegate_.reset(); | 386 delegate_.reset(); |
| 317 weak_ptr_factory_.InvalidateWeakPtrs(); | 387 weak_ptr_factory_.InvalidateWeakPtrs(); |
| 318 } | 388 } |
| OLD | NEW |