| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 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 // Whether the app should be excluded from the "apps" list because |
| 44 // it is special (such as the Web Store app). |
| 45 static bool IsAppExcludedFromList(const Extension* extension); |
| 46 |
| 43 // Populate a dictionary with the information from an extension. | 47 // Populate a dictionary with the information from an extension. |
| 44 static void CreateAppInfo(const Extension* extension, | 48 static void CreateAppInfo( |
| 45 const AppNotification* notification, | 49 const Extension* extension, |
| 46 ExtensionService* service, | 50 const AppNotification* notification, |
| 47 base::DictionaryValue* value); | 51 ExtensionService* service, |
| 52 base::DictionaryValue* value); |
| 48 | 53 |
| 49 // Callback for pings related to launching apps on the NTP. | 54 // Callback for pings related to launching apps on the NTP. |
| 50 static bool HandlePing(Profile* profile, const std::string& path); | 55 static bool HandlePing(Profile* profile, const std::string& path); |
| 51 | 56 |
| 52 // WebUIMessageHandler implementation. | 57 // WebUIMessageHandler implementation. |
| 53 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 58 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| 54 virtual void RegisterMessages() OVERRIDE; | 59 virtual void RegisterMessages() OVERRIDE; |
| 55 | 60 |
| 56 // NotificationObserver | 61 // NotificationObserver |
| 57 virtual void Observe(int type, | 62 virtual void Observe(int type, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 ExtensionInstallUI* GetExtensionInstallUI(); | 146 ExtensionInstallUI* GetExtensionInstallUI(); |
| 142 | 147 |
| 143 // Helper that uninstalls all the default apps. | 148 // Helper that uninstalls all the default apps. |
| 144 void UninstallDefaultApps(); | 149 void UninstallDefaultApps(); |
| 145 | 150 |
| 146 // Continuation for installing a bookmark app after favicon lookup. | 151 // Continuation for installing a bookmark app after favicon lookup. |
| 147 void OnFaviconForApp(FaviconService::Handle handle, | 152 void OnFaviconForApp(FaviconService::Handle handle, |
| 148 history::FaviconData data); | 153 history::FaviconData data); |
| 149 | 154 |
| 150 // The apps are represented in the extensions model, which | 155 // The apps are represented in the extensions model, which |
| 151 // outlives us since its owned by our containing profile. | 156 // outlives us since it's owned by our containing profile. |
| 152 ExtensionService* const extensions_service_; | 157 ExtensionService* const extension_service_; |
| 153 | 158 |
| 154 // We monitor changes to the extension system so that we can reload the apps | 159 // We monitor changes to the extension system so that we can reload the apps |
| 155 // when necessary. | 160 // when necessary. |
| 156 NotificationRegistrar registrar_; | 161 NotificationRegistrar registrar_; |
| 157 | 162 |
| 158 // Monitor extension preference changes so that the Web UI can be notified. | 163 // Monitor extension preference changes so that the Web UI can be notified. |
| 159 PrefChangeRegistrar pref_change_registrar_; | 164 PrefChangeRegistrar pref_change_registrar_; |
| 160 | 165 |
| 161 // Used to show confirmation UI for uninstalling extensions in incognito mode. | 166 // Used to show confirmation UI for uninstalling extensions in incognito mode. |
| 162 scoped_ptr<ExtensionUninstallDialog> extension_uninstall_dialog_; | 167 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. | 179 // refreshing. This is useful when making many batch updates to avoid flicker. |
| 175 bool ignore_changes_; | 180 bool ignore_changes_; |
| 176 | 181 |
| 177 // Hold state for favicon requests. | 182 // Hold state for favicon requests. |
| 178 CancelableRequestConsumerTSimple<WebApplicationInfo*> favicon_consumer_; | 183 CancelableRequestConsumerTSimple<WebApplicationInfo*> favicon_consumer_; |
| 179 | 184 |
| 180 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 185 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
| 181 }; | 186 }; |
| 182 | 187 |
| 183 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ | 188 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ |
| OLD | NEW |