OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H_ |
| 7 |
| 8 #include "base/basictypes.h" |
| 9 #include "base/callback_forward.h" |
| 10 #include "base/values.h" |
| 11 #include "chrome/browser/search_engines/template_url_service_observer.h" |
| 12 #include "extensions/common/one_shot_event.h" |
| 13 |
| 14 class Profile; |
| 15 |
| 16 // Defines the interface for the delegate that will interact with the rest of |
| 17 // the browser on behalf of the AutomaticProfileResetter. |
| 18 // The primary reason for this separation is to facilitate unit testing. |
| 19 class AutomaticProfileResetterDelegate { |
| 20 public: |
| 21 virtual ~AutomaticProfileResetterDelegate() {} |
| 22 |
| 23 // Requests the template URL service to load its database (asynchronously). |
| 24 virtual void LoadTemplateURLServiceIfNeeded() = 0; |
| 25 |
| 26 // Requests |ready_callback| to be posted on the UI thread once the template |
| 27 // URL service has finished loading its database. |
| 28 virtual void WaitOnTemplateURLService( |
| 29 const base::Closure& ready_callback) = 0; |
| 30 |
| 31 // Returns attributes of the search engine currently set as the default, or |
| 32 // NULL if none. The returned dictionary will contain the following keys: |
| 33 // "search_url", "search_terms_replacement_key", |
| 34 // "suggest_url", "instant_url", |
| 35 // "image_url", "new_tab_url", |
| 36 // "icon_url", "search_url_post_params", |
| 37 // "suggest_url_post_params", "instant_url_post_params", |
| 38 // "image_url_post_params", "name", |
| 39 // "keyword", "encodings", |
| 40 // "prepopulate_id", "alternate_urls". |
| 41 // These attributes are a subset of, and used in the same sense as the user |
| 42 // preferences stored by TemplateURLService::SaveDefaultSearchProviderToPrefs. |
| 43 // Each key corresponds to the preference with the same name once you add the |
| 44 // "default_search_provider" prefix. Returned value is owned by the caller. |
| 45 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const = 0; |
| 46 |
| 47 // Returns whether or not the default search provider is set by policy. |
| 48 virtual bool IsDefaultSearchProviderManaged() const = 0; |
| 49 |
| 50 // Returns a list of dictionaries, each containing attributes for each of the |
| 51 // pre-populated search engines, in the format described above. The returned |
| 52 // value is owned by the caller. |
| 53 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const = 0; |
| 54 |
| 55 // Triggers showing the one-time profile settings reset prompt. |
| 56 virtual void ShowPrompt() = 0; |
| 57 |
| 58 // Reports the given metrics through UMA. |
| 59 virtual void ReportStatistics(uint32 satisfied_criteria_mask, |
| 60 uint32 combined_status_mask) = 0; |
| 61 }; |
| 62 |
| 63 // Implementation for AutomaticProfileResetterDelegate. |
| 64 class AutomaticProfileResetterDelegateImpl |
| 65 : public AutomaticProfileResetterDelegate, |
| 66 public TemplateURLServiceObserver { |
| 67 public: |
| 68 explicit AutomaticProfileResetterDelegateImpl(Profile* profile); |
| 69 virtual ~AutomaticProfileResetterDelegateImpl(); |
| 70 |
| 71 // AutomaticProfileResetterDelegate overrides: |
| 72 virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE; |
| 73 virtual void WaitOnTemplateURLService( |
| 74 const base::Closure& ready_callback) OVERRIDE; |
| 75 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const |
| 76 OVERRIDE; |
| 77 virtual bool IsDefaultSearchProviderManaged() const OVERRIDE; |
| 78 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const |
| 79 OVERRIDE; |
| 80 virtual void ShowPrompt() OVERRIDE; |
| 81 virtual void ReportStatistics(uint32 satisfied_criteria_mask, |
| 82 uint32 combined_status_mask) OVERRIDE; |
| 83 |
| 84 // TemplateURLServiceObserver overrides: |
| 85 virtual void OnTemplateURLServiceChanged() OVERRIDE; |
| 86 |
| 87 private: |
| 88 Profile* profile_; |
| 89 |
| 90 extensions::OneShotEvent template_url_service_ready_event_; |
| 91 |
| 92 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); |
| 93 }; |
| 94 |
| 95 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H
_ |
OLD | NEW |