Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(56)

Unified Diff: chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h

Issue 62193002: Integrate UI and reset logic into AutomaticProfileResetter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Win compile error introduce by rebase. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..732137017792133c3435e04337a6f7761a97c3f4 100644
--- a/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h
@@ -8,11 +8,17 @@
#include "base/basictypes.h"
#include "base/callback_forward.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "chrome/browser/profile_resetter/profile_resetter.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 GlobalErrorService;
+class Profile;
+class ResettableSettingsSnapshot;
class TemplateURLService;
namespace base {
@@ -44,6 +50,17 @@ class AutomaticProfileResetterDelegate {
virtual void RequestCallbackWhenTemplateURLServiceIsLoaded(
const base::Closure& ready_callback) const = 0;
+ // Starts downloading the configuration file that specifies the default
+ // settings for the current brandcode; or establishes that we are running a
+ // vanilla (non-branded) build.
+ virtual void FetchBrandcodedDefaultSettingsIfNeeded() = 0;
+
+ // Requests |ready_callback| to be posted on the UI thread once the brandcoded
+ // default settings have been downloaded, or once it has been established that
+ // we are running a vanilla (non-branded) build.
+ 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;
@@ -69,28 +86,47 @@ class AutomaticProfileResetterDelegate {
virtual scoped_ptr<base::ListValue>
GetPrepopulatedSearchProvidersDetails() const = 0;
- // Triggers showing the one-time profile settings reset prompt.
- virtual void ShowPrompt() = 0;
+ // Triggers showing the one-time profile settings reset prompt, which consists
+ // of two parts: (1.) the profile reset (pop-up) bubble, and (2.) a menu item
+ // in the wrench menu. Showing the bubble might be delayed if there is another
+ // bubble currently shown, in which case the bubble will be shown the first
+ // time a new browser window is opened.
+ // Returns true unless the reset prompt is not supported on the current
+ // platform, in which case it returns false and does nothing.
+ virtual bool TriggerPrompt() = 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,
+ // the reset will be performed once the download is complete.
+ // NOTE: Should 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, if it is currently
+ // triggered. Will synchronously destroy the corresponding GlobalError.
+ virtual void DismissPrompt() = 0;
};
// Implementation for AutomaticProfileResetterDelegate.
-// To facilitate unit testing, having the TemplateURLService available is only
-// required when using search engine related methods.
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:
- // * LoadTemplateURLServiceIfNeeded(),
- // * GetDefaultSearchProviderDetails(),
- // * GetPrepopulatedSearchProvidersDetails(), or
- // * IsDefaultSearchManaged().
explicit AutomaticProfileResetterDelegateImpl(
- TemplateURLService* template_url_service);
+ Profile* profile,
+ ProfileResetter::ResettableFlags resettable_aspects);
virtual ~AutomaticProfileResetterDelegateImpl();
+ // Returns the brandcoded default settings; empty defaults if this is not a
+ // branded build; or NULL if FetchBrandcodedDefaultSettingsIfNeeded() has not
+ // yet been called or not yet finished. Exposed only for unit tests.
+ const BrandcodedDefaultSettings* brandcoded_defaults() const {
+ return brandcoded_defaults_.get();
+ }
+
// AutomaticProfileResetterDelegate:
virtual void EnumerateLoadedModulesIfNeeded() OVERRIDE;
virtual void RequestCallbackWhenLoadedModulesAreEnumerated(
@@ -98,6 +134,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>
@@ -105,7 +144,11 @@ class AutomaticProfileResetterDelegateImpl
virtual bool IsDefaultSearchProviderManaged() const OVERRIDE;
virtual scoped_ptr<base::ListValue>
GetPrepopulatedSearchProvidersDetails() const OVERRIDE;
- virtual void ShowPrompt() OVERRIDE;
+ virtual bool TriggerPrompt() OVERRIDE;
+ virtual void TriggerProfileSettingsReset(
+ bool send_feedback,
+ const base::Closure& completion) OVERRIDE;
+ virtual void DismissPrompt() OVERRIDE;
// TemplateURLServiceObserver:
virtual void OnTemplateURLServiceChanged() OVERRIDE;
@@ -116,15 +159,45 @@ class AutomaticProfileResetterDelegateImpl
const content::NotificationDetails& details) OVERRIDE;
private:
+ // Sends a feedback |report|, where |report| is supposed to be result of
+ // ::SerializeSettingsReport(). Virtual, so it can be mocked out for tests.
+ virtual void SendFeedback(const std::string& report) const;
+
+ // Triggers the ProfileResetter to reset |resettable_aspects_| and optionally
+ // |send_feedback|. Will invoke |completion| on the UI thread once completed
+ // The |brandcoded_defaults_| must already be initialized 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_;
+
+ const ProfileResetter::ResettableFlags resettable_aspects_;
+ scoped_ptr<ProfileResetter> profile_resetter_;
+
content::NotificationRegistrar registrar_;
// The list of modules found. Even when |modules_have_been_enumerated_event_|
// is signaled, this may still be NULL.
scoped_ptr<base::ListValue> module_list_;
- // This event is signaled once module enumeration has been attempted. If
+ // This event is signaled once module enumeration has been attempted. If
// during construction, EnumerateModulesModel can supply a non-empty list of
// modules, module enumeration has clearly already happened, so the event will
// be signaled immediately; otherwise, when EnumerateLoadedModulesIfNeeded()
@@ -137,6 +210,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 fetched,
+ // or once it has been established that this is not a branded build.
+ extensions::OneShotEvent brandcoded_defaults_fetched_event_;
+
DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl);
};

Powered by Google App Engine
This is Rietveld 408576698