| 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_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 "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "chrome/browser/extensions/extension_app_api.h" | 10 #include "chrome/browser/extensions/extension_app_api.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 // The handler for Javascript messages related to the "apps" view. | 34 // The handler for Javascript messages related to the "apps" view. |
| 35 class AppLauncherHandler : public WebUIMessageHandler, | 35 class AppLauncherHandler : public WebUIMessageHandler, |
| 36 public ExtensionUninstallDialog::Delegate, | 36 public ExtensionUninstallDialog::Delegate, |
| 37 public ExtensionInstallUI::Delegate, | 37 public ExtensionInstallUI::Delegate, |
| 38 public NotificationObserver { | 38 public NotificationObserver { |
| 39 public: | 39 public: |
| 40 explicit AppLauncherHandler(ExtensionService* extension_service); | 40 explicit AppLauncherHandler(ExtensionService* extension_service); |
| 41 virtual ~AppLauncherHandler(); | 41 virtual ~AppLauncherHandler(); |
| 42 | 42 |
| 43 // Populate a dictionary with the information from an extension. | 43 // Populate a dictionary with the information from an extension. |
| 44 static void CreateAppInfo(const Extension* extension, | 44 static base::DictionaryValue* CreateAppInfo( |
| 45 const AppNotification* notification, | 45 const Extension* extension, |
| 46 ExtensionService* service, | 46 const AppNotification* notification, |
| 47 base::DictionaryValue* value); | 47 ExtensionService* service); |
| 48 | 48 |
| 49 // Callback for pings related to launching apps on the NTP. | 49 // Callback for pings related to launching apps on the NTP. |
| 50 static bool HandlePing(Profile* profile, const std::string& path); | 50 static bool HandlePing(Profile* profile, const std::string& path); |
| 51 | 51 |
| 52 // WebUIMessageHandler implementation. | 52 // WebUIMessageHandler implementation. |
| 53 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 53 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| 54 virtual void RegisterMessages(); | 54 virtual void RegisterMessages() OVERRIDE; |
| 55 | 55 |
| 56 // NotificationObserver | 56 // NotificationObserver |
| 57 virtual void Observe(int type, | 57 virtual void Observe(int type, |
| 58 const NotificationSource& source, | 58 const NotificationSource& source, |
| 59 const NotificationDetails& details); | 59 const NotificationDetails& details) OVERRIDE; |
| 60 | 60 |
| 61 // Populate the given dictionary with all installed app info. | 61 // Populate the given dictionary with all installed app info. |
| 62 void FillAppDictionary(base::DictionaryValue* value); | 62 void FillAppDictionary(base::DictionaryValue* value); |
| 63 | 63 |
| 64 // Create a dictionary value for the given extension. May return NULL, e.g. if | 64 // 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 | 65 // the given extension is not an app. If non-NULL, the caller assumes |
| 66 // ownership of the pointer. | 66 // ownership of the pointer. |
| 67 base::DictionaryValue* GetAppInfo(const Extension* extension); | 67 base::DictionaryValue* GetAppInfo(const Extension* extension); |
| 68 | 68 |
| 69 // Populate the given dictionary with the web store promo content. | 69 // Populate the given dictionary with the web store promo content. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // Records an app launch in the corresponding |bucket| of the app launch | 118 // Records an app launch in the corresponding |bucket| of the app launch |
| 119 // histogram if the |escaped_url| corresponds to an installed app. | 119 // histogram if the |escaped_url| corresponds to an installed app. |
| 120 static void RecordAppLaunchByURL(Profile* profile, | 120 static void RecordAppLaunchByURL(Profile* profile, |
| 121 std::string escaped_url, | 121 std::string escaped_url, |
| 122 extension_misc::AppLaunchBucket bucket); | 122 extension_misc::AppLaunchBucket bucket); |
| 123 | 123 |
| 124 // Prompts the user to re-enable the app for |extension_id|. | 124 // Prompts the user to re-enable the app for |extension_id|. |
| 125 void PromptToEnableApp(const std::string& extension_id); | 125 void PromptToEnableApp(const std::string& extension_id); |
| 126 | 126 |
| 127 // ExtensionUninstallDialog::Delegate: | 127 // ExtensionUninstallDialog::Delegate: |
| 128 virtual void ExtensionDialogAccepted(); | 128 virtual void ExtensionDialogAccepted() OVERRIDE; |
| 129 virtual void ExtensionDialogCanceled(); | 129 virtual void ExtensionDialogCanceled() OVERRIDE; |
| 130 | 130 |
| 131 // ExtensionInstallUI::Delegate: | 131 // ExtensionInstallUI::Delegate: |
| 132 virtual void InstallUIProceed(); | 132 virtual void InstallUIProceed() OVERRIDE; |
| 133 virtual void InstallUIAbort(bool user_initiated); | 133 virtual void InstallUIAbort(bool user_initiated) OVERRIDE; |
| 134 | 134 |
| 135 // Returns the ExtensionUninstallDialog object for this class, creating it if | 135 // Returns the ExtensionUninstallDialog object for this class, creating it if |
| 136 // needed. | 136 // needed. |
| 137 ExtensionUninstallDialog* GetExtensionUninstallDialog(); | 137 ExtensionUninstallDialog* GetExtensionUninstallDialog(); |
| 138 | 138 |
| 139 // Returns the ExtensionInstallUI object for this class, creating it if | 139 // Returns the ExtensionInstallUI object for this class, creating it if |
| 140 // needed. | 140 // needed. |
| 141 ExtensionInstallUI* GetExtensionInstallUI(); | 141 ExtensionInstallUI* GetExtensionInstallUI(); |
| 142 | 142 |
| 143 // Helper that uninstalls all the default apps. | 143 // Helper that uninstalls all the default apps. |
| 144 void UninstallDefaultApps(); | 144 void UninstallDefaultApps(); |
| 145 | 145 |
| 146 // Continuation for installing a bookmark app after favicon lookup. | 146 // Continuation for installing a bookmark app after favicon lookup. |
| 147 void OnFaviconForApp(FaviconService::Handle handle, | 147 void OnFaviconForApp(FaviconService::Handle handle, |
| 148 history::FaviconData data); | 148 history::FaviconData data); |
| 149 | 149 |
| 150 // The apps are represented in the extensions model, which | 150 // The apps are represented in the extensions model, which |
| 151 // outlives us since its owned by our containing profile. | 151 // outlives us since it's owned by our containing profile. |
| 152 ExtensionService* const extensions_service_; | 152 ExtensionService* const extension_service_; |
| 153 | 153 |
| 154 // We monitor changes to the extension system so that we can reload the apps | 154 // We monitor changes to the extension system so that we can reload the apps |
| 155 // when necessary. | 155 // when necessary. |
| 156 NotificationRegistrar registrar_; | 156 NotificationRegistrar registrar_; |
| 157 | 157 |
| 158 // Monitor extension preference changes so that the Web UI can be notified. | 158 // Monitor extension preference changes so that the Web UI can be notified. |
| 159 PrefChangeRegistrar pref_change_registrar_; | 159 PrefChangeRegistrar pref_change_registrar_; |
| 160 | 160 |
| 161 // Used to show confirmation UI for uninstalling extensions in incognito mode. | 161 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
| 162 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 162 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 174 // refreshing. This is useful when making many batch updates to avoid flicker. | 174 // refreshing. This is useful when making many batch updates to avoid flicker. |
| 175 bool ignore_changes_; | 175 bool ignore_changes_; |
| 176 | 176 |
| 177 // Hold state for favicon requests. | 177 // Hold state for favicon requests. |
| 178 CancelableRequestConsumerTSimple<WebApplicationInfo*> favicon_consumer_; | 178 CancelableRequestConsumerTSimple<WebApplicationInfo*> favicon_consumer_; |
| 179 | 179 |
| 180 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 180 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
| 181 }; | 181 }; |
| 182 | 182 |
| 183 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ | 183 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ |
| OLD | NEW |