OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/task/cancelable_task_tracker.h" |
9 #include "chrome/browser/extensions/chrome_extension_function.h" | 10 #include "chrome/browser/extensions/chrome_extension_function.h" |
10 #include "chrome/browser/extensions/extension_install_prompt.h" | 11 #include "chrome/browser/extensions/extension_install_prompt.h" |
11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 12 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 13 #include "components/favicon_base/favicon_types.h" |
12 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
13 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
14 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
15 #include "extensions/browser/browser_context_keyed_api_factory.h" | 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
16 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
17 | 19 |
18 class ExtensionService; | 20 class ExtensionService; |
19 class ExtensionUninstallDialog; | 21 class ExtensionUninstallDialog; |
20 | 22 |
21 namespace extensions { | 23 namespace extensions { |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 void OnCloseShortcutPrompt(bool created); | 184 void OnCloseShortcutPrompt(bool created); |
183 | 185 |
184 static void SetAutoConfirmForTest(bool should_proceed); | 186 static void SetAutoConfirmForTest(bool should_proceed); |
185 | 187 |
186 protected: | 188 protected: |
187 virtual ~ManagementCreateAppShortcutFunction(); | 189 virtual ~ManagementCreateAppShortcutFunction(); |
188 | 190 |
189 virtual bool RunAsync() OVERRIDE; | 191 virtual bool RunAsync() OVERRIDE; |
190 }; | 192 }; |
191 | 193 |
| 194 class ManagementGenerateAppForLinkFunction : public AsyncManagementFunction, |
| 195 public content::NotificationObserver { |
| 196 public: |
| 197 DECLARE_EXTENSION_FUNCTION("management.generateAppForLink", |
| 198 MANAGEMENT_GENERATEAPPFORLINK); |
| 199 |
| 200 ManagementGenerateAppForLinkFunction(); |
| 201 |
| 202 protected: |
| 203 virtual ~ManagementGenerateAppForLinkFunction(); |
| 204 |
| 205 virtual bool RunAsync() OVERRIDE; |
| 206 |
| 207 private: |
| 208 struct AppInstallInfo { |
| 209 AppInstallInfo() {} |
| 210 ~AppInstallInfo() {} |
| 211 |
| 212 std::string title; |
| 213 GURL launch_url; |
| 214 }; |
| 215 |
| 216 void OnFaviconForApp(const favicon_base::FaviconImageResult& image_result); |
| 217 |
| 218 scoped_ptr<AppInstallInfo> install_info_; |
| 219 |
| 220 // Used for favicon loading tasks. |
| 221 base::CancelableTaskTracker cancelable_task_tracker_; |
| 222 |
| 223 // Overridden from content::NotificationObserver: |
| 224 virtual void Observe(int type, |
| 225 const content::NotificationSource& source, |
| 226 const content::NotificationDetails& details) OVERRIDE; |
| 227 |
| 228 content::NotificationRegistrar registrar_; |
| 229 }; |
| 230 |
192 class ManagementEventRouter : public content::NotificationObserver { | 231 class ManagementEventRouter : public content::NotificationObserver { |
193 public: | 232 public: |
194 explicit ManagementEventRouter(Profile* profile); | 233 explicit ManagementEventRouter(Profile* profile); |
195 virtual ~ManagementEventRouter(); | 234 virtual ~ManagementEventRouter(); |
196 | 235 |
197 private: | 236 private: |
198 // content::NotificationObserver implementation. | 237 // content::NotificationObserver implementation. |
199 virtual void Observe(int type, | 238 virtual void Observe(int type, |
200 const content::NotificationSource& source, | 239 const content::NotificationSource& source, |
201 const content::NotificationDetails& details) OVERRIDE; | 240 const content::NotificationDetails& details) OVERRIDE; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 | 275 |
237 // Created lazily upon OnListenerAdded. | 276 // Created lazily upon OnListenerAdded. |
238 scoped_ptr<ManagementEventRouter> management_event_router_; | 277 scoped_ptr<ManagementEventRouter> management_event_router_; |
239 | 278 |
240 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 279 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
241 }; | 280 }; |
242 | 281 |
243 } // namespace extensions | 282 } // namespace extensions |
244 | 283 |
245 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 284 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
OLD | NEW |