| 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 // Declares a delegate that interacts with the rest of the browser on behalf of | 5 // Declares a delegate that interacts with the rest of the browser on behalf of |
| 6 // the AutomaticProfileResetter. | 6 // the AutomaticProfileResetter. |
| 7 // | 7 // |
| 8 // The reason for this separation is to facilitate unit testing. Factoring out | 8 // The reason for this separation is to facilitate unit testing. Factoring out |
| 9 // the implementation for each interaction step (encapsulated by one method of | 9 // the implementation for each interaction step (encapsulated by one method of |
| 10 // the delegate) allows it to be tested independently in itself. It also becomes | 10 // the delegate) allows it to be tested independently in itself. It also becomes |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 // Implementation for AutomaticProfileResetterDelegate. | 117 // Implementation for AutomaticProfileResetterDelegate. |
| 118 class AutomaticProfileResetterDelegateImpl | 118 class AutomaticProfileResetterDelegateImpl |
| 119 : public AutomaticProfileResetterDelegate, | 119 : public AutomaticProfileResetterDelegate, |
| 120 public base::SupportsWeakPtr<AutomaticProfileResetterDelegateImpl>, | 120 public base::SupportsWeakPtr<AutomaticProfileResetterDelegateImpl>, |
| 121 public TemplateURLServiceObserver, | 121 public TemplateURLServiceObserver, |
| 122 public content::NotificationObserver { | 122 public content::NotificationObserver { |
| 123 public: | 123 public: |
| 124 explicit AutomaticProfileResetterDelegateImpl( | 124 explicit AutomaticProfileResetterDelegateImpl( |
| 125 Profile* profile, | 125 Profile* profile, |
| 126 ProfileResetter::ResettableFlags resettable_aspects); | 126 ProfileResetter::ResettableFlags resettable_aspects); |
| 127 virtual ~AutomaticProfileResetterDelegateImpl(); | 127 ~AutomaticProfileResetterDelegateImpl() override; |
| 128 | 128 |
| 129 // Returns the brandcoded default settings; empty defaults if this is not a | 129 // Returns the brandcoded default settings; empty defaults if this is not a |
| 130 // branded build; or NULL if FetchBrandcodedDefaultSettingsIfNeeded() has not | 130 // branded build; or NULL if FetchBrandcodedDefaultSettingsIfNeeded() has not |
| 131 // yet been called or not yet finished. Exposed only for unit tests. | 131 // yet been called or not yet finished. Exposed only for unit tests. |
| 132 const BrandcodedDefaultSettings* brandcoded_defaults() const { | 132 const BrandcodedDefaultSettings* brandcoded_defaults() const { |
| 133 return brandcoded_defaults_.get(); | 133 return brandcoded_defaults_.get(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 // AutomaticProfileResetterDelegate: | 136 // AutomaticProfileResetterDelegate: |
| 137 virtual void EnumerateLoadedModulesIfNeeded() override; | 137 void EnumerateLoadedModulesIfNeeded() override; |
| 138 virtual void RequestCallbackWhenLoadedModulesAreEnumerated( | 138 void RequestCallbackWhenLoadedModulesAreEnumerated( |
| 139 const base::Closure& ready_callback) const override; | 139 const base::Closure& ready_callback) const override; |
| 140 virtual void LoadTemplateURLServiceIfNeeded() override; | 140 void LoadTemplateURLServiceIfNeeded() override; |
| 141 virtual void RequestCallbackWhenTemplateURLServiceIsLoaded( | 141 void RequestCallbackWhenTemplateURLServiceIsLoaded( |
| 142 const base::Closure& ready_callback) const override; | 142 const base::Closure& ready_callback) const override; |
| 143 virtual void FetchBrandcodedDefaultSettingsIfNeeded() override; | 143 void FetchBrandcodedDefaultSettingsIfNeeded() override; |
| 144 virtual void RequestCallbackWhenBrandcodedDefaultsAreFetched( | 144 void RequestCallbackWhenBrandcodedDefaultsAreFetched( |
| 145 const base::Closure& ready_callback) const override; | 145 const base::Closure& ready_callback) const override; |
| 146 virtual scoped_ptr<base::ListValue> | 146 scoped_ptr<base::ListValue> GetLoadedModuleNameDigests() const override; |
| 147 GetLoadedModuleNameDigests() const override; | 147 scoped_ptr<base::DictionaryValue> GetDefaultSearchProviderDetails() |
| 148 virtual scoped_ptr<base::DictionaryValue> | 148 const override; |
| 149 GetDefaultSearchProviderDetails() const override; | 149 bool IsDefaultSearchProviderManaged() const override; |
| 150 virtual bool IsDefaultSearchProviderManaged() const override; | 150 scoped_ptr<base::ListValue> GetPrepopulatedSearchProvidersDetails() |
| 151 virtual scoped_ptr<base::ListValue> | 151 const override; |
| 152 GetPrepopulatedSearchProvidersDetails() const override; | 152 bool TriggerPrompt() override; |
| 153 virtual bool TriggerPrompt() override; | 153 void TriggerProfileSettingsReset(bool send_feedback, |
| 154 virtual void TriggerProfileSettingsReset( | 154 const base::Closure& completion) override; |
| 155 bool send_feedback, | 155 void DismissPrompt() override; |
| 156 const base::Closure& completion) override; | |
| 157 virtual void DismissPrompt() override; | |
| 158 | 156 |
| 159 // TemplateURLServiceObserver: | 157 // TemplateURLServiceObserver: |
| 160 virtual void OnTemplateURLServiceChanged() override; | 158 void OnTemplateURLServiceChanged() override; |
| 161 | 159 |
| 162 // content::NotificationObserver: | 160 // content::NotificationObserver: |
| 163 virtual void Observe(int type, | 161 void Observe(int type, |
| 164 const content::NotificationSource& source, | 162 const content::NotificationSource& source, |
| 165 const content::NotificationDetails& details) override; | 163 const content::NotificationDetails& details) override; |
| 166 | 164 |
| 167 private: | 165 private: |
| 168 // Sends a feedback |report|, where |report| is supposed to be result of | 166 // Sends a feedback |report|, where |report| is supposed to be result of |
| 169 // ::SerializeSettingsReport(). Virtual, so it can be mocked out for tests. | 167 // ::SerializeSettingsReport(). Virtual, so it can be mocked out for tests. |
| 170 virtual void SendFeedback(const std::string& report) const; | 168 virtual void SendFeedback(const std::string& report) const; |
| 171 | 169 |
| 172 // Triggers the ProfileResetter to reset |resettable_aspects_| and optionally | 170 // Triggers the ProfileResetter to reset |resettable_aspects_| and optionally |
| 173 // |send_feedback|. Will invoke |completion| on the UI thread once completed | 171 // |send_feedback|. Will invoke |completion| on the UI thread once completed |
| 174 // The |brandcoded_defaults_| must already be initialized when this is called. | 172 // The |brandcoded_defaults_| must already be initialized when this is called. |
| 175 void RunProfileSettingsReset(bool send_feedback, | 173 void RunProfileSettingsReset(bool send_feedback, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 extensions::OneShotEvent template_url_service_ready_event_; | 228 extensions::OneShotEvent template_url_service_ready_event_; |
| 231 | 229 |
| 232 // This event is signaled once brandcoded default settings have been fetched, | 230 // This event is signaled once brandcoded default settings have been fetched, |
| 233 // or once it has been established that this is not a branded build. | 231 // or once it has been established that this is not a branded build. |
| 234 extensions::OneShotEvent brandcoded_defaults_fetched_event_; | 232 extensions::OneShotEvent brandcoded_defaults_fetched_event_; |
| 235 | 233 |
| 236 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); | 234 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); |
| 237 }; | 235 }; |
| 238 | 236 |
| 239 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H
_ | 237 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H
_ |
| OLD | NEW |