| 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 CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_vector.h" |
| 8 #include "extensions/browser/extension_system.h" | 9 #include "extensions/browser/extension_system.h" |
| 9 #include "extensions/common/one_shot_event.h" | 10 #include "extensions/common/one_shot_event.h" |
| 10 | 11 |
| 11 class Profile; | 12 class Profile; |
| 12 | 13 |
| 13 namespace extensions { | 14 namespace extensions { |
| 14 | 15 |
| 15 class ContentVerifier; | 16 class ContentVerifier; |
| 17 class DeclarativeUserScriptMaster; |
| 16 class ExtensionSystemSharedFactory; | 18 class ExtensionSystemSharedFactory; |
| 17 class ExtensionWarningBadgeService; | 19 class ExtensionWarningBadgeService; |
| 18 class NavigationObserver; | 20 class NavigationObserver; |
| 21 class SharedUserScriptMaster; |
| 19 class StandardManagementPolicyProvider; | 22 class StandardManagementPolicyProvider; |
| 20 class StateStoreNotificationObserver; | 23 class StateStoreNotificationObserver; |
| 21 | 24 |
| 22 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. | 25 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl. |
| 23 // Implementation details: non-shared services are owned by | 26 // Implementation details: non-shared services are owned by |
| 24 // ExtensionSystemImpl, a KeyedService with separate incognito | 27 // ExtensionSystemImpl, a KeyedService with separate incognito |
| 25 // instances. A private Shared class (also a KeyedService, | 28 // instances. A private Shared class (also a KeyedService, |
| 26 // but with a shared instance for incognito) keeps the common services. | 29 // but with a shared instance for incognito) keeps the common services. |
| 27 class ExtensionSystemImpl : public ExtensionSystem { | 30 class ExtensionSystemImpl : public ExtensionSystem { |
| 28 public: | 31 public: |
| 29 explicit ExtensionSystemImpl(Profile* profile); | 32 explicit ExtensionSystemImpl(Profile* profile); |
| 30 virtual ~ExtensionSystemImpl(); | 33 virtual ~ExtensionSystemImpl(); |
| 31 | 34 |
| 32 // KeyedService implementation. | 35 // KeyedService implementation. |
| 33 virtual void Shutdown() OVERRIDE; | 36 virtual void Shutdown() OVERRIDE; |
| 34 | 37 |
| 35 virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE; | 38 virtual void InitForRegularProfile(bool extensions_enabled) OVERRIDE; |
| 36 | 39 |
| 37 virtual ExtensionService* extension_service() OVERRIDE; // shared | 40 virtual ExtensionService* extension_service() OVERRIDE; // shared |
| 38 virtual RuntimeData* runtime_data() OVERRIDE; // shared | 41 virtual RuntimeData* runtime_data() OVERRIDE; // shared |
| 39 virtual ManagementPolicy* management_policy() OVERRIDE; // shared | 42 virtual ManagementPolicy* management_policy() OVERRIDE; // shared |
| 40 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared | 43 // shared |
| 44 virtual SharedUserScriptMaster* shared_user_script_master() OVERRIDE; |
| 41 virtual ProcessManager* process_manager() OVERRIDE; | 45 virtual ProcessManager* process_manager() OVERRIDE; |
| 42 virtual StateStore* state_store() OVERRIDE; // shared | 46 virtual StateStore* state_store() OVERRIDE; // shared |
| 43 virtual StateStore* rules_store() OVERRIDE; // shared | 47 virtual StateStore* rules_store() OVERRIDE; // shared |
| 44 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() | 48 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() |
| 45 OVERRIDE; // shared | 49 OVERRIDE; // shared |
| 46 virtual InfoMap* info_map() OVERRIDE; // shared | 50 virtual InfoMap* info_map() OVERRIDE; // shared |
| 47 virtual EventRouter* event_router() OVERRIDE; // shared | 51 virtual EventRouter* event_router() OVERRIDE; // shared |
| 48 virtual ExtensionWarningService* warning_service() OVERRIDE; | 52 virtual ExtensionWarningService* warning_service() OVERRIDE; |
| 49 virtual Blacklist* blacklist() OVERRIDE; // shared | 53 virtual Blacklist* blacklist() OVERRIDE; // shared |
| 50 virtual ErrorConsole* error_console() OVERRIDE; | 54 virtual ErrorConsole* error_console() OVERRIDE; |
| 51 virtual InstallVerifier* install_verifier() OVERRIDE; | 55 virtual InstallVerifier* install_verifier() OVERRIDE; |
| 52 virtual QuotaService* quota_service() OVERRIDE; // shared | 56 virtual QuotaService* quota_service() OVERRIDE; // shared |
| 53 | 57 |
| 54 virtual void RegisterExtensionWithRequestContexts( | 58 virtual void RegisterExtensionWithRequestContexts( |
| 55 const Extension* extension) OVERRIDE; | 59 const Extension* extension) OVERRIDE; |
| 56 | 60 |
| 57 virtual void UnregisterExtensionWithRequestContexts( | 61 virtual void UnregisterExtensionWithRequestContexts( |
| 58 const std::string& extension_id, | 62 const std::string& extension_id, |
| 59 const UnloadedExtensionInfo::Reason reason) OVERRIDE; | 63 const UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 60 | 64 |
| 61 virtual const OneShotEvent& ready() const OVERRIDE; | 65 virtual const OneShotEvent& ready() const OVERRIDE; |
| 62 virtual ContentVerifier* content_verifier() OVERRIDE; // shared | 66 virtual ContentVerifier* content_verifier() OVERRIDE; // shared |
| 63 virtual scoped_ptr<ExtensionSet> GetDependentExtensions( | 67 virtual scoped_ptr<ExtensionSet> GetDependentExtensions( |
| 64 const Extension* extension) OVERRIDE; | 68 const Extension* extension) OVERRIDE; |
| 65 | 69 |
| 70 virtual DeclarativeUserScriptMaster* |
| 71 GetDeclarativeUserScriptMasterByExtension( |
| 72 const ExtensionId& extension_id) OVERRIDE; // shared |
| 73 |
| 66 private: | 74 private: |
| 67 friend class ExtensionSystemSharedFactory; | 75 friend class ExtensionSystemSharedFactory; |
| 68 | 76 |
| 69 // Owns the Extension-related systems that have a single instance | 77 // Owns the Extension-related systems that have a single instance |
| 70 // shared between normal and incognito profiles. | 78 // shared between normal and incognito profiles. |
| 71 class Shared : public KeyedService { | 79 class Shared : public KeyedService { |
| 72 public: | 80 public: |
| 73 explicit Shared(Profile* profile); | 81 explicit Shared(Profile* profile); |
| 74 virtual ~Shared(); | 82 virtual ~Shared(); |
| 75 | 83 |
| 76 // Initialization takes place in phases. | 84 // Initialization takes place in phases. |
| 77 virtual void InitPrefs(); | 85 virtual void InitPrefs(); |
| 78 // This must not be called until all the providers have been created. | 86 // This must not be called until all the providers have been created. |
| 79 void RegisterManagementPolicyProviders(); | 87 void RegisterManagementPolicyProviders(); |
| 80 void Init(bool extensions_enabled); | 88 void Init(bool extensions_enabled); |
| 81 | 89 |
| 82 // KeyedService implementation. | 90 // KeyedService implementation. |
| 83 virtual void Shutdown() OVERRIDE; | 91 virtual void Shutdown() OVERRIDE; |
| 84 | 92 |
| 85 StateStore* state_store(); | 93 StateStore* state_store(); |
| 86 StateStore* rules_store(); | 94 StateStore* rules_store(); |
| 87 ExtensionService* extension_service(); | 95 ExtensionService* extension_service(); |
| 88 RuntimeData* runtime_data(); | 96 RuntimeData* runtime_data(); |
| 89 ManagementPolicy* management_policy(); | 97 ManagementPolicy* management_policy(); |
| 90 UserScriptMaster* user_script_master(); | 98 SharedUserScriptMaster* shared_user_script_master(); |
| 91 Blacklist* blacklist(); | 99 Blacklist* blacklist(); |
| 92 InfoMap* info_map(); | 100 InfoMap* info_map(); |
| 93 LazyBackgroundTaskQueue* lazy_background_task_queue(); | 101 LazyBackgroundTaskQueue* lazy_background_task_queue(); |
| 94 EventRouter* event_router(); | 102 EventRouter* event_router(); |
| 95 ExtensionWarningService* warning_service(); | 103 ExtensionWarningService* warning_service(); |
| 96 ErrorConsole* error_console(); | 104 ErrorConsole* error_console(); |
| 97 InstallVerifier* install_verifier(); | 105 InstallVerifier* install_verifier(); |
| 98 QuotaService* quota_service(); | 106 QuotaService* quota_service(); |
| 99 const OneShotEvent& ready() const { return ready_; } | 107 const OneShotEvent& ready() const { return ready_; } |
| 100 ContentVerifier* content_verifier(); | 108 ContentVerifier* content_verifier(); |
| 101 | 109 |
| 110 DeclarativeUserScriptMaster* GetDeclarativeUserScriptMasterByExtension( |
| 111 const ExtensionId& extension_id); |
| 112 |
| 102 private: | 113 private: |
| 103 Profile* profile_; | 114 Profile* profile_; |
| 104 | 115 |
| 105 // The services that are shared between normal and incognito profiles. | 116 // The services that are shared between normal and incognito profiles. |
| 106 | 117 |
| 107 scoped_ptr<StateStore> state_store_; | 118 scoped_ptr<StateStore> state_store_; |
| 108 scoped_ptr<StateStoreNotificationObserver> | 119 scoped_ptr<StateStoreNotificationObserver> |
| 109 state_store_notification_observer_; | 120 state_store_notification_observer_; |
| 110 scoped_ptr<StateStore> rules_store_; | 121 scoped_ptr<StateStore> rules_store_; |
| 111 // LazyBackgroundTaskQueue is a dependency of | 122 // LazyBackgroundTaskQueue is a dependency of |
| 112 // MessageService and EventRouter. | 123 // MessageService and EventRouter. |
| 113 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; | 124 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_; |
| 114 scoped_ptr<EventRouter> event_router_; | 125 scoped_ptr<EventRouter> event_router_; |
| 115 scoped_ptr<NavigationObserver> navigation_observer_; | 126 scoped_ptr<NavigationObserver> navigation_observer_; |
| 116 scoped_ptr<UserScriptMaster> user_script_master_; | 127 // Shared memory region manager for scripts statically declared in extension |
| 128 // manifests. This region is shared between all extensions. |
| 129 scoped_ptr<SharedUserScriptMaster> shared_user_script_master_; |
| 130 // Shared memory region manager for programmatically declared scripts, one |
| 131 // per extension. Managers are instantiated the first time the declarative |
| 132 // API is used by an extension to request content scripts. |
| 133 ScopedVector<DeclarativeUserScriptMaster> declarative_user_script_masters_; |
| 117 scoped_ptr<Blacklist> blacklist_; | 134 scoped_ptr<Blacklist> blacklist_; |
| 118 // StandardManagementPolicyProvider depends on Blacklist. | 135 // StandardManagementPolicyProvider depends on Blacklist. |
| 119 scoped_ptr<StandardManagementPolicyProvider> | 136 scoped_ptr<StandardManagementPolicyProvider> |
| 120 standard_management_policy_provider_; | 137 standard_management_policy_provider_; |
| 121 scoped_ptr<RuntimeData> runtime_data_; | 138 scoped_ptr<RuntimeData> runtime_data_; |
| 122 // ExtensionService depends on StateStore, Blacklist and RuntimeData. | 139 // ExtensionService depends on StateStore, Blacklist and RuntimeData. |
| 123 scoped_ptr<ExtensionService> extension_service_; | 140 scoped_ptr<ExtensionService> extension_service_; |
| 124 scoped_ptr<ManagementPolicy> management_policy_; | 141 scoped_ptr<ManagementPolicy> management_policy_; |
| 125 // extension_info_map_ needs to outlive process_manager_. | 142 // extension_info_map_ needs to outlive process_manager_. |
| 126 scoped_refptr<InfoMap> extension_info_map_; | 143 scoped_refptr<InfoMap> extension_info_map_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 150 // extension processes and those require access to the ResourceContext owned | 167 // extension processes and those require access to the ResourceContext owned |
| 151 // by |io_data_|. | 168 // by |io_data_|. |
| 152 scoped_ptr<ProcessManager> process_manager_; | 169 scoped_ptr<ProcessManager> process_manager_; |
| 153 | 170 |
| 154 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 171 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
| 155 }; | 172 }; |
| 156 | 173 |
| 157 } // namespace extensions | 174 } // namespace extensions |
| 158 | 175 |
| 159 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ | 176 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_ |
| OLD | NEW |