| 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_EXTENSION_SYSTEM_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class ExtensionPrefs; | 21 class ExtensionPrefs; |
| 22 class ExtensionProcessManager; | 22 class ExtensionProcessManager; |
| 23 class ExtensionService; | 23 class ExtensionService; |
| 24 class Profile; | 24 class Profile; |
| 25 class UserScriptMaster; | 25 class UserScriptMaster; |
| 26 | 26 |
| 27 namespace extensions { | 27 namespace extensions { |
| 28 class AlarmManager; | 28 class AlarmManager; |
| 29 class Extension; | 29 class Extension; |
| 30 class LazyBackgroundTaskQueue; | 30 class LazyBackgroundTaskQueue; |
| 31 class ManagementPolicy; |
| 31 class RulesRegistryService; | 32 class RulesRegistryService; |
| 32 } | 33 } |
| 33 | 34 |
| 34 // The ExtensionSystem manages the creation and destruction of services | 35 // The ExtensionSystem manages the creation and destruction of services |
| 35 // related to extensions. Most objects are shared between normal | 36 // related to extensions. Most objects are shared between normal |
| 36 // and incognito Profiles, except as called out in comments. | 37 // and incognito Profiles, except as called out in comments. |
| 37 // This interface supports using TestExtensionSystem for TestingProfiles | 38 // This interface supports using TestExtensionSystem for TestingProfiles |
| 38 // that don't want all of the extensions baggage in their tests. | 39 // that don't want all of the extensions baggage in their tests. |
| 39 class ExtensionSystem : public ProfileKeyedService { | 40 class ExtensionSystem : public ProfileKeyedService { |
| 40 public: | 41 public: |
| 41 ExtensionSystem(); | 42 ExtensionSystem(); |
| 42 virtual ~ExtensionSystem(); | 43 virtual ~ExtensionSystem(); |
| 43 | 44 |
| 44 // Returns the instance for the given profile, or NULL if none. This is | 45 // Returns the instance for the given profile, or NULL if none. This is |
| 45 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. | 46 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. |
| 46 static ExtensionSystem* Get(Profile* profile); | 47 static ExtensionSystem* Get(Profile* profile); |
| 47 | 48 |
| 48 // ProfileKeyedService implementation. | 49 // ProfileKeyedService implementation. |
| 49 virtual void Shutdown() OVERRIDE {} | 50 virtual void Shutdown() OVERRIDE {} |
| 50 | 51 |
| 51 // Initializes extensions machinery. | 52 // Initializes extensions machinery. |
| 52 // Component extensions are always enabled, external and user extensions | 53 // Component extensions are always enabled, external and user extensions |
| 53 // are controlled by |extensions_enabled|. | 54 // are controlled by |extensions_enabled|. |
| 54 virtual void Init(bool extensions_enabled) = 0; | 55 virtual void Init(bool extensions_enabled) = 0; |
| 55 | 56 |
| 56 // The ExtensionService is created at startup. | 57 // The ExtensionService is created at startup. |
| 57 virtual ExtensionService* extension_service() = 0; | 58 virtual ExtensionService* extension_service() = 0; |
| 58 | 59 |
| 60 // The class controlling whether users are permitted to perform certain |
| 61 // actions on extensions (install, uninstall, disable, etc.). |
| 62 // The ManagementPolicy is created at startup. |
| 63 virtual extensions::ManagementPolicy* management_policy() = 0; |
| 64 |
| 59 // The ExtensionDevToolsManager is created at startup. | 65 // The ExtensionDevToolsManager is created at startup. |
| 60 virtual ExtensionDevToolsManager* devtools_manager() = 0; | 66 virtual ExtensionDevToolsManager* devtools_manager() = 0; |
| 61 | 67 |
| 62 // The UserScriptMaster is created at startup. | 68 // The UserScriptMaster is created at startup. |
| 63 virtual UserScriptMaster* user_script_master() = 0; | 69 virtual UserScriptMaster* user_script_master() = 0; |
| 64 | 70 |
| 65 // The ExtensionProcessManager is created at startup. | 71 // The ExtensionProcessManager is created at startup. |
| 66 virtual ExtensionProcessManager* process_manager() = 0; | 72 virtual ExtensionProcessManager* process_manager() = 0; |
| 67 | 73 |
| 68 // The AlarmManager is created at startup. | 74 // The AlarmManager is created at startup. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 public: | 114 public: |
| 109 explicit ExtensionSystemImpl(Profile* profile); | 115 explicit ExtensionSystemImpl(Profile* profile); |
| 110 virtual ~ExtensionSystemImpl(); | 116 virtual ~ExtensionSystemImpl(); |
| 111 | 117 |
| 112 // ProfileKeyedService implementation. | 118 // ProfileKeyedService implementation. |
| 113 virtual void Shutdown() OVERRIDE; | 119 virtual void Shutdown() OVERRIDE; |
| 114 | 120 |
| 115 virtual void Init(bool extensions_enabled) OVERRIDE; | 121 virtual void Init(bool extensions_enabled) OVERRIDE; |
| 116 | 122 |
| 117 virtual ExtensionService* extension_service() OVERRIDE; // shared | 123 virtual ExtensionService* extension_service() OVERRIDE; // shared |
| 124 virtual extensions::ManagementPolicy* management_policy() OVERRIDE; // shared |
| 118 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared | 125 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared |
| 119 virtual ExtensionDevToolsManager* devtools_manager() OVERRIDE; | 126 virtual ExtensionDevToolsManager* devtools_manager() OVERRIDE; |
| 120 virtual ExtensionProcessManager* process_manager() OVERRIDE; | 127 virtual ExtensionProcessManager* process_manager() OVERRIDE; |
| 121 virtual extensions::AlarmManager* alarm_manager() OVERRIDE; | 128 virtual extensions::AlarmManager* alarm_manager() OVERRIDE; |
| 122 virtual extensions::LazyBackgroundTaskQueue* lazy_background_task_queue() | 129 virtual extensions::LazyBackgroundTaskQueue* lazy_background_task_queue() |
| 123 OVERRIDE; // shared | 130 OVERRIDE; // shared |
| 124 virtual ExtensionInfoMap* info_map() OVERRIDE; // shared | 131 virtual ExtensionInfoMap* info_map() OVERRIDE; // shared |
| 125 virtual ExtensionMessageService* message_service() OVERRIDE; // shared | 132 virtual ExtensionMessageService* message_service() OVERRIDE; // shared |
| 126 virtual ExtensionEventRouter* event_router() OVERRIDE; // shared | 133 virtual ExtensionEventRouter* event_router() OVERRIDE; // shared |
| 127 // The RulesRegistryService is created at startup. | 134 // The RulesRegistryService is created at startup. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 140 | 147 |
| 141 // Owns the Extension-related systems that have a single instance | 148 // Owns the Extension-related systems that have a single instance |
| 142 // shared between normal and incognito profiles. | 149 // shared between normal and incognito profiles. |
| 143 class Shared : public ProfileKeyedService { | 150 class Shared : public ProfileKeyedService { |
| 144 public: | 151 public: |
| 145 explicit Shared(Profile* profile); | 152 explicit Shared(Profile* profile); |
| 146 virtual ~Shared(); | 153 virtual ~Shared(); |
| 147 | 154 |
| 148 // Initialization takes place in phases. | 155 // Initialization takes place in phases. |
| 149 virtual void InitPrefs(); | 156 virtual void InitPrefs(); |
| 157 // This must not be called until all the providers have been created. |
| 158 void RegisterManagementPolicyProviders(); |
| 150 void InitInfoMap(); | 159 void InitInfoMap(); |
| 151 void Init(bool extensions_enabled); | 160 void Init(bool extensions_enabled); |
| 152 | 161 |
| 153 ExtensionService* extension_service(); | 162 ExtensionService* extension_service(); |
| 163 extensions::ManagementPolicy* management_policy(); |
| 154 UserScriptMaster* user_script_master(); | 164 UserScriptMaster* user_script_master(); |
| 155 ExtensionInfoMap* info_map(); | 165 ExtensionInfoMap* info_map(); |
| 156 extensions::LazyBackgroundTaskQueue* lazy_background_task_queue(); | 166 extensions::LazyBackgroundTaskQueue* lazy_background_task_queue(); |
| 157 ExtensionMessageService* message_service(); | 167 ExtensionMessageService* message_service(); |
| 158 ExtensionEventRouter* event_router(); | 168 ExtensionEventRouter* event_router(); |
| 159 extensions::RulesRegistryService* rules_registry_service(); | 169 extensions::RulesRegistryService* rules_registry_service(); |
| 160 | 170 |
| 161 private: | 171 private: |
| 162 Profile* profile_; | 172 Profile* profile_; |
| 163 | 173 |
| 164 // The services that are shared between normal and incognito profiles. | 174 // The services that are shared between normal and incognito profiles. |
| 165 | 175 |
| 166 // Keep extension_prefs_ on top of extension_service_ because the latter | 176 // Keep extension_prefs_ above extension_service_, because the latter |
| 167 // maintains a pointer to the first and shall be destructed first. | 177 // maintains a pointer to the former and must be destructed first. |
| 168 scoped_ptr<ExtensionPrefs> extension_prefs_; | 178 scoped_ptr<ExtensionPrefs> extension_prefs_; |
| 169 scoped_ptr<ExtensionService> extension_service_; | 179 scoped_ptr<ExtensionService> extension_service_; |
| 180 scoped_ptr<extensions::ManagementPolicy> management_policy_; |
| 170 scoped_refptr<UserScriptMaster> user_script_master_; | 181 scoped_refptr<UserScriptMaster> user_script_master_; |
| 171 // extension_info_map_ needs to outlive extension_process_manager_. | 182 // extension_info_map_ needs to outlive extension_process_manager_. |
| 172 scoped_refptr<ExtensionInfoMap> extension_info_map_; | 183 scoped_refptr<ExtensionInfoMap> extension_info_map_; |
| 173 // This is a dependency of ExtensionMessageService and ExtensionEventRouter. | 184 // This is a dependency of ExtensionMessageService and ExtensionEventRouter. |
| 174 scoped_ptr<extensions::LazyBackgroundTaskQueue> lazy_background_task_queue_; | 185 scoped_ptr<extensions::LazyBackgroundTaskQueue> lazy_background_task_queue_; |
| 175 scoped_ptr<ExtensionMessageService> extension_message_service_; | 186 scoped_ptr<ExtensionMessageService> extension_message_service_; |
| 176 scoped_ptr<ExtensionEventRouter> extension_event_router_; | 187 scoped_ptr<ExtensionEventRouter> extension_event_router_; |
| 177 scoped_ptr<ExtensionNavigationObserver> extension_navigation_observer_; | 188 scoped_ptr<ExtensionNavigationObserver> extension_navigation_observer_; |
| 178 scoped_ptr<extensions::RulesRegistryService> rules_registry_service_; | 189 scoped_ptr<extensions::RulesRegistryService> rules_registry_service_; |
| 179 }; | 190 }; |
| 180 | 191 |
| 181 Profile* profile_; | 192 Profile* profile_; |
| 182 | 193 |
| 183 Shared* shared_; | 194 Shared* shared_; |
| 184 | 195 |
| 185 // The services that have their own instances in incognito. | 196 // The services that have their own instances in incognito. |
| 186 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; | 197 scoped_refptr<ExtensionDevToolsManager> extension_devtools_manager_; |
| 187 // |extension_process_manager_| must be destroyed before the Profile's | 198 // |extension_process_manager_| must be destroyed before the Profile's |
| 188 // |io_data_|. While |extension_process_manager_| still lives, we handle | 199 // |io_data_|. While |extension_process_manager_| still lives, we handle |
| 189 // incoming resource requests from extension processes and those require | 200 // incoming resource requests from extension processes and those require |
| 190 // access to the ResourceContext owned by |io_data_|. | 201 // access to the ResourceContext owned by |io_data_|. |
| 191 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 202 scoped_ptr<ExtensionProcessManager> extension_process_manager_; |
| 192 scoped_ptr<extensions::AlarmManager> alarm_manager_; | 203 scoped_ptr<extensions::AlarmManager> alarm_manager_; |
| 193 | 204 |
| 194 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 205 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
| 195 }; | 206 }; |
| 196 | 207 |
| 197 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 208 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
| OLD | NEW |