Add ENABLE_MEDIA_ROUTER define to builds other than Android and iOS.
[chromium-blink-merge.git] / chrome / browser / extensions / extension_system_impl.h
blob416d5a17540b48fa27ec334c199e095263880535
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;
13 class Profile;
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 {
29 public:
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 DeclarativeUserScriptManager* declarative_user_script_manager()
43 override; // shared
44 StateStore* state_store() override; // shared
45 StateStore* rules_store() override; // shared
46 LazyBackgroundTaskQueue* lazy_background_task_queue() override; // shared
47 InfoMap* info_map() override; // shared
48 EventRouter* event_router() override; // shared
49 ErrorConsole* error_console() override;
50 InstallVerifier* install_verifier() override;
51 QuotaService* quota_service() override; // shared
53 void RegisterExtensionWithRequestContexts(
54 const Extension* extension) override;
56 void UnregisterExtensionWithRequestContexts(
57 const std::string& extension_id,
58 const UnloadedExtensionInfo::Reason reason) override;
60 const OneShotEvent& ready() const override;
61 ContentVerifier* content_verifier() override; // shared
62 scoped_ptr<ExtensionSet> GetDependentExtensions(
63 const Extension* extension) override;
65 private:
66 friend class ExtensionSystemSharedFactory;
68 // Owns the Extension-related systems that have a single instance
69 // shared between normal and incognito profiles.
70 class Shared : public KeyedService {
71 public:
72 explicit Shared(Profile* profile);
73 ~Shared() override;
75 // Initialization takes place in phases.
76 virtual void InitPrefs();
77 // This must not be called until all the providers have been created.
78 void RegisterManagementPolicyProviders();
79 void Init(bool extensions_enabled);
81 // KeyedService implementation.
82 void Shutdown() override;
84 StateStore* state_store();
85 StateStore* rules_store();
86 ExtensionService* extension_service();
87 RuntimeData* runtime_data();
88 ManagementPolicy* management_policy();
89 SharedUserScriptMaster* shared_user_script_master();
90 DeclarativeUserScriptManager* declarative_user_script_manager();
91 InfoMap* info_map();
92 LazyBackgroundTaskQueue* lazy_background_task_queue();
93 EventRouter* event_router();
94 ErrorConsole* error_console();
95 InstallVerifier* install_verifier();
96 QuotaService* quota_service();
97 const OneShotEvent& ready() const { return ready_; }
98 ContentVerifier* content_verifier();
100 private:
101 Profile* profile_;
103 // The services that are shared between normal and incognito profiles.
105 scoped_ptr<StateStore> state_store_;
106 scoped_ptr<StateStoreNotificationObserver>
107 state_store_notification_observer_;
108 scoped_ptr<StateStore> rules_store_;
109 // LazyBackgroundTaskQueue is a dependency of
110 // MessageService and EventRouter.
111 scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
112 scoped_ptr<EventRouter> event_router_;
113 scoped_ptr<NavigationObserver> navigation_observer_;
114 // Shared memory region manager for scripts statically declared in extension
115 // manifests. This region is shared between all extensions.
116 scoped_ptr<SharedUserScriptMaster> shared_user_script_master_;
117 // Manager of a set of DeclarativeUserScript objects for programmatically
118 // declared scripts.
119 scoped_ptr<DeclarativeUserScriptManager> declarative_user_script_manager_;
120 scoped_ptr<RuntimeData> runtime_data_;
121 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
122 scoped_ptr<ExtensionService> extension_service_;
123 scoped_ptr<ManagementPolicy> management_policy_;
124 // extension_info_map_ needs to outlive process_manager_.
125 scoped_refptr<InfoMap> extension_info_map_;
126 scoped_ptr<ErrorConsole> error_console_;
127 scoped_ptr<InstallVerifier> install_verifier_;
128 scoped_ptr<QuotaService> quota_service_;
130 // For verifying the contents of extensions read from disk.
131 scoped_refptr<ContentVerifier> content_verifier_;
133 #if defined(OS_CHROMEOS)
134 scoped_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider>
135 device_local_account_management_policy_provider_;
136 #endif
138 OneShotEvent ready_;
141 Profile* profile_;
143 Shared* shared_;
145 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl);
148 } // namespace extensions
150 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_