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 NavigationObserver
;
17 class StateStoreNotificationObserver
;
19 // The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
20 // Implementation details: non-shared services are owned by
21 // ExtensionSystemImpl, a KeyedService with separate incognito
22 // instances. A private Shared class (also a KeyedService,
23 // but with a shared instance for incognito) keeps the common services.
24 class ExtensionSystemImpl
: public ExtensionSystem
{
26 explicit ExtensionSystemImpl(Profile
* profile
);
27 ~ExtensionSystemImpl() override
;
29 // KeyedService implementation.
30 void Shutdown() override
;
32 void InitForRegularProfile(bool extensions_enabled
) override
;
34 ExtensionService
* extension_service() override
; // shared
35 RuntimeData
* runtime_data() override
; // shared
36 ManagementPolicy
* management_policy() override
; // shared
37 SharedUserScriptMaster
* shared_user_script_master() override
; // shared
38 StateStore
* state_store() override
; // shared
39 StateStore
* rules_store() override
; // shared
40 InfoMap
* info_map() override
; // shared
41 QuotaService
* quota_service() override
; // shared
42 AppSorting
* app_sorting() override
; // shared
44 void RegisterExtensionWithRequestContexts(
45 const Extension
* extension
,
46 const base::Closure
& callback
) override
;
48 void UnregisterExtensionWithRequestContexts(
49 const std::string
& extension_id
,
50 const UnloadedExtensionInfo::Reason reason
) override
;
52 const OneShotEvent
& ready() const override
;
53 ContentVerifier
* content_verifier() override
; // shared
54 scoped_ptr
<ExtensionSet
> GetDependentExtensions(
55 const Extension
* extension
) override
;
58 friend class ExtensionSystemSharedFactory
;
60 // Owns the Extension-related systems that have a single instance
61 // shared between normal and incognito profiles.
62 class Shared
: public KeyedService
{
64 explicit Shared(Profile
* profile
);
67 // Initialization takes place in phases.
68 virtual void InitPrefs();
69 // This must not be called until all the providers have been created.
70 void RegisterManagementPolicyProviders();
71 void Init(bool extensions_enabled
);
73 // KeyedService implementation.
74 void Shutdown() override
;
76 StateStore
* state_store();
77 StateStore
* rules_store();
78 ExtensionService
* extension_service();
79 RuntimeData
* runtime_data();
80 ManagementPolicy
* management_policy();
81 SharedUserScriptMaster
* shared_user_script_master();
83 QuotaService
* quota_service();
84 AppSorting
* app_sorting();
85 const OneShotEvent
& ready() const { return ready_
; }
86 ContentVerifier
* content_verifier();
91 // The services that are shared between normal and incognito profiles.
93 scoped_ptr
<StateStore
> state_store_
;
94 scoped_ptr
<StateStoreNotificationObserver
>
95 state_store_notification_observer_
;
96 scoped_ptr
<StateStore
> rules_store_
;
97 scoped_ptr
<NavigationObserver
> navigation_observer_
;
98 // Shared memory region manager for scripts statically declared in extension
99 // manifests. This region is shared between all extensions.
100 scoped_ptr
<SharedUserScriptMaster
> shared_user_script_master_
;
101 scoped_ptr
<RuntimeData
> runtime_data_
;
102 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
103 scoped_ptr
<ExtensionService
> extension_service_
;
104 scoped_ptr
<ManagementPolicy
> management_policy_
;
105 // extension_info_map_ needs to outlive process_manager_.
106 scoped_refptr
<InfoMap
> extension_info_map_
;
107 scoped_ptr
<QuotaService
> quota_service_
;
108 scoped_ptr
<AppSorting
> app_sorting_
;
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_