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 |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3bd263b1b052c30cb1b92192b9d9c12b98896182 |
--- /dev/null |
+++ b/chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h |
@@ -0,0 +1,128 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H_ |
+#define CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H_ |
+ |
+#include "base/basictypes.h" |
+#include "base/callback_forward.h" |
+#include "base/values.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 Profile; |
+ |
+// Defines the interface for the delegate that will interact with the rest of |
+// the browser on behalf of the AutomaticProfileResetter. |
+// The primary reason for this separation is to facilitate unit testing. |
+class AutomaticProfileResetterDelegate { |
+ public: |
+ virtual ~AutomaticProfileResetterDelegate() {} |
+ |
+ // Requests the module enumerator to start scanning for loaded modules now, if |
+ // it has not done so already. |
+ virtual void EnumerateLoadedModulesIfNeeded() = 0; |
+ |
+ // Requests |ready_callback| to be posted on the UI thread once the module |
+ // enumerator has finished scanning for loaded modules. |
+ virtual void RequestCallbackWhenLoadedModulesAreEnumerated( |
+ const base::Closure& ready_callback) const = 0; |
+ |
+ // Requests the template URL service to load its database (asynchronously). |
+ virtual void LoadTemplateURLServiceIfNeeded() = 0; |
+ |
+ // Requests |ready_callback| to be posted on the UI thread once the template |
+ // URL service has finished loading its database. |
+ virtual void RequestCallbackWhenTemplateURLServiceIsLoaded( |
+ const base::Closure& ready_callback) const = 0; |
+ |
+ // Returns a list of loaded module name digests. |
+ virtual base::ListValue* GetLoadedModuleNameDigests() const = 0; |
Peter Kasting
2013/10/15 01:31:28
Try to return scoped_ptr<>s instead of raw pointer
engedy
2013/10/15 22:13:07
Done. Also replaced all such usages of raw pointer
|
+ |
+ // Returns attributes of the search engine currently set as the default, or |
+ // NULL if none. The returned dictionary will contain the following keys: |
Peter Kasting
2013/10/15 01:31:28
Avoid a big list like this. It's liable to get ou
engedy
2013/10/15 22:13:07
Done.
|
+ // "search_url", "search_terms_replacement_key", |
+ // "suggest_url", "instant_url", |
+ // "image_url", "new_tab_url", |
+ // "icon_url", "search_url_post_params", |
+ // "suggest_url_post_params", "instant_url_post_params", |
+ // "image_url_post_params", "name", |
+ // "keyword", "encodings", |
+ // "prepopulate_id", "alternate_urls". |
+ // These attributes are a subset of, and used in the same sense as the user |
+ // preferences stored by TemplateURLService::SaveDefaultSearchProviderToPrefs. |
+ // Each key corresponds to the preference with the same name once you add the |
+ // "default_search_provider" prefix. Returned value is owned by the caller. |
+ virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const = 0; |
+ |
+ // Returns whether or not the default search provider is set by policy. |
+ virtual bool IsDefaultSearchProviderManaged() const = 0; |
+ |
+ // Returns a list of dictionaries, each containing attributes for each of the |
+ // pre-populated search engines, in the format described above. The returned |
+ // value is owned by the caller. |
+ virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const = 0; |
+ |
+ // Triggers showing the one-time profile settings reset prompt. |
+ virtual void ShowPrompt() = 0; |
+}; |
+ |
+// Implementation for AutomaticProfileResetterDelegate. |
+class AutomaticProfileResetterDelegateImpl |
+ : public AutomaticProfileResetterDelegate, |
+ public TemplateURLServiceObserver, |
+ public content::NotificationObserver { |
+ public: |
+ explicit AutomaticProfileResetterDelegateImpl(Profile* profile); |
+ virtual ~AutomaticProfileResetterDelegateImpl(); |
+ |
+ // AutomaticProfileResetterDelegate overrides: |
Peter Kasting
2013/10/15 01:31:28
Nit: Omit "overrides" (2 places)
engedy
2013/10/15 22:13:07
Done. Removed everywhere in automatic_profile_rese
|
+ virtual void EnumerateLoadedModulesIfNeeded() OVERRIDE; |
+ virtual void RequestCallbackWhenLoadedModulesAreEnumerated( |
+ const base::Closure& ready_callback) const OVERRIDE; |
+ |
Peter Kasting
2013/10/15 01:31:28
Nit: Blank lines inside the group of overrides for
engedy
2013/10/15 22:13:07
Done. Removed everywhere in automatic_profile_rese
|
+ virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE; |
+ virtual void RequestCallbackWhenTemplateURLServiceIsLoaded( |
+ const base::Closure& ready_callback) const OVERRIDE; |
+ |
+ virtual base::ListValue* GetLoadedModuleNameDigests() const OVERRIDE; |
+ |
+ virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const |
+ OVERRIDE; |
Peter Kasting
2013/10/15 01:31:28
Nit: Try to avoid breaking before OVERRIDE; instea
engedy
2013/10/15 22:13:07
Done.
|
+ virtual bool IsDefaultSearchProviderManaged() const OVERRIDE; |
+ virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const |
+ OVERRIDE; |
+ |
+ virtual void ShowPrompt() OVERRIDE; |
+ |
+ // TemplateURLServiceObserver overrides: |
+ virtual void OnTemplateURLServiceChanged() OVERRIDE; |
+ |
+ // content::NotificationObserver: |
+ virtual void Observe(int type, |
+ const content::NotificationSource& source, |
+ const content::NotificationDetails& details) OVERRIDE; |
+ |
+ private: |
+ Profile* profile_; |
+ |
+ 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 we have proof that the modules have been |
+ // (attempted to be) enumerated at least once. |
+ extensions::OneShotEvent modules_have_been_enumerated_event_; |
+ |
+ // This event is signaled once TemplateURLService::loaded() returns true. |
Peter Kasting
2013/10/15 01:31:28
Nit: How about:
This event is signaled once the T
engedy
2013/10/15 22:13:07
Done.
|
+ extensions::OneShotEvent template_url_service_ready_event_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); |
+}; |
+ |
+#endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H_ |