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 "content/public/browser/notification_observer.h" | |
13 #include "content/public/browser/notification_registrar.h" | |
14 #include "extensions/common/one_shot_event.h" | |
15 | |
16 class Profile; | |
17 | |
18 // Defines the interface for the delegate that will interact with the rest of | |
19 // the browser on behalf of the AutomaticProfileResetter. | |
20 // The primary reason for this separation is to facilitate unit testing. | |
21 class AutomaticProfileResetterDelegate { | |
22 public: | |
23 virtual ~AutomaticProfileResetterDelegate() {} | |
24 | |
25 // Requests the module enumerator to start scanning for loaded modules now, if | |
26 // it has not done so already. | |
27 virtual void EnumerateLoadedModulesIfNeeded() = 0; | |
28 | |
29 // Requests |ready_callback| to be posted on the UI thread once the module | |
30 // enumerator has finished scanning for loaded modules. | |
31 virtual void RequestCallbackWhenLoadedModulesAreEnumerated( | |
32 const base::Closure& ready_callback) const = 0; | |
33 | |
34 // Requests the template URL service to load its database (asynchronously). | |
35 virtual void LoadTemplateURLServiceIfNeeded() = 0; | |
36 | |
37 // Requests |ready_callback| to be posted on the UI thread once the template | |
38 // URL service has finished loading its database. | |
39 virtual void RequestCallbackWhenTemplateURLServiceIsLoaded( | |
40 const base::Closure& ready_callback) const = 0; | |
41 | |
42 // Returns a list of loaded module name digests. | |
43 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
| |
44 | |
45 // Returns attributes of the search engine currently set as the default, or | |
46 // 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.
| |
47 // "search_url", "search_terms_replacement_key", | |
48 // "suggest_url", "instant_url", | |
49 // "image_url", "new_tab_url", | |
50 // "icon_url", "search_url_post_params", | |
51 // "suggest_url_post_params", "instant_url_post_params", | |
52 // "image_url_post_params", "name", | |
53 // "keyword", "encodings", | |
54 // "prepopulate_id", "alternate_urls". | |
55 // These attributes are a subset of, and used in the same sense as the user | |
56 // preferences stored by TemplateURLService::SaveDefaultSearchProviderToPrefs. | |
57 // Each key corresponds to the preference with the same name once you add the | |
58 // "default_search_provider" prefix. Returned value is owned by the caller. | |
59 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const = 0; | |
60 | |
61 // Returns whether or not the default search provider is set by policy. | |
62 virtual bool IsDefaultSearchProviderManaged() const = 0; | |
63 | |
64 // Returns a list of dictionaries, each containing attributes for each of the | |
65 // pre-populated search engines, in the format described above. The returned | |
66 // value is owned by the caller. | |
67 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const = 0; | |
68 | |
69 // Triggers showing the one-time profile settings reset prompt. | |
70 virtual void ShowPrompt() = 0; | |
71 }; | |
72 | |
73 // Implementation for AutomaticProfileResetterDelegate. | |
74 class AutomaticProfileResetterDelegateImpl | |
75 : public AutomaticProfileResetterDelegate, | |
76 public TemplateURLServiceObserver, | |
77 public content::NotificationObserver { | |
78 public: | |
79 explicit AutomaticProfileResetterDelegateImpl(Profile* profile); | |
80 virtual ~AutomaticProfileResetterDelegateImpl(); | |
81 | |
82 // 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
| |
83 virtual void EnumerateLoadedModulesIfNeeded() OVERRIDE; | |
84 virtual void RequestCallbackWhenLoadedModulesAreEnumerated( | |
85 const base::Closure& ready_callback) const OVERRIDE; | |
86 | |
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
| |
87 virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE; | |
88 virtual void RequestCallbackWhenTemplateURLServiceIsLoaded( | |
89 const base::Closure& ready_callback) const OVERRIDE; | |
90 | |
91 virtual base::ListValue* GetLoadedModuleNameDigests() const OVERRIDE; | |
92 | |
93 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const | |
94 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.
| |
95 virtual bool IsDefaultSearchProviderManaged() const OVERRIDE; | |
96 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const | |
97 OVERRIDE; | |
98 | |
99 virtual void ShowPrompt() OVERRIDE; | |
100 | |
101 // TemplateURLServiceObserver overrides: | |
102 virtual void OnTemplateURLServiceChanged() OVERRIDE; | |
103 | |
104 // content::NotificationObserver: | |
105 virtual void Observe(int type, | |
106 const content::NotificationSource& source, | |
107 const content::NotificationDetails& details) OVERRIDE; | |
108 | |
109 private: | |
110 Profile* profile_; | |
111 | |
112 content::NotificationRegistrar registrar_; | |
113 | |
114 // The list of modules found. Even when |modules_have_been_enumerated_event_| | |
115 // is signaled, this may still be NULL. | |
116 scoped_ptr<base::ListValue> module_list_; | |
117 | |
118 // This event is signaled once we have proof that the modules have been | |
119 // (attempted to be) enumerated at least once. | |
120 extensions::OneShotEvent modules_have_been_enumerated_event_; | |
121 | |
122 // 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.
| |
123 extensions::OneShotEvent template_url_service_ready_event_; | |
124 | |
125 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl); | |
126 }; | |
127 | |
128 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H _ | |
OLD | NEW |