Chromium Code Reviews| 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/scoped_observer.h" | |
| 9 #include "base/task/cancelable_task_tracker.h" | 10 #include "base/task/cancelable_task_tracker.h" |
| 10 #include "chrome/browser/extensions/bookmark_app_helper.h" | 11 #include "chrome/browser/extensions/bookmark_app_helper.h" |
| 11 #include "chrome/browser/extensions/chrome_extension_function.h" | 12 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 12 #include "chrome/browser/extensions/extension_install_prompt.h" | 13 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 13 #include "chrome/browser/extensions/extension_uninstall_dialog.h" | 14 #include "chrome/browser/extensions/extension_uninstall_dialog.h" |
| 14 #include "chrome/common/web_application_info.h" | 15 #include "chrome/common/web_application_info.h" |
| 15 #include "components/favicon_base/favicon_types.h" | 16 #include "components/favicon_base/favicon_types.h" |
| 16 #include "components/keyed_service/core/keyed_service.h" | 17 #include "components/keyed_service/core/keyed_service.h" |
| 17 #include "content/public/browser/notification_observer.h" | |
| 18 #include "content/public/browser/notification_registrar.h" | |
| 19 #include "extensions/browser/browser_context_keyed_api_factory.h" | 18 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 20 #include "extensions/browser/event_router.h" | 19 #include "extensions/browser/event_router.h" |
| 20 #include "extensions/browser/extension_registry_observer.h" | |
| 21 | 21 |
| 22 class ExtensionService; | 22 class ExtensionService; |
| 23 class ExtensionUninstallDialog; | 23 class ExtensionUninstallDialog; |
| 24 | 24 |
| 25 namespace extensions { | 25 namespace extensions { |
| 26 class ExtensionRegistry; | |
| 26 | 27 |
| 27 class ManagementFunction : public ChromeSyncExtensionFunction { | 28 class ManagementFunction : public ChromeSyncExtensionFunction { |
| 28 protected: | 29 protected: |
| 29 virtual ~ManagementFunction() {} | 30 virtual ~ManagementFunction() {} |
| 30 | 31 |
| 31 ExtensionService* service(); | 32 ExtensionService* service(); |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 class AsyncManagementFunction : public ChromeAsyncExtensionFunction { | 35 class AsyncManagementFunction : public ChromeAsyncExtensionFunction { |
| 35 protected: | 36 protected: |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 223 | 224 |
| 224 std::string title_; | 225 std::string title_; |
| 225 GURL launch_url_; | 226 GURL launch_url_; |
| 226 | 227 |
| 227 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_; | 228 scoped_ptr<BookmarkAppHelper> bookmark_app_helper_; |
| 228 | 229 |
| 229 // Used for favicon loading tasks. | 230 // Used for favicon loading tasks. |
| 230 base::CancelableTaskTracker cancelable_task_tracker_; | 231 base::CancelableTaskTracker cancelable_task_tracker_; |
| 231 }; | 232 }; |
| 232 | 233 |
| 233 class ManagementEventRouter : public content::NotificationObserver { | 234 class ManagementEventRouter : public ExtensionRegistryObserver { |
| 234 public: | 235 public: |
| 235 explicit ManagementEventRouter(Profile* profile); | 236 explicit ManagementEventRouter(content::BrowserContext* context); |
| 236 virtual ~ManagementEventRouter(); | 237 virtual ~ManagementEventRouter(); |
| 237 | 238 |
| 238 private: | 239 private: |
| 239 // content::NotificationObserver implementation. | 240 virtual void OnExtensionLoaded(content::BrowserContext* browser_context, |
| 240 virtual void Observe(int type, | 241 const Extension* extension) OVERRIDE; |
| 241 const content::NotificationSource& source, | 242 virtual void OnExtensionUnloaded( |
| 242 const content::NotificationDetails& details) OVERRIDE; | 243 content::BrowserContext* browser_context, |
| 244 const Extension* extension, | |
| 245 UnloadedExtensionInfo::Reason reason) OVERRIDE; | |
| 246 virtual void OnExtensionWillBeInstalled( | |
|
Devlin
2014/06/17 16:28:31
For what this is doing, I think maybe OnExtensionI
limasdf
2014/06/17 18:25:48
Done.
Yep, Perhaps, There must be many other place
| |
| 247 content::BrowserContext* browser_context, | |
| 248 const Extension* extension, | |
| 249 bool is_update, | |
| 250 bool from_ephemeral, | |
| 251 const std::string& old_name) OVERRIDE; | |
| 252 virtual void OnExtensionUninstalled(content::BrowserContext* browser_context, | |
| 253 const Extension* extension) OVERRIDE; | |
| 243 | 254 |
| 244 content::NotificationRegistrar registrar_; | 255 content::BrowserContext* browser_context_; |
| 245 | 256 |
| 246 Profile* profile_; | 257 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 258 extension_registry_observer_; | |
| 247 | 259 |
| 248 DISALLOW_COPY_AND_ASSIGN(ManagementEventRouter); | 260 DISALLOW_COPY_AND_ASSIGN(ManagementEventRouter); |
| 249 }; | 261 }; |
| 250 | 262 |
| 251 class ManagementAPI : public BrowserContextKeyedAPI, | 263 class ManagementAPI : public BrowserContextKeyedAPI, |
| 252 public extensions::EventRouter::Observer { | 264 public extensions::EventRouter::Observer { |
| 253 public: | 265 public: |
| 254 explicit ManagementAPI(content::BrowserContext* context); | 266 explicit ManagementAPI(content::BrowserContext* context); |
| 255 virtual ~ManagementAPI(); | 267 virtual ~ManagementAPI(); |
| 256 | 268 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 277 | 289 |
| 278 // Created lazily upon OnListenerAdded. | 290 // Created lazily upon OnListenerAdded. |
| 279 scoped_ptr<ManagementEventRouter> management_event_router_; | 291 scoped_ptr<ManagementEventRouter> management_event_router_; |
| 280 | 292 |
| 281 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); | 293 DISALLOW_COPY_AND_ASSIGN(ManagementAPI); |
| 282 }; | 294 }; |
| 283 | 295 |
| 284 } // namespace extensions | 296 } // namespace extensions |
| 285 | 297 |
| 286 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ | 298 #endif // CHROME_BROWSER_EXTENSIONS_API_MANAGEMENT_MANAGEMENT_API_H_ |
| OLD | NEW |