blob: 98809e1e0132f644e59b85520066eb897e8a2889 [file] [log] [blame]
[email protected]59b0e602014-01-30 00:41:241// 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.
4
5#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_
6#define CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_
7
asargent8380bd392016-03-21 23:47:338#include <string>
9
avia2f4804a2015-12-24 23:11:1310#include "base/macros.h"
Christopher Lamebb90202019-04-04 03:42:3611#include "base/one_shot_event.h"
avia2f4804a2015-12-24 23:11:1312#include "build/build_config.h"
Randy Smith64399d62017-12-20 04:33:4013#include "chrome/browser/extensions/extension_cookie_notifier.h"
[email protected]59b0e602014-01-30 00:41:2414#include "extensions/browser/extension_system.h"
[email protected]59b0e602014-01-30 00:41:2415
16class Profile;
[email protected]59b0e602014-01-30 00:41:2417
antrim58769562016-11-14 14:48:4118#if defined(OS_CHROMEOS)
19namespace chromeos {
20class DeviceLocalAccountManagementPolicyProvider;
21class SigninScreenPolicyProvider;
22}
23#endif // defined(OS_CHROMEOS)
24
[email protected]59b0e602014-01-30 00:41:2425namespace extensions {
26
27class ExtensionSystemSharedFactory;
[email protected]59b0e602014-01-30 00:41:2428class NavigationObserver;
[email protected]479e3922014-07-30 07:12:5729class StateStoreNotificationObserver;
asargent8380bd392016-03-21 23:47:3330class UninstallPingSender;
xiyuanf6a4c6a62016-04-19 18:14:5431class InstallGate;
cmumford6ae8d462016-03-24 20:35:2732class ValueStoreFactory;
33class ValueStoreFactoryImpl;
[email protected]59b0e602014-01-30 00:41:2434
35// The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
36// Implementation details: non-shared services are owned by
[email protected]b33f0b112014-03-13 17:05:3037// ExtensionSystemImpl, a KeyedService with separate incognito
38// instances. A private Shared class (also a KeyedService,
[email protected]59b0e602014-01-30 00:41:2439// but with a shared instance for incognito) keeps the common services.
40class ExtensionSystemImpl : public ExtensionSystem {
41 public:
Minh X. Nguyen30975342017-12-04 22:02:4142 using InstallUpdateCallback = ExtensionSystem::InstallUpdateCallback;
43
[email protected]59b0e602014-01-30 00:41:2444 explicit ExtensionSystemImpl(Profile* profile);
dchengae36a4a2014-10-21 12:36:3645 ~ExtensionSystemImpl() override;
[email protected]59b0e602014-01-30 00:41:2446
[email protected]b33f0b112014-03-13 17:05:3047 // KeyedService implementation.
dchengae36a4a2014-10-21 12:36:3648 void Shutdown() override;
[email protected]59b0e602014-01-30 00:41:2449
dchengae36a4a2014-10-21 12:36:3650 void InitForRegularProfile(bool extensions_enabled) override;
Randy Smith64399d62017-12-20 04:33:4051 void InitForIncognitoProfile() override;
[email protected]59b0e602014-01-30 00:41:2452
dchengae36a4a2014-10-21 12:36:3653 ExtensionService* extension_service() override; // shared
54 RuntimeData* runtime_data() override; // shared
55 ManagementPolicy* management_policy() override; // shared
rdevlin.croninf5863da2015-09-10 19:21:4556 ServiceWorkerManager* service_worker_manager() override; // shared
hanxi6d9b43a2014-12-12 21:53:4657 SharedUserScriptMaster* shared_user_script_master() override; // shared
dchengae36a4a2014-10-21 12:36:3658 StateStore* state_store() override; // shared
59 StateStore* rules_store() override; // shared
cmumford6ae8d462016-03-24 20:35:2760 scoped_refptr<ValueStoreFactory> store_factory() override; // shared
dchengae36a4a2014-10-21 12:36:3661 InfoMap* info_map() override; // shared
dchengae36a4a2014-10-21 12:36:3662 QuotaService* quota_service() override; // shared
treib926ee2d2015-08-06 10:55:4263 AppSorting* app_sorting() override; // shared
[email protected]59b0e602014-01-30 00:41:2464
dchengae36a4a2014-10-21 12:36:3665 void RegisterExtensionWithRequestContexts(
rockot494f0072015-07-29 17:58:0766 const Extension* extension,
67 const base::Closure& callback) override;
[email protected]59b0e602014-01-30 00:41:2468
dchengae36a4a2014-10-21 12:36:3669 void UnregisterExtensionWithRequestContexts(
[email protected]59b0e602014-01-30 00:41:2470 const std::string& extension_id,
limasdf0deef2042017-05-03 19:17:1771 const UnloadedExtensionReason reason) override;
[email protected]59b0e602014-01-30 00:41:2472
Christopher Lamebb90202019-04-04 03:42:3673 const base::OneShotEvent& ready() const override;
dchengae36a4a2014-10-21 12:36:3674 ContentVerifier* content_verifier() override; // shared
dchengc963c7142016-04-08 03:55:2275 std::unique_ptr<ExtensionSet> GetDependentExtensions(
mostynba15bee12014-10-04 00:40:3276 const Extension* extension) override;
asargent631a99a2015-10-15 21:51:4877 void InstallUpdate(const std::string& extension_id,
Minh X. Nguyen30975342017-12-04 22:02:4178 const std::string& public_key,
79 const base::FilePath& unpacked_dir,
Minh X. Nguyen039eb992018-06-26 20:12:1380 bool install_immediately,
Minh X. Nguyen30975342017-12-04 22:02:4181 InstallUpdateCallback install_update_callback) override;
Minh X. Nguyenb4fbf922018-01-29 18:28:1082 bool FinishDelayedInstallationIfReady(const std::string& extension_id,
83 bool install_immediately) override;
[email protected]59b0e602014-01-30 00:41:2484
85 private:
86 friend class ExtensionSystemSharedFactory;
87
88 // Owns the Extension-related systems that have a single instance
89 // shared between normal and incognito profiles.
Devlin Croninc5c5a0c2018-08-15 04:04:1090 class Shared : public KeyedService {
[email protected]59b0e602014-01-30 00:41:2491 public:
92 explicit Shared(Profile* profile);
dchengae36a4a2014-10-21 12:36:3693 ~Shared() override;
[email protected]59b0e602014-01-30 00:41:2494
95 // Initialization takes place in phases.
96 virtual void InitPrefs();
97 // This must not be called until all the providers have been created.
98 void RegisterManagementPolicyProviders();
xiyuanf6a4c6a62016-04-19 18:14:5499 void InitInstallGates();
[email protected]59b0e602014-01-30 00:41:24100 void Init(bool extensions_enabled);
101
[email protected]b33f0b112014-03-13 17:05:30102 // KeyedService implementation.
dchengae36a4a2014-10-21 12:36:36103 void Shutdown() override;
[email protected]59b0e602014-01-30 00:41:24104
105 StateStore* state_store();
106 StateStore* rules_store();
cmumford6ae8d462016-03-24 20:35:27107 scoped_refptr<ValueStoreFactory> store_factory() const;
[email protected]59b0e602014-01-30 00:41:24108 ExtensionService* extension_service();
109 RuntimeData* runtime_data();
110 ManagementPolicy* management_policy();
rdevlin.croninf5863da2015-09-10 19:21:45111 ServiceWorkerManager* service_worker_manager();
[email protected]15ad2ee2014-08-15 19:15:26112 SharedUserScriptMaster* shared_user_script_master();
[email protected]59b0e602014-01-30 00:41:24113 InfoMap* info_map();
[email protected]aab23102014-02-05 18:57:55114 QuotaService* quota_service();
treib926ee2d2015-08-06 10:55:42115 AppSorting* app_sorting();
Christopher Lamebb90202019-04-04 03:42:36116 const base::OneShotEvent& ready() const { return ready_; }
[email protected]fd3df7782014-05-08 23:54:27117 ContentVerifier* content_verifier();
[email protected]59b0e602014-01-30 00:41:24118
119 private:
[email protected]59b0e602014-01-30 00:41:24120 Profile* profile_;
121
122 // The services that are shared between normal and incognito profiles.
123
dchengc963c7142016-04-08 03:55:22124 std::unique_ptr<StateStore> state_store_;
125 std::unique_ptr<StateStoreNotificationObserver>
[email protected]479e3922014-07-30 07:12:57126 state_store_notification_observer_;
dchengc963c7142016-04-08 03:55:22127 std::unique_ptr<StateStore> rules_store_;
cmumford6ae8d462016-03-24 20:35:27128 scoped_refptr<ValueStoreFactoryImpl> store_factory_;
dchengc963c7142016-04-08 03:55:22129 std::unique_ptr<NavigationObserver> navigation_observer_;
130 std::unique_ptr<ServiceWorkerManager> service_worker_manager_;
[email protected]15ad2ee2014-08-15 19:15:26131 // Shared memory region manager for scripts statically declared in extension
132 // manifests. This region is shared between all extensions.
dchengc963c7142016-04-08 03:55:22133 std::unique_ptr<SharedUserScriptMaster> shared_user_script_master_;
134 std::unique_ptr<RuntimeData> runtime_data_;
[email protected]59b0e602014-01-30 00:41:24135 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
dchengc963c7142016-04-08 03:55:22136 std::unique_ptr<ExtensionService> extension_service_;
137 std::unique_ptr<ManagementPolicy> management_policy_;
[email protected]59b0e602014-01-30 00:41:24138 // extension_info_map_ needs to outlive process_manager_.
139 scoped_refptr<InfoMap> extension_info_map_;
dchengc963c7142016-04-08 03:55:22140 std::unique_ptr<QuotaService> quota_service_;
141 std::unique_ptr<AppSorting> app_sorting_;
xiyuanf6a4c6a62016-04-19 18:14:54142 std::unique_ptr<InstallGate> update_install_gate_;
[email protected]59b0e602014-01-30 00:41:24143
[email protected]fd3df7782014-05-08 23:54:27144 // For verifying the contents of extensions read from disk.
145 scoped_refptr<ContentVerifier> content_verifier_;
146
dchengc963c7142016-04-08 03:55:22147 std::unique_ptr<UninstallPingSender> uninstall_ping_sender_;
asargent8380bd392016-03-21 23:47:33148
[email protected]59b0e602014-01-30 00:41:24149#if defined(OS_CHROMEOS)
dchengc963c7142016-04-08 03:55:22150 std::unique_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider>
[email protected]59b0e602014-01-30 00:41:24151 device_local_account_management_policy_provider_;
antrim58769562016-11-14 14:48:41152 std::unique_ptr<chromeos::SigninScreenPolicyProvider>
153 signin_screen_policy_provider_;
xiyuana0a6aaaa2016-04-19 23:34:16154 std::unique_ptr<InstallGate> kiosk_app_update_install_gate_;
[email protected]59b0e602014-01-30 00:41:24155#endif
156
Christopher Lamebb90202019-04-04 03:42:36157 base::OneShotEvent ready_;
[email protected]59b0e602014-01-30 00:41:24158 };
159
Randy Smith64399d62017-12-20 04:33:40160 std::unique_ptr<ExtensionCookieNotifier> cookie_notifier_;
161
[email protected]59b0e602014-01-30 00:41:24162 Profile* profile_;
163
164 Shared* shared_;
165
[email protected]59b0e602014-01-30 00:41:24166 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl);
167};
168
169} // namespace extensions
170
171#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_