| Index: chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
|
| diff --git a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
|
| index dc8a613040fbb9e384966319cb8bf72d71b07790..f2ab410f74c1ceb6936fb1432773bdce1c9064e9 100644
|
| --- a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
|
| +++ b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
|
| @@ -8,11 +8,18 @@
|
| #include "base/basictypes.h"
|
| #include "base/callback_forward.h"
|
| #include "base/memory/scoped_ptr.h"
|
| +#include "base/memory/weak_ptr.h"
|
| #include "chrome/browser/search_engines/template_url_service_observer.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
| #include "extensions/common/one_shot_event.h"
|
|
|
| +class BrandcodeConfigFetcher;
|
| +class BrandcodedDefaultSettings;
|
| +class GlobalErrorService;
|
| +class Profile;
|
| +class ProfileResetter;
|
| +class ResettableSettingsSnapshot;
|
| class TemplateURLService;
|
|
|
| namespace base {
|
| @@ -44,6 +51,15 @@ class AutomaticProfileResetterDelegate {
|
| virtual void RequestCallbackWhenTemplateURLServiceIsLoaded(
|
| const base::Closure& ready_callback) const = 0;
|
|
|
| + // Requests that the configuration file containing the default settings for
|
| + // the current brandcode be downloaded if it has not been already.
|
| + virtual void FetchBrandcodedDefaultSettingsIfNeeded() = 0;
|
| +
|
| + // Requests |ready_callback| to be posted on the UI thread once the brandcoded
|
| + // default settings have been downloaded.
|
| + virtual void RequestCallbackWhenBrandcodedDefaultsAreFetched(
|
| + const base::Closure& ready_callback) const = 0;
|
| +
|
| // Returns a list of loaded module name digests.
|
| virtual scoped_ptr<base::ListValue> GetLoadedModuleNameDigests() const = 0;
|
|
|
| @@ -71,24 +87,40 @@ class AutomaticProfileResetterDelegate {
|
|
|
| // Triggers showing the one-time profile settings reset prompt.
|
| virtual void ShowPrompt() = 0;
|
| +
|
| + // Triggers the ProfileResetter to reset all supported settings and optionally
|
| + // |send_feedback|. Will post |completion| on the UI thread once completed.
|
| + // Brandcoded default settings will be fetched if they are not yet available,
|
| + // then the reset will be performed once the download is complete.
|
| + // NOTE: Can only be called at most once during the lifetime of the object.
|
| + virtual void TriggerProfileSettingsReset(bool send_feedback,
|
| + const base::Closure& completion) = 0;
|
| +
|
| + // Dismisses the one-time profile settings reset prompt.
|
| + virtual void DismissPrompt() = 0;
|
| };
|
|
|
| // Implementation for AutomaticProfileResetterDelegate.
|
| -// To facilitate unit testing, having the TemplateURLService available is only
|
| -// required when using search engine related methods.
|
| +// To facilitate unit testing, having a GlobalErrorService or TemplateURLService
|
| +// available for the Profile is only required when using specific methods, see
|
| +// constructor for details.
|
| class AutomaticProfileResetterDelegateImpl
|
| : public AutomaticProfileResetterDelegate,
|
| + public base::SupportsWeakPtr<AutomaticProfileResetterDelegateImpl>,
|
| public TemplateURLServiceObserver,
|
| public content::NotificationObserver {
|
| public:
|
| - // The |template_url_service| may be NULL in unit tests. Must be non-NULL for
|
| - // callers who wish to call:
|
| + // The GlobalErrorService and TemplateURLService for |profile| may be NULL in
|
| + // unit tests.
|
| + // TemplateURLService must be non-NULL for callers who wish to call:
|
| // * LoadTemplateURLServiceIfNeeded(),
|
| // * GetDefaultSearchProviderDetails(),
|
| // * GetPrepopulatedSearchProvidersDetails(), or
|
| // * IsDefaultSearchManaged().
|
| - explicit AutomaticProfileResetterDelegateImpl(
|
| - TemplateURLService* template_url_service);
|
| + // GlobalErrorService must be non-NULL for callers who wish to call:
|
| + // * ShowPrompt(), or
|
| + // * DismissPrompt().
|
| + explicit AutomaticProfileResetterDelegateImpl(Profile* profile);
|
| virtual ~AutomaticProfileResetterDelegateImpl();
|
|
|
| // AutomaticProfileResetterDelegate:
|
| @@ -98,6 +130,9 @@ class AutomaticProfileResetterDelegateImpl
|
| virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE;
|
| virtual void RequestCallbackWhenTemplateURLServiceIsLoaded(
|
| const base::Closure& ready_callback) const OVERRIDE;
|
| + virtual void FetchBrandcodedDefaultSettingsIfNeeded() OVERRIDE;
|
| + virtual void RequestCallbackWhenBrandcodedDefaultsAreFetched(
|
| + const base::Closure& ready_callback) const OVERRIDE;
|
| virtual scoped_ptr<base::ListValue>
|
| GetLoadedModuleNameDigests() const OVERRIDE;
|
| virtual scoped_ptr<base::DictionaryValue>
|
| @@ -106,6 +141,10 @@ class AutomaticProfileResetterDelegateImpl
|
| virtual scoped_ptr<base::ListValue>
|
| GetPrepopulatedSearchProvidersDetails() const OVERRIDE;
|
| virtual void ShowPrompt() OVERRIDE;
|
| + virtual void TriggerProfileSettingsReset(
|
| + bool send_feedback,
|
| + const base::Closure& completion) OVERRIDE;
|
| + virtual void DismissPrompt() OVERRIDE;
|
|
|
| // TemplateURLServiceObserver:
|
| virtual void OnTemplateURLServiceChanged() OVERRIDE;
|
| @@ -116,8 +155,33 @@ class AutomaticProfileResetterDelegateImpl
|
| const content::NotificationDetails& details) OVERRIDE;
|
|
|
| private:
|
| + // Triggers the ProfileResetter to reset all supported settings and optionally
|
| + // |send_feedback|. Will invoke |completion| on the UI thread once completed
|
| + // |brandcoded_defaults_| must be already fetched when this is called.
|
| + void RunProfileSettingsReset(bool send_feedback,
|
| + const base::Closure& completion);
|
| +
|
| + // Called by |brandcoded_config_fetcher_| when it finishes downloading the
|
| + // brandcoded default settings (or the download times out).
|
| + void OnBrandcodedDefaultsFetched();
|
| +
|
| + // Called back by the ProfileResetter once resetting the profile settings has
|
| + // been completed. If |old_settings_snapshot| is non-NULL, will compare it to
|
| + // the new settings and send the differences to Google for analysis. Finally,
|
| + // will post |user_callback|.
|
| + void OnProfileSettingsResetCompleted(
|
| + const base::Closure& user_callback,
|
| + scoped_ptr<ResettableSettingsSnapshot> old_settings_snapshot);
|
| +
|
| + Profile* profile_;
|
| + GlobalErrorService* global_error_service_;
|
| TemplateURLService* template_url_service_;
|
|
|
| + scoped_ptr<BrandcodeConfigFetcher> brandcoded_config_fetcher_;
|
| + scoped_ptr<BrandcodedDefaultSettings> brandcoded_defaults_;
|
| +
|
| + scoped_ptr<ProfileResetter> profile_resetter_;
|
| +
|
| content::NotificationRegistrar registrar_;
|
|
|
| // The list of modules found. Even when |modules_have_been_enumerated_event_|
|
| @@ -137,6 +201,10 @@ class AutomaticProfileResetterDelegateImpl
|
| // the event will be signaled during construction.
|
| extensions::OneShotEvent template_url_service_ready_event_;
|
|
|
| + // This event is signaled once brandcoded default settings have been
|
| + // downloaded, or it has been established that this is not a branded build.
|
| + extensions::OneShotEvent brandcoded_defaults_fetched_event_;
|
| +
|
| DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl);
|
| };
|
|
|
|
|