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

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

Issue 11644077: Put extension enable logic into a ExtensionEnableFlow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 <set>
8 #include <string> 9 #include <string>
9 10
10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
11 #include "base/prefs/public/pref_change_registrar.h" 12 #include "base/prefs/public/pref_change_registrar.h"
12 #include "chrome/browser/extensions/extension_install_prompt.h" 13 #include "chrome/browser/extensions/extension_install_prompt.h"
13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 14 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
14 #include "chrome/browser/favicon/favicon_service.h" 15 #include "chrome/browser/favicon/favicon_service.h"
16 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
15 #include "chrome/common/cancelable_task_tracker.h" 17 #include "chrome/common/cancelable_task_tracker.h"
16 #include "chrome/common/extensions/extension.h" 18 #include "chrome/common/extensions/extension.h"
17 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
18 #include "content/public/browser/notification_observer.h" 20 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 21 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/web_ui_message_handler.h" 22 #include "content/public/browser/web_ui_message_handler.h"
21 #include "sync/api/string_ordinal.h" 23 #include "sync/api/string_ordinal.h"
22 24
23 class ExtensionService; 25 class ExtensionService;
24 class PrefChangeRegistrar; 26 class PrefChangeRegistrar;
25 class Profile; 27 class Profile;
26 28
27 namespace extensions { 29 namespace extensions {
28 class AppNotification; 30 class AppNotification;
29 } 31 }
30 32
31 // The handler for Javascript messages related to the "apps" view. 33 // The handler for Javascript messages related to the "apps" view.
32 class AppLauncherHandler : public content::WebUIMessageHandler, 34 class AppLauncherHandler : public content::WebUIMessageHandler,
33 public ExtensionUninstallDialog::Delegate, 35 public ExtensionUninstallDialog::Delegate,
34 public ExtensionInstallPrompt::Delegate, 36 public ExtensionEnableFlowDelegate,
35 public content::NotificationObserver { 37 public content::NotificationObserver {
36 public: 38 public:
37 explicit AppLauncherHandler(ExtensionService* extension_service); 39 explicit AppLauncherHandler(ExtensionService* extension_service);
38 virtual ~AppLauncherHandler(); 40 virtual ~AppLauncherHandler();
39 41
40 // Populate a dictionary with the information from an extension. 42 // Populate a dictionary with the information from an extension.
41 static void CreateAppInfo( 43 static void CreateAppInfo(
42 const extensions::Extension* extension, 44 const extensions::Extension* extension,
43 const extensions::AppNotification* notification, 45 const extensions::AppNotification* notification,
44 ExtensionService* service, 46 ExtensionService* service,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string escaped_url, 136 std::string escaped_url,
135 extension_misc::AppLaunchBucket bucket); 137 extension_misc::AppLaunchBucket bucket);
136 138
137 // Prompts the user to re-enable the app for |extension_id|. 139 // Prompts the user to re-enable the app for |extension_id|.
138 void PromptToEnableApp(const std::string& extension_id); 140 void PromptToEnableApp(const std::string& extension_id);
139 141
140 // ExtensionUninstallDialog::Delegate: 142 // ExtensionUninstallDialog::Delegate:
141 virtual void ExtensionUninstallAccepted() OVERRIDE; 143 virtual void ExtensionUninstallAccepted() OVERRIDE;
142 virtual void ExtensionUninstallCanceled() OVERRIDE; 144 virtual void ExtensionUninstallCanceled() OVERRIDE;
143 145
144 // ExtensionInstallPrompt::Delegate: 146 // ExtensionEnableFlowDelegate:
145 virtual void InstallUIProceed() OVERRIDE; 147 virtual ExtensionInstallPrompt* CreateExtensionInstallPrompt() OVERRIDE;
146 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; 148 virtual void ExtensionEnableFlowFinished(ExtensionEnableFlow* flow) OVERRIDE;
149 virtual void ExtensionEnableFlowAborted(ExtensionEnableFlow* flow,
150 bool user_initiated) OVERRIDE;
147 151
148 // Returns the ExtensionUninstallDialog object for this class, creating it if 152 // Returns the ExtensionUninstallDialog object for this class, creating it if
149 // needed. 153 // needed.
150 ExtensionUninstallDialog* GetExtensionUninstallDialog(); 154 ExtensionUninstallDialog* GetExtensionUninstallDialog();
151 155
152 // Returns the ExtensionInstallPrompt object for this class, creating it if
153 // needed.
154 ExtensionInstallPrompt* GetExtensionInstallPrompt();
155
156 // Continuation for installing a bookmark app after favicon lookup. 156 // Continuation for installing a bookmark app after favicon lookup.
157 void OnFaviconForApp(scoped_ptr<AppInstallInfo> install_info, 157 void OnFaviconForApp(scoped_ptr<AppInstallInfo> install_info,
158 const history::FaviconImageResult& image_result); 158 const history::FaviconImageResult& image_result);
159 159
160 // Sends |highlight_app_id_| to the js. 160 // Sends |highlight_app_id_| to the js.
161 void SetAppToBeHighlighted(); 161 void SetAppToBeHighlighted();
162 162
163 void OnPreferenceChanged(); 163 void OnPreferenceChanged();
164 164
165 // The apps are represented in the extensions model, which 165 // The apps are represented in the extensions model, which
166 // outlives us since it's owned by our containing profile. 166 // outlives us since it's owned by our containing profile.
167 ExtensionService* const extension_service_; 167 ExtensionService* const extension_service_;
168 168
169 // 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
170 // when necessary. 170 // when necessary.
171 content::NotificationRegistrar registrar_; 171 content::NotificationRegistrar registrar_;
172 172
173 // 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.
174 PrefChangeRegistrar pref_change_registrar_; 174 PrefChangeRegistrar pref_change_registrar_;
175 175
176 // Used to show confirmation UI for uninstalling extensions in incognito mode. 176 // Used to show confirmation UI for uninstalling extensions in incognito mode.
177 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; 177 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_;
178 178
179 // Used to show confirmation UI for enabling extensions in incognito mode. 179 // Used to show confirmation UI for enabling extensions.
180 scoped_ptr<ExtensionInstallPrompt> extension_install_ui_; 180 scoped_ptr<ExtensionEnableFlow> extension_enable_flow_;
181 181
182 // The ids of apps to show on the NTP. 182 // The ids of apps to show on the NTP.
183 std::set<std::string> visible_apps_; 183 std::set<std::string> visible_apps_;
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_;
(...skipping 10 matching lines...) Expand all
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 // Used for favicon loading tasks. 204 // Used for favicon loading tasks.
205 CancelableTaskTracker cancelable_task_tracker_; 205 CancelableTaskTracker cancelable_task_tracker_;
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

Powered by Google App Engine
This is Rietveld 408576698