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

Side by Side Diff: chrome/browser/ui/webui/ntp/app_launcher_handler.h

Issue 11348165: Remove PrefObserver usages, batch 10. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ 6 #define CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/public/pref_change_registrar.h" 11 #include "base/prefs/public/pref_change_registrar.h"
12 #include "base/prefs/public/pref_observer.h"
13 #include "chrome/browser/common/cancelable_request.h" 12 #include "chrome/browser/common/cancelable_request.h"
14 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
15 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 14 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
16 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
17 #include "chrome/common/extensions/extension.h" 16 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_constants.h" 17 #include "chrome/common/extensions/extension_constants.h"
19 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
20 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
21 #include "content/public/browser/web_ui_message_handler.h" 20 #include "content/public/browser/web_ui_message_handler.h"
22 #include "sync/api/string_ordinal.h" 21 #include "sync/api/string_ordinal.h"
23 22
24 class ExtensionService; 23 class ExtensionService;
25 class PrefChangeRegistrar; 24 class PrefChangeRegistrar;
26 class Profile; 25 class Profile;
27 26
28 namespace extensions { 27 namespace extensions {
29 class AppNotification; 28 class AppNotification;
30 } 29 }
31 30
32 // The handler for Javascript messages related to the "apps" view. 31 // The handler for Javascript messages related to the "apps" view.
33 class AppLauncherHandler : public content::WebUIMessageHandler, 32 class AppLauncherHandler : public content::WebUIMessageHandler,
34 public ExtensionUninstallDialog::Delegate, 33 public ExtensionUninstallDialog::Delegate,
35 public ExtensionInstallPrompt::Delegate, 34 public ExtensionInstallPrompt::Delegate,
36 public content::NotificationObserver, 35 public content::NotificationObserver {
37 public PrefObserver {
38 public: 36 public:
39 explicit AppLauncherHandler(ExtensionService* extension_service); 37 explicit AppLauncherHandler(ExtensionService* extension_service);
40 virtual ~AppLauncherHandler(); 38 virtual ~AppLauncherHandler();
41 39
42 // Populate a dictionary with the information from an extension. 40 // Populate a dictionary with the information from an extension.
43 static void CreateAppInfo( 41 static void CreateAppInfo(
44 const extensions::Extension* extension, 42 const extensions::Extension* extension,
45 const extensions::AppNotification* notification, 43 const extensions::AppNotification* notification,
46 ExtensionService* service, 44 ExtensionService* service,
47 base::DictionaryValue* value); 45 base::DictionaryValue* value);
48 46
49 // WebUIMessageHandler implementation. 47 // WebUIMessageHandler implementation.
50 virtual void RegisterMessages() OVERRIDE; 48 virtual void RegisterMessages() OVERRIDE;
51 49
52 // content::NotificationObserver 50 // content::NotificationObserver
53 virtual void Observe(int type, 51 virtual void Observe(int type,
54 const content::NotificationSource& source, 52 const content::NotificationSource& source,
55 const content::NotificationDetails& details) OVERRIDE; 53 const content::NotificationDetails& details) OVERRIDE;
56 54
57 // PrefObserver
58 virtual void OnPreferenceChanged(PrefServiceBase* service,
59 const std::string& pref_name) OVERRIDE;
60
61 // Populate the given dictionary with all installed app info. 55 // Populate the given dictionary with all installed app info.
62 void FillAppDictionary(base::DictionaryValue* value); 56 void FillAppDictionary(base::DictionaryValue* value);
63 57
64 // Create a dictionary value for the given extension. May return NULL, e.g. if 58 // Create a dictionary value for the given extension. May return NULL, e.g. if
65 // the given extension is not an app. If non-NULL, the caller assumes 59 // the given extension is not an app. If non-NULL, the caller assumes
66 // ownership of the pointer. 60 // ownership of the pointer.
67 base::DictionaryValue* GetAppInfo(const extensions::Extension* extension); 61 base::DictionaryValue* GetAppInfo(const extensions::Extension* extension);
68 62
69 // Populate the given dictionary with the web store promo content. 63 // Populate the given dictionary with the web store promo content.
70 void FillPromoDictionary(base::DictionaryValue* value); 64 void FillPromoDictionary(base::DictionaryValue* value);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // needed. 153 // needed.
160 ExtensionInstallPrompt* GetExtensionInstallPrompt(); 154 ExtensionInstallPrompt* GetExtensionInstallPrompt();
161 155
162 // Continuation for installing a bookmark app after favicon lookup. 156 // Continuation for installing a bookmark app after favicon lookup.
163 void OnFaviconForApp(FaviconService::Handle handle, 157 void OnFaviconForApp(FaviconService::Handle handle,
164 const history::FaviconImageResult& image_result); 158 const history::FaviconImageResult& image_result);
165 159
166 // Sends |highlight_app_id_| to the js. 160 // Sends |highlight_app_id_| to the js.
167 void SetAppToBeHighlighted(); 161 void SetAppToBeHighlighted();
168 162
163 void OnPreferencesChanged();
Jói 2012/11/20 22:11:55 suggest OnPreferenceChanged (singular) to match na
tfarina 2012/11/20 23:41:20 Done.
164
169 // The apps are represented in the extensions model, which 165 // The apps are represented in the extensions model, which
170 // outlives us since it's owned by our containing profile. 166 // outlives us since it's owned by our containing profile.
171 ExtensionService* const extension_service_; 167 ExtensionService* const extension_service_;
172 168
173 // We monitor changes to the extension system so that we can reload the apps 169 // We monitor changes to the extension system so that we can reload the apps
174 // when necessary. 170 // when necessary.
175 content::NotificationRegistrar registrar_; 171 content::NotificationRegistrar registrar_;
176 172
177 // Monitor extension preference changes so that the Web UI can be notified. 173 // Monitor extension preference changes so that the Web UI can be notified.
178 PrefChangeRegistrar pref_change_registrar_; 174 PrefChangeRegistrar pref_change_registrar_;
(...skipping 26 matching lines...) Expand all
205 // when the app is added to the page (via getAppsCallback or appAdded). 201 // when the app is added to the page (via getAppsCallback or appAdded).
206 std::string highlight_app_id_; 202 std::string highlight_app_id_;
207 203
208 // Hold state for favicon requests. 204 // Hold state for favicon requests.
209 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_; 205 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_;
210 206
211 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); 207 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler);
212 }; 208 };
213 209
214 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ 210 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698