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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_
8 #include "extensions/browser/extension_system.h"
9 #include "extensions/common/one_shot_event.h"
13 namespace extensions
{
15 class ExtensionSystemSharedFactory
;
16 class ExtensionWarningBadgeService
;
17 class NavigationObserver
;
18 class StandardManagementPolicyProvider
;
20 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
21 // Implementation details: non-shared services are owned by
22 // ExtensionSystemImpl, a BrowserContextKeyedService with separate incognito
23 // instances. A private Shared class (also a BrowserContextKeyedService,
24 // but with a shared instance for incognito) keeps the common services.
25 class ExtensionSystemImpl
: public ExtensionSystem
{
27 explicit ExtensionSystemImpl(Profile
* profile
);
28 virtual ~ExtensionSystemImpl();
30 // BrowserContextKeyedService implementation.
31 virtual void Shutdown() OVERRIDE
;
33 virtual void InitForRegularProfile(bool extensions_enabled
) OVERRIDE
;
35 virtual ExtensionService
* extension_service() OVERRIDE
; // shared
36 virtual RuntimeData
* runtime_data() OVERRIDE
; // shared
37 virtual ManagementPolicy
* management_policy() OVERRIDE
; // shared
38 virtual UserScriptMaster
* user_script_master() OVERRIDE
; // shared
39 virtual ProcessManager
* process_manager() OVERRIDE
;
40 virtual StateStore
* state_store() OVERRIDE
; // shared
41 virtual StateStore
* rules_store() OVERRIDE
; // shared
42 virtual LazyBackgroundTaskQueue
* lazy_background_task_queue()
44 virtual InfoMap
* info_map() OVERRIDE
; // shared
45 virtual EventRouter
* event_router() OVERRIDE
; // shared
46 virtual ExtensionWarningService
* warning_service() OVERRIDE
;
47 virtual Blacklist
* blacklist() OVERRIDE
; // shared
48 virtual ErrorConsole
* error_console() OVERRIDE
;
49 virtual InstallVerifier
* install_verifier() OVERRIDE
;
50 virtual QuotaService
* quota_service() OVERRIDE
; // shared
52 virtual void RegisterExtensionWithRequestContexts(
53 const Extension
* extension
) OVERRIDE
;
55 virtual void UnregisterExtensionWithRequestContexts(
56 const std::string
& extension_id
,
57 const UnloadedExtensionInfo::Reason reason
) OVERRIDE
;
59 virtual const OneShotEvent
& ready() const OVERRIDE
;
62 friend class ExtensionSystemSharedFactory
;
64 // Owns the Extension-related systems that have a single instance
65 // shared between normal and incognito profiles.
66 class Shared
: public BrowserContextKeyedService
{
68 explicit Shared(Profile
* profile
);
71 // Initialization takes place in phases.
72 virtual void InitPrefs();
73 // This must not be called until all the providers have been created.
74 void RegisterManagementPolicyProviders();
75 void Init(bool extensions_enabled
);
77 // BrowserContextKeyedService implementation.
78 virtual void Shutdown() OVERRIDE
;
80 StateStore
* state_store();
81 StateStore
* rules_store();
82 ExtensionService
* extension_service();
83 RuntimeData
* runtime_data();
84 ManagementPolicy
* management_policy();
85 UserScriptMaster
* user_script_master();
86 Blacklist
* blacklist();
88 LazyBackgroundTaskQueue
* lazy_background_task_queue();
89 EventRouter
* event_router();
90 ExtensionWarningService
* warning_service();
91 ErrorConsole
* error_console();
92 InstallVerifier
* install_verifier();
93 QuotaService
* quota_service();
94 const OneShotEvent
& ready() const { return ready_
; }
99 // The services that are shared between normal and incognito profiles.
101 scoped_ptr
<StateStore
> state_store_
;
102 scoped_ptr
<StateStore
> rules_store_
;
103 // LazyBackgroundTaskQueue is a dependency of
104 // MessageService and EventRouter.
105 scoped_ptr
<LazyBackgroundTaskQueue
> lazy_background_task_queue_
;
106 scoped_ptr
<EventRouter
> event_router_
;
107 scoped_ptr
<NavigationObserver
> navigation_observer_
;
108 scoped_refptr
<UserScriptMaster
> user_script_master_
;
109 scoped_ptr
<Blacklist
> blacklist_
;
110 // StandardManagementPolicyProvider depends on Blacklist.
111 scoped_ptr
<StandardManagementPolicyProvider
>
112 standard_management_policy_provider_
;
113 scoped_ptr
<RuntimeData
> runtime_data_
;
114 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
115 scoped_ptr
<ExtensionService
> extension_service_
;
116 scoped_ptr
<ManagementPolicy
> management_policy_
;
117 // extension_info_map_ needs to outlive process_manager_.
118 scoped_refptr
<InfoMap
> extension_info_map_
;
119 scoped_ptr
<ExtensionWarningService
> extension_warning_service_
;
120 scoped_ptr
<ExtensionWarningBadgeService
> extension_warning_badge_service_
;
121 scoped_ptr
<ErrorConsole
> error_console_
;
122 scoped_ptr
<InstallVerifier
> install_verifier_
;
123 scoped_ptr
<QuotaService
> quota_service_
;
125 #if defined(OS_CHROMEOS)
126 scoped_ptr
<chromeos::DeviceLocalAccountManagementPolicyProvider
>
127 device_local_account_management_policy_provider_
;
137 // |process_manager_| must be destroyed before the Profile's |io_data_|. While
138 // |process_manager_| still lives, we handle incoming resource requests from
139 // extension processes and those require access to the ResourceContext owned
141 scoped_ptr
<ProcessManager
> process_manager_
;
143 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl
);
146 } // namespace extensions
148 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_