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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 void FillAppDictionary(base::DictionaryValue* value); | 58 void FillAppDictionary(base::DictionaryValue* value); |
59 | 59 |
60 // Create a dictionary value for the given extension. May return NULL, e.g. if | 60 // Create a dictionary value for the given extension. May return NULL, e.g. if |
61 // the given extension is not an app. If non-NULL, the caller assumes | 61 // the given extension is not an app. If non-NULL, the caller assumes |
62 // ownership of the pointer. | 62 // ownership of the pointer. |
63 base::DictionaryValue* GetAppInfo(const Extension* extension); | 63 base::DictionaryValue* GetAppInfo(const Extension* extension); |
64 | 64 |
65 // Populate the given dictionary with the web store promo content. | 65 // Populate the given dictionary with the web store promo content. |
66 void FillPromoDictionary(base::DictionaryValue* value); | 66 void FillPromoDictionary(base::DictionaryValue* value); |
67 | 67 |
68 // Callback for the "deleteAppsPage" message. Takes a page index as the first | |
69 // and only argument. | |
70 void HandleDeleteAppsPage(const base::ListValue* args); | |
71 | |
68 // Callback for the "getApps" message. | 72 // Callback for the "getApps" message. |
69 void HandleGetApps(const base::ListValue* args); | 73 void HandleGetApps(const base::ListValue* args); |
70 | 74 |
71 // Callback for the "launchApp" message. | 75 // Callback for the "launchApp" message. |
72 void HandleLaunchApp(const base::ListValue* args); | 76 void HandleLaunchApp(const base::ListValue* args); |
73 | 77 |
74 // Callback for the "setLaunchType" message. | 78 // Callback for the "setLaunchType" message. |
75 void HandleSetLaunchType(const base::ListValue* args); | 79 void HandleSetLaunchType(const base::ListValue* args); |
76 | 80 |
77 // Callback for the "uninstallApp" message. | 81 // Callback for the "uninstallApp" message. |
78 void HandleUninstallApp(const base::ListValue* args); | 82 void HandleUninstallApp(const base::ListValue* args); |
79 | 83 |
80 // Callback for the "hideAppPromo" message. | 84 // Callback for the "hideAppPromo" message. |
81 void HandleHideAppsPromo(const base::ListValue* args); | 85 void HandleHideAppsPromo(const base::ListValue* args); |
82 | 86 |
83 // Callback for the "createAppShortcut" message. | 87 // Callback for the "createAppShortcut" message. |
84 void HandleCreateAppShortcut(const base::ListValue* args); | 88 void HandleCreateAppShortcut(const base::ListValue* args); |
85 | 89 |
86 // Callback for the "reorderApps" message. | 90 // Callback for the "reorderApps" message. |
87 void HandleReorderApps(const base::ListValue* args); | 91 void HandleReorderApps(const base::ListValue* args); |
88 | 92 |
89 // Callback for the "setPageIndex" message. | 93 // Callback for the "setPageIndex" message. |
90 void HandleSetPageIndex(const base::ListValue* args); | 94 void HandleSetPageIndex(const base::ListValue* args); |
91 | 95 |
92 // Callback for the "promoSeen" message. | 96 // Callback for the "promoSeen" message. |
93 void HandlePromoSeen(const base::ListValue* args); | 97 void HandlePromoSeen(const base::ListValue* args); |
94 | 98 |
95 // Callback for the "saveAppPageName" message. | 99 // Callback for the "saveAppPageName" message. |
csilv
2011/12/02 01:57:02
"saveAppsPageName" in comment
Dan Beam
2011/12/05 18:05:10
Done.
| |
96 void HandleSaveAppPageName(const base::ListValue* args); | 100 void HandleSaveAppsPageName(const base::ListValue* args); |
97 | 101 |
98 // Callback for the "generateAppForLink" message. | 102 // Callback for the "generateAppForLink" message. |
99 void HandleGenerateAppForLink(const base::ListValue* args); | 103 void HandleGenerateAppForLink(const base::ListValue* args); |
100 | 104 |
101 // Callback for the "recordAppLaunchByURL" message. Takes an escaped URL and a | 105 // Callback for the "recordAppLaunchByURL" message. Takes an escaped URL and a |
102 // launch source (integer), and if the URL represents an app, records the | 106 // launch source (integer), and if the URL represents an app, records the |
103 // action for UMA. | 107 // action for UMA. |
104 void HandleRecordAppLaunchByURL(const base::ListValue* args); | 108 void HandleRecordAppLaunchByURL(const base::ListValue* args); |
105 | 109 |
106 // Callback for "closeNotification" message. | 110 // Callback for "closeNotification" message. |
107 void HandleNotificationClose(const base::ListValue* args); | 111 void HandleNotificationClose(const base::ListValue* args); |
108 | 112 |
109 // Register app launcher preferences. | 113 // Register app launcher preferences. |
110 static void RegisterUserPrefs(PrefService* pref_service); | 114 static void RegisterUserPrefs(PrefService* pref_service); |
111 | 115 |
112 private: | 116 private: |
113 struct AppInstallInfo { | 117 struct AppInstallInfo { |
114 bool is_bookmark_app; | 118 bool is_bookmark_app; |
115 string16 title; | 119 string16 title; |
116 GURL app_url; | 120 GURL app_url; |
117 int page_index; | 121 int page_index; |
118 }; | 122 }; |
119 | 123 |
124 // Removes pages with no apps when loading from saved preferences. Does its | |
125 // best to avoid messing up save apps page names in the process. | |
126 void CondenseAppsPages(); | |
127 | |
128 // Deletes a range of empty apps pages. | |
129 void DeleteAppsPageRange(const size_t index, const size_t howmany); | |
130 | |
131 // Make sure that the app has a valid page index before we do anything with | |
132 // this data. | |
133 static void EnsureAppHasPageIndex(ExtensionService* service, | |
134 const std::string& id); | |
135 | |
136 // Return the number apps that have the given |page_index|. | |
137 int GetNumberOfAppsOnPage(const int page_index) const; | |
138 | |
120 // Records a web store launch in the appropriate histograms. |promo_active| | 139 // Records a web store launch in the appropriate histograms. |promo_active| |
121 // specifies if the web store promotion was active. | 140 // specifies if the web store promotion was active. |
122 static void RecordWebStoreLaunch(bool promo_active); | 141 static void RecordWebStoreLaunch(bool promo_active); |
123 | 142 |
124 // Records an app launch in the corresponding |bucket| of the app launch | 143 // Records an app launch in the corresponding |bucket| of the app launch |
125 // histogram. |promo_active| specifies if the web store promotion was active. | 144 // histogram. |promo_active| specifies if the web store promotion was active. |
126 static void RecordAppLaunchByID(extension_misc::AppLaunchBucket bucket); | 145 static void RecordAppLaunchByID(extension_misc::AppLaunchBucket bucket); |
127 | 146 |
128 // Records an app launch in the corresponding |bucket| of the app launch | 147 // Records an app launch in the corresponding |bucket| of the app launch |
129 // histogram if the |escaped_url| corresponds to an installed app. | 148 // histogram if the |escaped_url| corresponds to an installed app. |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
189 bool attempted_bookmark_app_install_; | 208 bool attempted_bookmark_app_install_; |
190 | 209 |
191 // True if we have executed HandleGetApps() at least once. | 210 // True if we have executed HandleGetApps() at least once. |
192 bool has_loaded_apps_; | 211 bool has_loaded_apps_; |
193 | 212 |
194 // The ID of the app to be highlighted on the NTP (i.e. shown on the page | 213 // The ID of the app to be highlighted on the NTP (i.e. shown on the page |
195 // and pulsed). This is done for new installs. The actual higlighting occurs | 214 // and pulsed). This is done for new installs. The actual higlighting occurs |
196 // when the app is added to the page (via getAppsCallback or appAdded). | 215 // when the app is added to the page (via getAppsCallback or appAdded). |
197 std::string highlight_app_id_; | 216 std::string highlight_app_id_; |
198 | 217 |
218 // Used to determine if the current instance of AppLauncherHandler called | |
219 // ExtensionUninstallAccepted(). If the current one was the one that called | |
220 // this, we use this value to animate the removal on the attached NTP. | |
221 bool uninstall_from_page_; | |
222 | |
199 // Hold state for favicon requests. | 223 // Hold state for favicon requests. |
200 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_; | 224 CancelableRequestConsumerTSimple<AppInstallInfo*> favicon_consumer_; |
201 | 225 |
202 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); | 226 DISALLOW_COPY_AND_ASSIGN(AppLauncherHandler); |
203 }; | 227 }; |
204 | 228 |
205 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ | 229 #endif // CHROME_BROWSER_UI_WEBUI_NTP_APP_LAUNCHER_HANDLER_H_ |
OLD | NEW |