OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_APP_LAUNCHER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
10 #include "chrome/browser/extensions/extension_install_ui.h" | 10 #include "chrome/browser/extensions/extension_install_ui.h" |
| 11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
11 #include "chrome/browser/prefs/pref_change_registrar.h" | 12 #include "chrome/browser/prefs/pref_change_registrar.h" |
12 #include "chrome/common/extensions/extension.h" | 13 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
14 #include "content/browser/webui/web_ui.h" | 15 #include "content/browser/webui/web_ui.h" |
15 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
16 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
17 | 18 |
18 class ExtensionPrefs; | 19 class ExtensionPrefs; |
19 class ExtensionService; | 20 class ExtensionService; |
20 class NotificationRegistrar; | 21 class NotificationRegistrar; |
21 class PrefChangeRegistrar; | 22 class PrefChangeRegistrar; |
22 class Profile; | 23 class Profile; |
23 | 24 |
24 namespace gfx { | 25 namespace gfx { |
25 class Rect; | 26 class Rect; |
26 } | 27 } |
27 | 28 |
28 // The handler for Javascript messages related to the "apps" view. | 29 // The handler for Javascript messages related to the "apps" view. |
29 class AppLauncherHandler | 30 class AppLauncherHandler : public WebUIMessageHandler, |
30 : public WebUIMessageHandler, | 31 public ExtensionUninstallDialog::Delegate, |
31 public ExtensionInstallUI::Delegate, | 32 public ExtensionInstallUI::Delegate, |
32 public NotificationObserver { | 33 public NotificationObserver { |
33 public: | 34 public: |
34 explicit AppLauncherHandler(ExtensionService* extension_service); | 35 explicit AppLauncherHandler(ExtensionService* extension_service); |
35 virtual ~AppLauncherHandler(); | 36 virtual ~AppLauncherHandler(); |
36 | 37 |
37 // Populate a dictionary with the information from an extension. | 38 // Populate a dictionary with the information from an extension. |
38 static void CreateAppInfo(const Extension* extension, | 39 static void CreateAppInfo(const Extension* extension, |
39 ExtensionPrefs* extension_prefs, | 40 ExtensionPrefs* extension_prefs, |
40 DictionaryValue* value); | 41 DictionaryValue* value); |
41 | 42 |
42 // Callback for pings related to launching apps on the NTP. | 43 // Callback for pings related to launching apps on the NTP. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 // Records an app launch in the corresponding |bucket| of the app launch | 92 // Records an app launch in the corresponding |bucket| of the app launch |
92 // histogram if the |escaped_url| corresponds to an installed app. | 93 // histogram if the |escaped_url| corresponds to an installed app. |
93 static void RecordAppLaunchByURL(Profile* profile, | 94 static void RecordAppLaunchByURL(Profile* profile, |
94 std::string escaped_url, | 95 std::string escaped_url, |
95 extension_misc::AppLaunchBucket bucket); | 96 extension_misc::AppLaunchBucket bucket); |
96 | 97 |
97 // Prompts the user to re-enable the app for |extension_id|. | 98 // Prompts the user to re-enable the app for |extension_id|. |
98 void PromptToEnableApp(std::string extension_id); | 99 void PromptToEnableApp(std::string extension_id); |
99 | 100 |
100 // ExtensionInstallUI::Delegate implementation, used for receiving | 101 // ExtensionUninstallDialog::Delegate: |
101 // notification about uninstall confirmation dialog selections. | 102 virtual void ExtensionDialogAccepted(); |
| 103 virtual void ExtensionDialogCanceled(); |
| 104 |
| 105 // ExtensionInstallUI::Delegate: |
102 virtual void InstallUIProceed(); | 106 virtual void InstallUIProceed(); |
103 virtual void InstallUIAbort(); | 107 virtual void InstallUIAbort(); |
104 | 108 |
| 109 // Returns the ExtensionUninstallDialog object for this class, creating it if |
| 110 // needed. |
| 111 ExtensionUninstallDialog* GetExtensionUninstallDialog(); |
| 112 |
105 // Returns the ExtensionInstallUI object for this class, creating it if | 113 // Returns the ExtensionInstallUI object for this class, creating it if |
106 // needed. | 114 // needed. |
107 ExtensionInstallUI* GetExtensionInstallUI(); | 115 ExtensionInstallUI* GetExtensionInstallUI(); |
108 | 116 |
109 // Helper that uninstalls all the default apps. | 117 // Helper that uninstalls all the default apps. |
110 void UninstallDefaultApps(); | 118 void UninstallDefaultApps(); |
111 | 119 |
112 // The apps are represented in the extensions model. | 120 // The apps are represented in the extensions model. |
113 scoped_refptr<ExtensionService> extensions_service_; | 121 scoped_refptr<ExtensionService> extensions_service_; |
114 | 122 |
115 // We monitor changes to the extension system so that we can reload the apps | 123 // We monitor changes to the extension system so that we can reload the apps |
116 // when necessary. | 124 // when necessary. |
117 NotificationRegistrar registrar_; | 125 NotificationRegistrar registrar_; |
118 | 126 |
119 // Monitor extension preference changes so that the Web UI can be notified. | 127 // Monitor extension preference changes so that the Web UI can be notified. |
120 PrefChangeRegistrar pref_change_registrar_; | 128 PrefChangeRegistrar pref_change_registrar_; |
121 | 129 |
122 // Used to show confirmation UI for uninstalling/enabling extensions in | 130 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
123 // incognito mode. | 131 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
124 scoped_ptr<ExtensionInstallUI> install_ui_; | 132 |
| 133 // Used to show confirmation UI for enabling extensions in incognito mode. |
| 134 scoped_ptr<ExtensionInstallUI> extension_install_ui_; |
125 | 135 |
126 // The id of the extension we are prompting the user about. | 136 // The id of the extension we are prompting the user about. |
127 std::string extension_id_prompting_; | 137 std::string extension_id_prompting_; |
128 | 138 |
129 // The type of prompt we are showing the user. | |
130 ExtensionInstallUI::PromptType extension_prompt_type_; | |
131 | |
132 // Whether the promo is currently being shown. | 139 // Whether the promo is currently being shown. |
133 bool promo_active_; | 140 bool promo_active_; |
134 | 141 |
135 // When true, we ignore changes to the underlying data rather than immediately | 142 // When true, we ignore changes to the underlying data rather than immediately |
136 // refreshing. This is useful when making many batch updates to avoid flicker. | 143 // refreshing. This is useful when making many batch updates to avoid flicker. |
137 bool ignore_changes_; | 144 bool ignore_changes_; |
138 | 145 |
139 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 146 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
140 }; | 147 }; |
141 | 148 |
142 #endif // CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ | 149 #endif // CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ |
OLD | NEW |