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

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

Issue 10388252: Refactoring ExtenionInstallUI to abstract the Browser references. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced + mac fix Created 8 years, 6 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
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/cancelable_request.h" 12 #include "chrome/browser/cancelable_request.h"
13 #include "chrome/browser/extensions/extension_install_ui.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
14 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 14 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
15 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
16 #include "chrome/browser/prefs/pref_change_registrar.h" 16 #include "chrome/browser/prefs/pref_change_registrar.h"
17 #include "chrome/common/extensions/extension.h" 17 #include "chrome/common/extensions/extension.h"
18 #include "chrome/common/extensions/extension_constants.h" 18 #include "chrome/common/extensions/extension_constants.h"
19 #include "chrome/common/string_ordinal.h" 19 #include "chrome/common/string_ordinal.h"
20 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/browser/web_ui_message_handler.h" 22 #include "content/public/browser/web_ui_message_handler.h"
23 23
24 class AppNotification; 24 class AppNotification;
25 class ExtensionService; 25 class ExtensionService;
26 class PrefChangeRegistrar; 26 class PrefChangeRegistrar;
27 class Profile; 27 class Profile;
28 28
29 // The handler for Javascript messages related to the "apps" view. 29 // The handler for Javascript messages related to the "apps" view.
30 class AppLauncherHandler : public content::WebUIMessageHandler, 30 class AppLauncherHandler : public content::WebUIMessageHandler,
31 public ExtensionUninstallDialog::Delegate, 31 public ExtensionUninstallDialog::Delegate,
32 public ExtensionInstallUI::Delegate, 32 public ExtensionInstallPrompt::Delegate,
33 public content::NotificationObserver { 33 public content::NotificationObserver {
34 public: 34 public:
35 explicit AppLauncherHandler(ExtensionService* extension_service); 35 explicit AppLauncherHandler(ExtensionService* extension_service);
36 virtual ~AppLauncherHandler(); 36 virtual ~AppLauncherHandler();
37 37
38 // Populate a dictionary with the information from an extension. 38 // Populate a dictionary with the information from an extension.
39 static void CreateAppInfo( 39 static void CreateAppInfo(
40 const extensions::Extension* extension, 40 const extensions::Extension* extension,
41 const AppNotification* notification, 41 const AppNotification* notification,
42 ExtensionService* service, 42 ExtensionService* service,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 std::string escaped_url, 136 std::string escaped_url,
137 extension_misc::AppLaunchBucket bucket); 137 extension_misc::AppLaunchBucket bucket);
138 138
139 // Prompts the user to re-enable the app for |extension_id|. 139 // Prompts the user to re-enable the app for |extension_id|.
140 void PromptToEnableApp(const std::string& extension_id); 140 void PromptToEnableApp(const std::string& extension_id);
141 141
142 // ExtensionUninstallDialog::Delegate: 142 // ExtensionUninstallDialog::Delegate:
143 virtual void ExtensionUninstallAccepted() OVERRIDE; 143 virtual void ExtensionUninstallAccepted() OVERRIDE;
144 virtual void ExtensionUninstallCanceled() OVERRIDE; 144 virtual void ExtensionUninstallCanceled() OVERRIDE;
145 145
146 // ExtensionInstallUI::Delegate: 146 // ExtensionInstallPrompt::Delegate:
147 virtual void InstallUIProceed() OVERRIDE; 147 virtual void InstallUIProceed() OVERRIDE;
148 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 148 virtual void InstallUIAbort(bool user_initiated) OVERRIDE;
149 149
150 // Returns the ExtensionUninstallDialog object for this class, creating it if 150 // Returns the ExtensionUninstallDialog object for this class, creating it if
151 // needed. 151 // needed.
152 ExtensionUninstallDialog* GetExtensionUninstallDialog(); 152 ExtensionUninstallDialog* GetExtensionUninstallDialog();
153 153
154 // Returns the ExtensionInstallUI object for this class, creating it if 154 // Returns the ExtensionInstallPrompt object for this class, creating it if
155 // needed. 155 // needed.
156 ExtensionInstallUI* GetExtensionInstallUI(); 156 ExtensionInstallPrompt* GetExtensionInstallPrompt();
157 157
158 // Helper that uninstalls all the default apps. 158 // Helper that uninstalls all the default apps.
159 void UninstallDefaultApps(); 159 void UninstallDefaultApps();
160 160
161 // Continuation for installing a bookmark app after favicon lookup. 161 // Continuation for installing a bookmark app after favicon lookup.
162 void OnFaviconForApp(FaviconService::Handle handle, 162 void OnFaviconForApp(FaviconService::Handle handle,
163 history::FaviconData data); 163 history::FaviconData data);
164 164
165 // Sends |highlight_app_id_| to the js. 165 // Sends |highlight_app_id_| to the js.
166 void SetAppToBeHighlighted(); 166 void SetAppToBeHighlighted();
167 167
168 // The apps are represented in the extensions model, which 168 // The apps are represented in the extensions model, which
169 // outlives us since it's owned by our containing profile. 169 // outlives us since it's owned by our containing profile.
170 ExtensionService* const extension_service_; 170 ExtensionService* const extension_service_;
171 171
172 // We monitor changes to the extension system so that we can reload the apps 172 // We monitor changes to the extension system so that we can reload the apps
173 // when necessary. 173 // when necessary.
174 content::NotificationRegistrar registrar_; 174 content::NotificationRegistrar registrar_;
175 175
176 // Monitor extension preference changes so that the Web UI can be notified. 176 // Monitor extension preference changes so that the Web UI can be notified.
177 PrefChangeRegistrar pref_change_registrar_; 177 PrefChangeRegistrar pref_change_registrar_;
178 178
179 // Used to show confirmation UI for uninstalling extensions in incognito mode. 179 // Used to show confirmation UI for uninstalling extensions in incognito mode.
180 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; 180 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
181 181
182 // Used to show confirmation UI for enabling extensions in incognito mode. 182 // Used to show confirmation UI for enabling extensions in incognito mode.
183 scoped_ptr<ExtensionInstallUI> extension_install_ui_; 183 scoped_ptr<ExtensionInstallPrompt> extension_install_ui_;
184 184
185 // The id of the extension we are prompting the user about. 185 // The id of the extension we are prompting the user about.
186 std::string extension_id_prompting_; 186 std::string extension_id_prompting_;
187 187
188 // When true, we ignore changes to the underlying data rather than immediately 188 // When true, we ignore changes to the underlying data rather than immediately
189 // refreshing. This is useful when making many batch updates to avoid flicker. 189 // refreshing. This is useful when making many batch updates to avoid flicker.
190 bool ignore_changes_; 190 bool ignore_changes_;
191 191
192 // When true, we have attempted to install a bookmark app, and are still 192 // When true, we have attempted to install a bookmark app, and are still
193 // waiting to hear about success or failure from the extensions system. 193 // waiting to hear about success or failure from the extensions system.
194 bool attempted_bookmark_app_install_; 194 bool attempted_bookmark_app_install_;
195 195
196 // True if we have executed HandleGetApps() at least once. 196 // True if we have executed HandleGetApps() at least once.
197 bool has_loaded_apps_; 197 bool has_loaded_apps_;
198 198
199 // The ID of the app to be highlighted on the NTP (i.e. shown on the page 199 // The ID of the app to be highlighted on the NTP (i.e. shown on the page
200 // and pulsed). This is done for new installs. The actual higlighting occurs 200 // and pulsed). This is done for new installs. The actual higlighting occurs
201 // 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).
202 std::string highlight_app_id_; 202 std::string highlight_app_id_;
203 203
204 // Hold state for favicon requests. 204 // Hold state for favicon requests.
205 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_; 205 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_;
206 206
207 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); 207 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler);
208 }; 208 };
209 209
210 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ 210 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/extensions/install_extension_handler.cc ('k') | chrome/browser/ui/webui/ntp/app_launcher_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698