| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service
.h" |
| 14 #include "extensions/common/one_shot_event.h" | 14 #include "extensions/common/one_shot_event.h" |
| 15 | 15 |
| 16 class ExtensionProcessManager; | |
| 17 class ExtensionService; | 16 class ExtensionService; |
| 18 class Profile; | 17 class Profile; |
| 19 | 18 |
| 20 #if defined(OS_CHROMEOS) | 19 #if defined(OS_CHROMEOS) |
| 21 namespace chromeos { | 20 namespace chromeos { |
| 22 class DeviceLocalAccountManagementPolicyProvider; | 21 class DeviceLocalAccountManagementPolicyProvider; |
| 23 } | 22 } |
| 24 #endif // defined(OS_CHROMEOS) | 23 #endif // defined(OS_CHROMEOS) |
| 25 | 24 |
| 26 namespace content { | 25 namespace content { |
| 27 class BrowserContext; | 26 class BrowserContext; |
| 28 } | 27 } |
| 29 | 28 |
| 30 namespace extensions { | 29 namespace extensions { |
| 31 class Blacklist; | 30 class Blacklist; |
| 32 class ErrorConsole; | 31 class ErrorConsole; |
| 33 class EventRouter; | 32 class EventRouter; |
| 34 class Extension; | 33 class Extension; |
| 35 class ExtensionSystemSharedFactory; | 34 class ExtensionSystemSharedFactory; |
| 36 class ExtensionWarningBadgeService; | 35 class ExtensionWarningBadgeService; |
| 37 class ExtensionWarningService; | 36 class ExtensionWarningService; |
| 38 class InfoMap; | 37 class InfoMap; |
| 39 class LazyBackgroundTaskQueue; | 38 class LazyBackgroundTaskQueue; |
| 40 class ManagementPolicy; | 39 class ManagementPolicy; |
| 41 class NavigationObserver; | 40 class NavigationObserver; |
| 41 class ProcessManager; |
| 42 class StandardManagementPolicyProvider; | 42 class StandardManagementPolicyProvider; |
| 43 class StateStore; | 43 class StateStore; |
| 44 class UserScriptMaster; | 44 class UserScriptMaster; |
| 45 | 45 |
| 46 // The ExtensionSystem manages the creation and destruction of services | 46 // The ExtensionSystem manages the creation and destruction of services |
| 47 // related to extensions. Most objects are shared between normal | 47 // related to extensions. Most objects are shared between normal |
| 48 // and incognito Profiles, except as called out in comments. | 48 // and incognito Profiles, except as called out in comments. |
| 49 // This interface supports using TestExtensionSystem for TestingProfiles | 49 // This interface supports using TestExtensionSystem for TestingProfiles |
| 50 // that don't want all of the extensions baggage in their tests. | 50 // that don't want all of the extensions baggage in their tests. |
| 51 class ExtensionSystem : public BrowserContextKeyedService { | 51 class ExtensionSystem : public BrowserContextKeyedService { |
| 52 public: | 52 public: |
| 53 ExtensionSystem(); | 53 ExtensionSystem(); |
| 54 virtual ~ExtensionSystem(); | 54 virtual ~ExtensionSystem(); |
| 55 | 55 |
| 56 // Returns the instance for the given profile, or NULL if none. This is | 56 // Returns the instance for the given profile, or NULL if none. This is |
| 57 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. | 57 // a convenience wrapper around ExtensionSystemFactory::GetForProfile. |
| 58 static ExtensionSystem* Get(Profile* profile); | 58 static ExtensionSystem* Get(Profile* profile); |
| 59 | 59 |
| 60 // Returns the same instance as Get() above. | 60 // Returns the same instance as Get() above. |
| 61 static ExtensionSystem* GetForBrowserContext( | 61 static ExtensionSystem* GetForBrowserContext( |
| 62 content::BrowserContext* profile); | 62 content::BrowserContext* profile); |
| 63 | 63 |
| 64 // BrowserContextKeyedService implementation. | 64 // BrowserContextKeyedService implementation. |
| 65 virtual void Shutdown() OVERRIDE {} | 65 virtual void Shutdown() OVERRIDE {} |
| 66 | 66 |
| 67 // Initializes extensions machinery. | 67 // Initializes extensions machinery. |
| 68 // Component extensions are always enabled, external and user extensions | 68 // Component extensions are always enabled, external and user extensions |
| 69 // are controlled by |extensions_enabled|. If |defer_background_creation| is | 69 // are controlled by |extensions_enabled|. If |defer_background_creation| is |
| 70 // true, then creation of background extension RenderViews will be deferred | 70 // true, then creation of background extension RenderViews will be deferred |
| 71 // until ExtensionProcessManager::DeferBackgroundHostCreation is called with | 71 // until extensions::ProcessManager::DeferBackgroundHostCreation is called |
| 72 // |defer| set to false. | 72 // with |defer| set to false. |
| 73 virtual void InitForRegularProfile(bool extensions_enabled, | 73 virtual void InitForRegularProfile(bool extensions_enabled, |
| 74 bool defer_background_creation) = 0; | 74 bool defer_background_creation) = 0; |
| 75 | 75 |
| 76 // The ExtensionService is created at startup. | 76 // The ExtensionService is created at startup. |
| 77 virtual ExtensionService* extension_service() = 0; | 77 virtual ExtensionService* extension_service() = 0; |
| 78 | 78 |
| 79 // The class controlling whether users are permitted to perform certain | 79 // The class controlling whether users are permitted to perform certain |
| 80 // actions on extensions (install, uninstall, disable, etc.). | 80 // actions on extensions (install, uninstall, disable, etc.). |
| 81 // The ManagementPolicy is created at startup. | 81 // The ManagementPolicy is created at startup. |
| 82 virtual ManagementPolicy* management_policy() = 0; | 82 virtual ManagementPolicy* management_policy() = 0; |
| 83 | 83 |
| 84 // The UserScriptMaster is created at startup. | 84 // The UserScriptMaster is created at startup. |
| 85 virtual UserScriptMaster* user_script_master() = 0; | 85 virtual UserScriptMaster* user_script_master() = 0; |
| 86 | 86 |
| 87 // The ExtensionProcessManager is created at startup. | 87 // The ProcessManager is created at startup. |
| 88 virtual ExtensionProcessManager* process_manager() = 0; | 88 virtual ProcessManager* process_manager() = 0; |
| 89 | 89 |
| 90 // The StateStore is created at startup. | 90 // The StateStore is created at startup. |
| 91 virtual StateStore* state_store() = 0; | 91 virtual StateStore* state_store() = 0; |
| 92 | 92 |
| 93 // The rules store is created at startup. | 93 // The rules store is created at startup. |
| 94 virtual StateStore* rules_store() = 0; | 94 virtual StateStore* rules_store() = 0; |
| 95 | 95 |
| 96 // Returns the IO-thread-accessible extension data. | 96 // Returns the IO-thread-accessible extension data. |
| 97 virtual InfoMap* info_map() = 0; | 97 virtual InfoMap* info_map() = 0; |
| 98 | 98 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 | 142 |
| 143 // BrowserContextKeyedService implementation. | 143 // BrowserContextKeyedService implementation. |
| 144 virtual void Shutdown() OVERRIDE; | 144 virtual void Shutdown() OVERRIDE; |
| 145 | 145 |
| 146 virtual void InitForRegularProfile(bool extensions_enabled, | 146 virtual void InitForRegularProfile(bool extensions_enabled, |
| 147 bool defer_background_creation) OVERRIDE; | 147 bool defer_background_creation) OVERRIDE; |
| 148 | 148 |
| 149 virtual ExtensionService* extension_service() OVERRIDE; // shared | 149 virtual ExtensionService* extension_service() OVERRIDE; // shared |
| 150 virtual ManagementPolicy* management_policy() OVERRIDE; // shared | 150 virtual ManagementPolicy* management_policy() OVERRIDE; // shared |
| 151 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared | 151 virtual UserScriptMaster* user_script_master() OVERRIDE; // shared |
| 152 virtual ExtensionProcessManager* process_manager() OVERRIDE; | 152 virtual ProcessManager* process_manager() OVERRIDE; |
| 153 virtual StateStore* state_store() OVERRIDE; // shared | 153 virtual StateStore* state_store() OVERRIDE; // shared |
| 154 virtual StateStore* rules_store() OVERRIDE; // shared | 154 virtual StateStore* rules_store() OVERRIDE; // shared |
| 155 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() | 155 virtual LazyBackgroundTaskQueue* lazy_background_task_queue() |
| 156 OVERRIDE; // shared | 156 OVERRIDE; // shared |
| 157 virtual InfoMap* info_map() OVERRIDE; // shared | 157 virtual InfoMap* info_map() OVERRIDE; // shared |
| 158 virtual EventRouter* event_router() OVERRIDE; // shared | 158 virtual EventRouter* event_router() OVERRIDE; // shared |
| 159 virtual ExtensionWarningService* warning_service() OVERRIDE; | 159 virtual ExtensionWarningService* warning_service() OVERRIDE; |
| 160 virtual Blacklist* blacklist() OVERRIDE; // shared | 160 virtual Blacklist* blacklist() OVERRIDE; // shared |
| 161 virtual ErrorConsole* error_console() OVERRIDE; | 161 virtual ErrorConsole* error_console() OVERRIDE; |
| 162 | 162 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 scoped_ptr<EventRouter> event_router_; | 214 scoped_ptr<EventRouter> event_router_; |
| 215 scoped_ptr<NavigationObserver> navigation_observer_; | 215 scoped_ptr<NavigationObserver> navigation_observer_; |
| 216 scoped_refptr<UserScriptMaster> user_script_master_; | 216 scoped_refptr<UserScriptMaster> user_script_master_; |
| 217 scoped_ptr<Blacklist> blacklist_; | 217 scoped_ptr<Blacklist> blacklist_; |
| 218 // StandardManagementPolicyProvider depends on Blacklist. | 218 // StandardManagementPolicyProvider depends on Blacklist. |
| 219 scoped_ptr<StandardManagementPolicyProvider> | 219 scoped_ptr<StandardManagementPolicyProvider> |
| 220 standard_management_policy_provider_; | 220 standard_management_policy_provider_; |
| 221 // ExtensionService depends on StateStore and Blacklist. | 221 // ExtensionService depends on StateStore and Blacklist. |
| 222 scoped_ptr<ExtensionService> extension_service_; | 222 scoped_ptr<ExtensionService> extension_service_; |
| 223 scoped_ptr<ManagementPolicy> management_policy_; | 223 scoped_ptr<ManagementPolicy> management_policy_; |
| 224 // extension_info_map_ needs to outlive extension_process_manager_. | 224 // extension_info_map_ needs to outlive process_manager_. |
| 225 scoped_refptr<InfoMap> extension_info_map_; | 225 scoped_refptr<InfoMap> extension_info_map_; |
| 226 scoped_ptr<ExtensionWarningService> extension_warning_service_; | 226 scoped_ptr<ExtensionWarningService> extension_warning_service_; |
| 227 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; | 227 scoped_ptr<ExtensionWarningBadgeService> extension_warning_badge_service_; |
| 228 scoped_ptr<ErrorConsole> error_console_; | 228 scoped_ptr<ErrorConsole> error_console_; |
| 229 | 229 |
| 230 #if defined(OS_CHROMEOS) | 230 #if defined(OS_CHROMEOS) |
| 231 scoped_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider> | 231 scoped_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider> |
| 232 device_local_account_management_policy_provider_; | 232 device_local_account_management_policy_provider_; |
| 233 #endif | 233 #endif |
| 234 | 234 |
| 235 OneShotEvent ready_; | 235 OneShotEvent ready_; |
| 236 }; | 236 }; |
| 237 | 237 |
| 238 Profile* profile_; | 238 Profile* profile_; |
| 239 | 239 |
| 240 Shared* shared_; | 240 Shared* shared_; |
| 241 | 241 |
| 242 // |extension_process_manager_| must be destroyed before the Profile's | 242 // |process_manager_| must be destroyed before the Profile's |io_data_|. While |
| 243 // |io_data_|. While |extension_process_manager_| still lives, we handle | 243 // |process_manager_| still lives, we handle incoming resource requests from |
| 244 // incoming resource requests from extension processes and those require | 244 // extension processes and those require access to the ResourceContext owned |
| 245 // access to the ResourceContext owned by |io_data_|. | 245 // by |io_data_|. |
| 246 scoped_ptr<ExtensionProcessManager> extension_process_manager_; | 246 scoped_ptr<ProcessManager> process_manager_; |
| 247 | 247 |
| 248 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); | 248 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl); |
| 249 }; | 249 }; |
| 250 | 250 |
| 251 } // namespace extensions | 251 } // namespace extensions |
| 252 | 252 |
| 253 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ | 253 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_H_ |
| OLD | NEW |