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