Chromium Code Reviews| 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. | |
|
battre
2013/10/11 15:05:33
Please add comment on ownership of returned value.
engedy
2013/10/11 16:42:16
Done.
| |
| 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. | |
| 52 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const = 0; | |
| 53 | |
| 54 // Triggers showing the one-time profile settings reset prompt. | |
| 55 virtual void ShowPrompt() = 0; | |
| 56 | |
| 57 // Reports the given metrics through UMA. | |
| 58 virtual void ReportStatistics(uint32 satisfied_criteria_mask, | |
| 59 uint32 combined_status_mask) = 0; | |
| 60 }; | |
| 61 | |
| 62 // Implementation for AutomaticProfileResetterDelegate. | |
| 63 class AutomaticProfileResetterDelegateImpl | |
| 64 : public AutomaticProfileResetterDelegate, | |
| 65 public TemplateURLServiceObserver { | |
| 66 public: | |
| 67 explicit AutomaticProfileResetterDelegateImpl(Profile* profile); | |
| 68 virtual ~AutomaticProfileResetterDelegateImpl(); | |
| 69 | |
| 70 // AutomaticProfileResetterDelegate overrides: | |
| 71 virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE; | |
| 72 virtual void WaitOnTemplateURLService( | |
| 73 const base::Closure& ready_callback) OVERRIDE; | |
| 74 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const | |
| 75 OVERRIDE; | |
| 76 virtual bool IsDefaultSearchProviderManaged() const OVERRIDE; | |
| 77 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const | |
| 78 OVERRIDE; | |
| 79 virtual void ShowPrompt() OVERRIDE; | |
| 80 virtual void ReportStatistics(uint32 satisfied_criteria_mask, | |
| 81 uint32 combined_status_mask) OVERRIDE; | |
| 82 | |
| 83 // TemplateURLServiceObserver overrides: | |
| 84 virtual void OnTemplateURLServiceChanged() OVERRIDE; | |
| 85 | |
| 86 private: | |
| 87 Profile* profile_; | |
| 88 | |
| 89 extensions::OneShotEvent template_url_service_ready_event_; | |
| 90 | |
| 91 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); | |
| 92 }; | |
| 93 | |
| 94 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H _ | |
| OLD | NEW |