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" |
Aaron Boodman
2011/03/23 21:06:54
Is this header still needed?
| |
11 #include "chrome/browser/extensions/extension_generic_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 ExtensionGenericDialog::Delegate, |
31 public ExtensionInstallUI::Delegate, | 32 public NotificationObserver { |
32 public NotificationObserver { | |
33 public: | 33 public: |
34 explicit AppLauncherHandler(ExtensionService* extension_service); | 34 explicit AppLauncherHandler(ExtensionService* extension_service); |
35 virtual ~AppLauncherHandler(); | 35 virtual ~AppLauncherHandler(); |
36 | 36 |
37 // Populate a dictionary with the information from an extension. | 37 // Populate a dictionary with the information from an extension. |
38 static void CreateAppInfo(const Extension* extension, | 38 static void CreateAppInfo(const Extension* extension, |
39 ExtensionPrefs* extension_prefs, | 39 ExtensionPrefs* extension_prefs, |
40 DictionaryValue* value); | 40 DictionaryValue* value); |
41 | 41 |
42 // Callback for pings related to launching apps on the NTP. | 42 // Callback for pings related to launching apps on the NTP. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
90 | 90 |
91 // Records an app launch in the corresponding |bucket| of the app launch | 91 // Records an app launch in the corresponding |bucket| of the app launch |
92 // histogram if the |escaped_url| corresponds to an installed app. | 92 // histogram if the |escaped_url| corresponds to an installed app. |
93 static void RecordAppLaunchByURL(Profile* profile, | 93 static void RecordAppLaunchByURL(Profile* profile, |
94 std::string escaped_url, | 94 std::string escaped_url, |
95 extension_misc::AppLaunchBucket bucket); | 95 extension_misc::AppLaunchBucket bucket); |
96 | 96 |
97 // Prompts the user to re-enable the app for |extension_id|. | 97 // Prompts the user to re-enable the app for |extension_id|. |
98 void PromptToEnableApp(std::string extension_id); | 98 void PromptToEnableApp(std::string extension_id); |
99 | 99 |
100 // ExtensionInstallUI::Delegate implementation, used for receiving | 100 // ExtensionGenericDialog::Delegate: |
101 // notification about uninstall confirmation dialog selections. | 101 virtual void ExtensionDialogAccepted(); |
102 virtual void InstallUIProceed(); | 102 virtual void ExtensionDialogCanceled(); |
103 virtual void InstallUIAbort(); | |
104 | 103 |
105 // Returns the ExtensionInstallUI object for this class, creating it if | 104 // Returns the ExtensionGenericDialog object for this class, creating it if |
106 // needed. | 105 // needed. |
107 ExtensionInstallUI* GetExtensionInstallUI(); | 106 ExtensionGenericDialog* GetExtensionGenericDialog(); |
108 | 107 |
109 // Helper that uninstalls all the default apps. | 108 // Helper that uninstalls all the default apps. |
110 void UninstallDefaultApps(); | 109 void UninstallDefaultApps(); |
111 | 110 |
112 // The apps are represented in the extensions model. | 111 // The apps are represented in the extensions model. |
113 scoped_refptr<ExtensionService> extensions_service_; | 112 scoped_refptr<ExtensionService> extensions_service_; |
114 | 113 |
115 // We monitor changes to the extension system so that we can reload the apps | 114 // We monitor changes to the extension system so that we can reload the apps |
116 // when necessary. | 115 // when necessary. |
117 NotificationRegistrar registrar_; | 116 NotificationRegistrar registrar_; |
118 | 117 |
119 // Monitor extension preference changes so that the Web UI can be notified. | 118 // Monitor extension preference changes so that the Web UI can be notified. |
120 PrefChangeRegistrar pref_change_registrar_; | 119 PrefChangeRegistrar pref_change_registrar_; |
121 | 120 |
122 // Used to show confirmation UI for uninstalling/enabling extensions in | 121 // Used to show confirmation UI for uninstalling/enabling extensions in |
123 // incognito mode. | 122 // incognito mode. |
124 scoped_ptr<ExtensionInstallUI> install_ui_; | 123 scoped_ptr<ExtensionGenericDialog> extension_generic_dialog_; |
125 | 124 |
126 // The id of the extension we are prompting the user about. | 125 // The id of the extension we are prompting the user about. |
127 std::string extension_id_prompting_; | 126 std::string extension_id_prompting_; |
128 | 127 |
129 // The type of prompt we are showing the user. | 128 // The type of prompt we are showing the user. |
130 ExtensionInstallUI::PromptType extension_prompt_type_; | 129 ExtensionGenericDialog::DialogType extension_dialog_type_; |
131 | 130 |
132 // Whether the promo is currently being shown. | 131 // Whether the promo is currently being shown. |
133 bool promo_active_; | 132 bool promo_active_; |
134 | 133 |
135 // When true, we ignore changes to the underlying data rather than immediately | 134 // 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. | 135 // refreshing. This is useful when making many batch updates to avoid flicker. |
137 bool ignore_changes_; | 136 bool ignore_changes_; |
138 | 137 |
139 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 138 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
140 }; | 139 }; |
141 | 140 |
142 #endif // CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ | 141 #endif // CHROME_BROWSER_UI_WEBUI_APP_LAUNCHER_HANDLER_H_ |
OLD | NEW |