| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ |
| 6 #define EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ | 6 #define EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/scoped_observer.h" | 10 #include "base/scoped_observer.h" |
| 11 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
| 12 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "extensions/browser/api/runtime/runtime_api_delegate.h" | 13 #include "extensions/browser/api/runtime/runtime_api_delegate.h" |
| 14 #include "extensions/browser/browser_context_keyed_api_factory.h" | 14 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 15 #include "extensions/browser/extension_function.h" | 15 #include "extensions/browser/extension_function.h" |
| 16 #include "extensions/browser/extension_registry_observer.h" | 16 #include "extensions/browser/extension_registry_observer.h" |
| 17 #include "extensions/browser/process_manager.h" |
| 17 #include "extensions/browser/process_manager_observer.h" | 18 #include "extensions/browser/process_manager_observer.h" |
| 18 #include "extensions/browser/update_observer.h" | 19 #include "extensions/browser/update_observer.h" |
| 19 #include "extensions/common/api/runtime.h" | 20 #include "extensions/common/api/runtime.h" |
| 20 | 21 |
| 21 namespace base { | 22 namespace base { |
| 22 class Version; | 23 class Version; |
| 23 } | 24 } |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 class BrowserContext; | 27 class BrowserContext; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 | 99 |
| 99 // True if we should dispatch the chrome.runtime.onInstalled event with | 100 // True if we should dispatch the chrome.runtime.onInstalled event with |
| 100 // reason "chrome_update" upon loading each extension. | 101 // reason "chrome_update" upon loading each extension. |
| 101 bool dispatch_chrome_updated_event_; | 102 bool dispatch_chrome_updated_event_; |
| 102 | 103 |
| 103 content::NotificationRegistrar registrar_; | 104 content::NotificationRegistrar registrar_; |
| 104 | 105 |
| 105 // Listen to extension notifications. | 106 // Listen to extension notifications. |
| 106 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 107 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
| 107 extension_registry_observer_; | 108 extension_registry_observer_; |
| 109 ScopedObserver<ProcessManager, ProcessManagerObserver> |
| 110 process_manager_observer_; |
| 108 | 111 |
| 109 DISALLOW_COPY_AND_ASSIGN(RuntimeAPI); | 112 DISALLOW_COPY_AND_ASSIGN(RuntimeAPI); |
| 110 }; | 113 }; |
| 111 | 114 |
| 115 template <> |
| 116 void BrowserContextKeyedAPIFactory<RuntimeAPI>::DeclareFactoryDependencies(); |
| 117 |
| 112 class RuntimeEventRouter { | 118 class RuntimeEventRouter { |
| 113 public: | 119 public: |
| 114 // Dispatches the onStartup event to all currently-loaded extensions. | 120 // Dispatches the onStartup event to all currently-loaded extensions. |
| 115 static void DispatchOnStartupEvent(content::BrowserContext* context, | 121 static void DispatchOnStartupEvent(content::BrowserContext* context, |
| 116 const std::string& extension_id); | 122 const std::string& extension_id); |
| 117 | 123 |
| 118 // Dispatches the onInstalled event to the given extension. | 124 // Dispatches the onInstalled event to the given extension. |
| 119 static void DispatchOnInstalledEvent(content::BrowserContext* context, | 125 static void DispatchOnInstalledEvent(content::BrowserContext* context, |
| 120 const std::string& extension_id, | 126 const std::string& extension_id, |
| 121 const base::Version& old_version, | 127 const base::Version& old_version, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 RUNTIME_GETPACKAGEDIRECTORYENTRY) | 219 RUNTIME_GETPACKAGEDIRECTORYENTRY) |
| 214 | 220 |
| 215 protected: | 221 protected: |
| 216 ~RuntimeGetPackageDirectoryEntryFunction() override {} | 222 ~RuntimeGetPackageDirectoryEntryFunction() override {} |
| 217 ResponseAction Run() override; | 223 ResponseAction Run() override; |
| 218 }; | 224 }; |
| 219 | 225 |
| 220 } // namespace extensions | 226 } // namespace extensions |
| 221 | 227 |
| 222 #endif // EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ | 228 #endif // EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_H_ |
| OLD | NEW |