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 public ExtensionInstallUI::Delegate, | 34 public ExtensionInstallUI::Delegate, |
35 public NotificationObserver { | 35 public NotificationObserver { |
36 public: | 36 public: |
37 explicit AppLauncherHandler(ExtensionService* extension_service); | 37 explicit AppLauncherHandler(ExtensionService* extension_service); |
38 virtual ~AppLauncherHandler(); | 38 virtual ~AppLauncherHandler(); |
39 | 39 |
40 // Populate a dictionary with the information from an extension. | 40 // Populate a dictionary with the information from an extension. |
41 static void CreateAppInfo(const Extension* extension, | 41 static void CreateAppInfo(const Extension* extension, |
42 const AppNotification* notification, | 42 const AppNotification* notification, |
43 ExtensionService* service, | 43 ExtensionService* service, |
44 DictionaryValue* value); | 44 base::DictionaryValue* value); |
45 | 45 |
46 // Callback for pings related to launching apps on the NTP. | 46 // Callback for pings related to launching apps on the NTP. |
47 static bool HandlePing(Profile* profile, const std::string& path); | 47 static bool HandlePing(Profile* profile, const std::string& path); |
48 | 48 |
49 // WebUIMessageHandler implementation. | 49 // WebUIMessageHandler implementation. |
50 virtual WebUIMessageHandler* Attach(WebUI* web_ui); | 50 virtual WebUIMessageHandler* Attach(WebUI* web_ui); |
51 virtual void RegisterMessages(); | 51 virtual void RegisterMessages(); |
52 | 52 |
53 // NotificationObserver | 53 // NotificationObserver |
54 virtual void Observe(int type, | 54 virtual void Observe(int type, |
55 const NotificationSource& source, | 55 const NotificationSource& source, |
56 const NotificationDetails& details); | 56 const NotificationDetails& details); |
57 | 57 |
58 // Populate the given dictionary with all installed app info. | 58 // Populate the given dictionary with all installed app info. |
59 void FillAppDictionary(DictionaryValue* value); | 59 void FillAppDictionary(base::DictionaryValue* value); |
60 | 60 |
61 // Create a dictionary value for the given extension. May return NULL, e.g. if | 61 // Create a dictionary value for the given extension. May return NULL, e.g. if |
62 // the given extension is not an app. If non-NULL, the caller assumes | 62 // the given extension is not an app. If non-NULL, the caller assumes |
63 // ownership of the pointer. | 63 // ownership of the pointer. |
64 DictionaryValue* GetAppInfo(const Extension* extension); | 64 base::DictionaryValue* GetAppInfo(const Extension* extension); |
65 | 65 |
66 // Populate the given dictionary with the web store promo content. | 66 // Populate the given dictionary with the web store promo content. |
67 void FillPromoDictionary(DictionaryValue* value); | 67 void FillPromoDictionary(base::DictionaryValue* value); |
68 | 68 |
69 // Callback for the "getApps" message. | 69 // Callback for the "getApps" message. |
70 void HandleGetApps(const ListValue* args); | 70 void HandleGetApps(const base::ListValue* args); |
71 | 71 |
72 // Callback for the "launchApp" message. | 72 // Callback for the "launchApp" message. |
73 void HandleLaunchApp(const ListValue* args); | 73 void HandleLaunchApp(const base::ListValue* args); |
74 | 74 |
75 // Callback for the "setLaunchType" message. | 75 // Callback for the "setLaunchType" message. |
76 void HandleSetLaunchType(const ListValue* args); | 76 void HandleSetLaunchType(const base::ListValue* args); |
77 | 77 |
78 // Callback for the "uninstallApp" message. | 78 // Callback for the "uninstallApp" message. |
79 void HandleUninstallApp(const ListValue* args); | 79 void HandleUninstallApp(const base::ListValue* args); |
80 | 80 |
81 // Callback for the "hideAppPromo" message. | 81 // Callback for the "hideAppPromo" message. |
82 void HandleHideAppsPromo(const ListValue* args); | 82 void HandleHideAppsPromo(const base::ListValue* args); |
83 | 83 |
84 // Callback for the "createAppShortcut" message. | 84 // Callback for the "createAppShortcut" message. |
85 void HandleCreateAppShortcut(const ListValue* args); | 85 void HandleCreateAppShortcut(const base::ListValue* args); |
86 | 86 |
87 // Callback for the "reorderApps" message. | 87 // Callback for the "reorderApps" message. |
88 void HandleReorderApps(const ListValue* args); | 88 void HandleReorderApps(const base::ListValue* args); |
89 | 89 |
90 // Callback for the "setPageIndex" message. | 90 // Callback for the "setPageIndex" message. |
91 void HandleSetPageIndex(const ListValue* args); | 91 void HandleSetPageIndex(const base::ListValue* args); |
92 | 92 |
93 // Callback for the "promoSeen" message. | 93 // Callback for the "promoSeen" message. |
94 void HandlePromoSeen(const ListValue* args); | 94 void HandlePromoSeen(const base::ListValue* args); |
95 | 95 |
96 // Callback for the "saveAppPageName" message. | 96 // Callback for the "saveAppPageName" message. |
97 void HandleSaveAppPageName(const ListValue* args); | 97 void HandleSaveAppPageName(const base::ListValue* args); |
98 | 98 |
99 // Register app launcher preferences. | 99 // Register app launcher preferences. |
100 static void RegisterUserPrefs(PrefService* pref_service); | 100 static void RegisterUserPrefs(PrefService* pref_service); |
101 | 101 |
102 private: | 102 private: |
103 // Records a web store launch in the appropriate histograms. |promo_active| | 103 // Records a web store launch in the appropriate histograms. |promo_active| |
104 // specifies if the web store promotion was active. | 104 // specifies if the web store promotion was active. |
105 static void RecordWebStoreLaunch(bool promo_active); | 105 static void RecordWebStoreLaunch(bool promo_active); |
106 | 106 |
107 // Records an app launch in the corresponding |bucket| of the app launch | 107 // Records an app launch in the corresponding |bucket| of the app launch |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 bool promo_active_; | 161 bool promo_active_; |
162 | 162 |
163 // When true, we ignore changes to the underlying data rather than immediately | 163 // When true, we ignore changes to the underlying data rather than immediately |
164 // refreshing. This is useful when making many batch updates to avoid flicker. | 164 // refreshing. This is useful when making many batch updates to avoid flicker. |
165 bool ignore_changes_; | 165 bool ignore_changes_; |
166 | 166 |
167 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 167 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
168 }; | 168 }; |
169 | 169 |
170 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ | 170 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ |
OLD | NEW |