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 "base/memory/scoped_vector.h"
9 #include "extensions/browser/extension_system.h"
10 #include "extensions/common/one_shot_event.h"
12 class DeclarativeUserScriptManager
;
15 namespace extensions
{
17 class ContentVerifier
;
18 class ExtensionSystemSharedFactory
;
19 class NavigationObserver
;
20 class SharedUserScriptMaster
;
21 class StateStoreNotificationObserver
;
23 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
24 // Implementation details: non-shared services are owned by
25 // ExtensionSystemImpl, a KeyedService with separate incognito
26 // instances. A private Shared class (also a KeyedService,
27 // but with a shared instance for incognito) keeps the common services.
28 class ExtensionSystemImpl
: public ExtensionSystem
{
30 explicit ExtensionSystemImpl(Profile
* profile
);
31 ~ExtensionSystemImpl() override
;
33 // KeyedService implementation.
34 void Shutdown() override
;
36 void InitForRegularProfile(bool extensions_enabled
) override
;
38 ExtensionService
* extension_service() override
; // shared
39 RuntimeData
* runtime_data() override
; // shared
40 ManagementPolicy
* management_policy() override
; // shared
41 SharedUserScriptMaster
* shared_user_script_master() override
; // shared
42 StateStore
* state_store() override
; // shared
43 StateStore
* rules_store() override
; // shared
44 InfoMap
* info_map() override
; // shared
45 QuotaService
* quota_service() override
; // shared
47 void RegisterExtensionWithRequestContexts(
48 const Extension
* extension
) override
;
50 void UnregisterExtensionWithRequestContexts(
51 const std::string
& extension_id
,
52 const UnloadedExtensionInfo::Reason reason
) override
;
54 const OneShotEvent
& ready() const override
;
55 ContentVerifier
* content_verifier() override
; // shared
56 scoped_ptr
<ExtensionSet
> GetDependentExtensions(
57 const Extension
* extension
) override
;
60 friend class ExtensionSystemSharedFactory
;
62 // Owns the Extension-related systems that have a single instance
63 // shared between normal and incognito profiles.
64 class Shared
: public KeyedService
{
66 explicit Shared(Profile
* profile
);
69 // Initialization takes place in phases.
70 virtual void InitPrefs();
71 // This must not be called until all the providers have been created.
72 void RegisterManagementPolicyProviders();
73 void Init(bool extensions_enabled
);
75 // KeyedService implementation.
76 void Shutdown() override
;
78 StateStore
* state_store();
79 StateStore
* rules_store();
80 ExtensionService
* extension_service();
81 RuntimeData
* runtime_data();
82 ManagementPolicy
* management_policy();
83 SharedUserScriptMaster
* shared_user_script_master();
85 QuotaService
* quota_service();
86 const OneShotEvent
& ready() const { return ready_
; }
87 ContentVerifier
* content_verifier();
92 // The services that are shared between normal and incognito profiles.
94 scoped_ptr
<StateStore
> state_store_
;
95 scoped_ptr
<StateStoreNotificationObserver
>
96 state_store_notification_observer_
;
97 scoped_ptr
<StateStore
> rules_store_
;
98 scoped_ptr
<NavigationObserver
> navigation_observer_
;
99 // Shared memory region manager for scripts statically declared in extension
100 // manifests. This region is shared between all extensions.
101 scoped_ptr
<SharedUserScriptMaster
> shared_user_script_master_
;
102 scoped_ptr
<RuntimeData
> runtime_data_
;
103 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
104 scoped_ptr
<ExtensionService
> extension_service_
;
105 scoped_ptr
<ManagementPolicy
> management_policy_
;
106 // extension_info_map_ needs to outlive process_manager_.
107 scoped_refptr
<InfoMap
> extension_info_map_
;
108 scoped_ptr
<QuotaService
> quota_service_
;
110 // For verifying the contents of extensions read from disk.
111 scoped_refptr
<ContentVerifier
> content_verifier_
;
113 #if defined(OS_CHROMEOS)
114 scoped_ptr
<chromeos::DeviceLocalAccountManagementPolicyProvider
>
115 device_local_account_management_policy_provider_
;
125 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl
);
128 } // namespace extensions
130 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_