| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_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/dom_ui/dom_ui.h" | 10 #include "chrome/browser/dom_ui/dom_ui.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 // The handler for Javascript messages related to the "apps" view. | 26 // The handler for Javascript messages related to the "apps" view. |
| 27 class AppLauncherHandler | 27 class AppLauncherHandler |
| 28 : public DOMMessageHandler, | 28 : public DOMMessageHandler, |
| 29 public ExtensionInstallUI::Delegate, | 29 public ExtensionInstallUI::Delegate, |
| 30 public NotificationObserver { | 30 public NotificationObserver { |
| 31 public: | 31 public: |
| 32 explicit AppLauncherHandler(ExtensionsService* extension_service); | 32 explicit AppLauncherHandler(ExtensionsService* extension_service); |
| 33 virtual ~AppLauncherHandler(); | 33 virtual ~AppLauncherHandler(); |
| 34 | 34 |
| 35 // Populate a dictionary with the information from an extension. |
| 36 static void CreateAppInfo(const Extension* extension, |
| 37 ExtensionPrefs* extension_prefs, |
| 38 DictionaryValue* value); |
| 39 |
| 40 // Callback for pings related to launching apps on the NTP. |
| 41 static bool HandlePing(const std::string& path); |
| 42 |
| 35 // DOMMessageHandler implementation. | 43 // DOMMessageHandler implementation. |
| 36 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); | 44 virtual DOMMessageHandler* Attach(DOMUI* dom_ui); |
| 37 virtual void RegisterMessages(); | 45 virtual void RegisterMessages(); |
| 38 | 46 |
| 39 // NotificationObserver | 47 // NotificationObserver |
| 40 virtual void Observe(NotificationType type, | 48 virtual void Observe(NotificationType type, |
| 41 const NotificationSource& source, | 49 const NotificationSource& source, |
| 42 const NotificationDetails& details); | 50 const NotificationDetails& details); |
| 43 | 51 |
| 44 // Populate a dictionary with the information from an extension. | |
| 45 static void CreateAppInfo(const Extension* extension, | |
| 46 ExtensionPrefs* extension_prefs, | |
| 47 DictionaryValue* value); | |
| 48 | |
| 49 // Populate the given dictionary with all installed app info. | 52 // Populate the given dictionary with all installed app info. |
| 50 void FillAppDictionary(DictionaryValue* value); | 53 void FillAppDictionary(DictionaryValue* value); |
| 51 | 54 |
| 52 // Callback for the "getApps" message. | 55 // Callback for the "getApps" message. |
| 53 void HandleGetApps(const ListValue* args); | 56 void HandleGetApps(const ListValue* args); |
| 54 | 57 |
| 55 // Callback for the "launchApp" message. | 58 // Callback for the "launchApp" message. |
| 56 void HandleLaunchApp(const ListValue* args); | 59 void HandleLaunchApp(const ListValue* args); |
| 57 | 60 |
| 58 // Callback for the "setLaunchType" message. | 61 // Callback for the "setLaunchType" message. |
| 59 void HandleSetLaunchType(const ListValue* args); | 62 void HandleSetLaunchType(const ListValue* args); |
| 60 | 63 |
| 61 // Callback for the "uninstallApp" message. | 64 // Callback for the "uninstallApp" message. |
| 62 void HandleUninstallApp(const ListValue* args); | 65 void HandleUninstallApp(const ListValue* args); |
| 63 | 66 |
| 64 // Callback for the "hideAppPromo" message. | 67 // Callback for the "hideAppPromo" message. |
| 65 void HandleHideAppsPromo(const ListValue* args); | 68 void HandleHideAppsPromo(const ListValue* args); |
| 66 | 69 |
| 67 private: | 70 private: |
| 71 // Records a web store launch in the appropriate histograms. |promo_active| |
| 72 // specifies if the web store promotion was active. |
| 73 static void RecordWebStoreLaunch(bool promo_active); |
| 74 |
| 75 // Records an app launch in the appropriate histograms. |promo_active| |
| 76 // specifies if the web store promotion was active. |
| 77 static void RecordAppLaunch(bool promo_active); |
| 78 |
| 68 // ExtensionInstallUI::Delegate implementation, used for receiving | 79 // ExtensionInstallUI::Delegate implementation, used for receiving |
| 69 // notification about uninstall confirmation dialog selections. | 80 // notification about uninstall confirmation dialog selections. |
| 70 virtual void InstallUIProceed(); | 81 virtual void InstallUIProceed(); |
| 71 virtual void InstallUIAbort(); | 82 virtual void InstallUIAbort(); |
| 72 | 83 |
| 73 // Returns the ExtensionInstallUI object for this class, creating it if | 84 // Returns the ExtensionInstallUI object for this class, creating it if |
| 74 // needed. | 85 // needed. |
| 75 ExtensionInstallUI* GetExtensionInstallUI(); | 86 ExtensionInstallUI* GetExtensionInstallUI(); |
| 76 | 87 |
| 77 // Starts the animation of the app icon. | 88 // Starts the animation of the app icon. |
| 78 void AnimateAppIcon(const Extension* extension, const gfx::Rect& rect); | 89 void AnimateAppIcon(const Extension* extension, const gfx::Rect& rect); |
| 79 | 90 |
| 80 // The apps are represented in the extensions model. | 91 // The apps are represented in the extensions model. |
| 81 scoped_refptr<ExtensionsService> extensions_service_; | 92 scoped_refptr<ExtensionsService> extensions_service_; |
| 82 | 93 |
| 83 // We monitor changes to the extension system so that we can reload the apps | 94 // We monitor changes to the extension system so that we can reload the apps |
| 84 // when necessary. | 95 // when necessary. |
| 85 NotificationRegistrar registrar_; | 96 NotificationRegistrar registrar_; |
| 86 | 97 |
| 87 // Monitor extension preference changes so that the DOM UI can be notified. | 98 // Monitor extension preference changes so that the DOM UI can be notified. |
| 88 PrefChangeRegistrar pref_change_registrar_; | 99 PrefChangeRegistrar pref_change_registrar_; |
| 89 | 100 |
| 90 // Used to show confirmation UI for uninstalling/enabling extensions in | 101 // Used to show confirmation UI for uninstalling/enabling extensions in |
| 91 // incognito mode. | 102 // incognito mode. |
| 92 scoped_ptr<ExtensionInstallUI> install_ui_; | 103 scoped_ptr<ExtensionInstallUI> install_ui_; |
| 93 | 104 |
| 94 // The id of the extension we are prompting the user about. | 105 // The id of the extension we are prompting the user about. |
| 95 std::string extension_id_prompting_; | 106 std::string extension_id_prompting_; |
| 96 | 107 |
| 108 // Whether the promo is currently being shown. |
| 109 bool promo_active_; |
| 110 |
| 97 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 111 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
| 98 }; | 112 }; |
| 99 | 113 |
| 100 #endif // CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ | 114 #endif // CHROME_BROWSER_DOM_UI_APP_LAUNCHER_HANDLER_H_ |
| OLD | NEW |