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

Side by Side Diff: chrome/browser/profile_resetter/automatic_profile_resetter_delegate.h

Issue 27030002: Added collecting of data to be fed to the JTL interpreter. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor changes, plus added some additional unit-tests. Created 7 years, 2 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 // verifier has finished scanning for loaded modules.
31 virtual void WaitOnEnumerationOfLoadedModules(
vasilii 2013/10/14 16:43:33 Here and below SetCallbackOnEnumerationOfLoadedMod
engedy 2013/10/14 19:35:50 Done.
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 WaitOnTemplateURLService(
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;
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:
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 // Reports the given metrics through UMA.
73 virtual void ReportStatistics(uint32 satisfied_criteria_mask,
74 uint32 combined_status_mask) = 0;
75 };
76
77 // Implementation for AutomaticProfileResetterDelegate.
78 class AutomaticProfileResetterDelegateImpl
79 : public AutomaticProfileResetterDelegate,
80 public TemplateURLServiceObserver,
81 public content::NotificationObserver {
82 public:
83 explicit AutomaticProfileResetterDelegateImpl(Profile* profile);
84 virtual ~AutomaticProfileResetterDelegateImpl();
85
86 // AutomaticProfileResetterDelegate overrides:
87 virtual void EnumerateLoadedModulesIfNeeded() OVERRIDE;
88 virtual void WaitOnEnumerationOfLoadedModules(
89 const base::Closure& ready_callback) const OVERRIDE;
90
91 virtual void LoadTemplateURLServiceIfNeeded() OVERRIDE;
92 virtual void WaitOnTemplateURLService(
93 const base::Closure& ready_callback) const OVERRIDE;
94
95 virtual base::ListValue* GetLoadedModuleNameDigests() const OVERRIDE;
96
97 virtual base::DictionaryValue* GetDefaultSearchProviderDetails() const
98 OVERRIDE;
99 virtual bool IsDefaultSearchProviderManaged() const OVERRIDE;
100 virtual base::ListValue* GetPrepopulatedSearchProvidersDetails() const
101 OVERRIDE;
102
103 virtual void ShowPrompt() OVERRIDE;
104 virtual void ReportStatistics(uint32 satisfied_criteria_mask,
105 uint32 combined_status_mask) OVERRIDE;
106
107 // TemplateURLServiceObserver overrides:
108 virtual void OnTemplateURLServiceChanged() OVERRIDE;
109
110 // content::NotificationObserver:
111 virtual void Observe(int type,
112 const content::NotificationSource& source,
113 const content::NotificationDetails& details) OVERRIDE;
114
115 private:
116 Profile* profile_;
117
118 content::NotificationRegistrar registrar_;
119
120 // The list of modules found. Even when |modules_have_been_enumerated_event_|
121 // is signaled, this may still be NULL if scanning for modules failed.
122 scoped_ptr<base::ListValue> module_list_;
123
124 // This event is signaled once we have proof that the modules have been
125 // (attempted to be) enumerated at least once.
126 extensions::OneShotEvent modules_have_been_enumerated_event_;
127
128 // This event is signaled once TemplateURLService::loaded() returns true.
129 extensions::OneShotEvent template_url_service_ready_event_;
130
131 DISALLOW_COPY_AND_ASSIGN(AutomaticProfileResetterDelegateImpl);
132 };
133
134 #endif // CHROME_BROWSER_PROFILE_RESETTER_AUTOMATIC_PROFILE_RESETTER_DELEGATE_H _
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698