blob: e5eb8698bb1e2ee5d2af3a4e8f7db99d70582241 [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"
[email protected]59b0e602014-01-30 00:41:2413#include "extensions/browser/extension_system.h"
Devlin Croninc9c4efe2020-01-07 21:04:0514#include "extensions/browser/unloaded_extension_reason.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;
[email protected]59b0e602014-01-30 00:41:2451
dchengae36a4a2014-10-21 12:36:3652 ExtensionService* extension_service() override; // shared
53 RuntimeData* runtime_data() override; // shared
54 ManagementPolicy* management_policy() override; // shared
rdevlin.croninf5863da2015-09-10 19:21:4555 ServiceWorkerManager* service_worker_manager() override; // shared
hanxi6d9b43a2014-12-12 21:53:4656 SharedUserScriptMaster* shared_user_script_master() override; // shared
dchengae36a4a2014-10-21 12:36:3657 StateStore* state_store() override; // shared
58 StateStore* rules_store() override; // shared
cmumford6ae8d462016-03-24 20:35:2759 scoped_refptr<ValueStoreFactory> store_factory() override; // shared
dchengae36a4a2014-10-21 12:36:3660 InfoMap* info_map() override; // shared
dchengae36a4a2014-10-21 12:36:3661 QuotaService* quota_service() override; // shared
treib926ee2d2015-08-06 10:55:4262 AppSorting* app_sorting() override; // shared
[email protected]59b0e602014-01-30 00:41:2463
dchengae36a4a2014-10-21 12:36:3664 void RegisterExtensionWithRequestContexts(
rockot494f0072015-07-29 17:58:0765 const Extension* extension,
danakjf6d89bf2020-01-07 01:21:2966 base::OnceClosure callback) override;
[email protected]59b0e602014-01-30 00:41:2467
dchengae36a4a2014-10-21 12:36:3668 void UnregisterExtensionWithRequestContexts(
[email protected]59b0e602014-01-30 00:41:2469 const std::string& extension_id,
limasdf0deef2042017-05-03 19:17:1770 const UnloadedExtensionReason reason) override;
[email protected]59b0e602014-01-30 00:41:2471
Christopher Lamebb90202019-04-04 03:42:3672 const base::OneShotEvent& ready() const override;
dchengae36a4a2014-10-21 12:36:3673 ContentVerifier* content_verifier() override; // shared
dchengc963c7142016-04-08 03:55:2274 std::unique_ptr<ExtensionSet> GetDependentExtensions(
mostynba15bee12014-10-04 00:40:3275 const Extension* extension) override;
asargent631a99a2015-10-15 21:51:4876 void InstallUpdate(const std::string& extension_id,
Minh X. Nguyen30975342017-12-04 22:02:4177 const std::string& public_key,
78 const base::FilePath& unpacked_dir,
Minh X. Nguyen039eb992018-06-26 20:12:1379 bool install_immediately,
Minh X. Nguyen30975342017-12-04 22:02:4180 InstallUpdateCallback install_update_callback) override;
Minh X. Nguyenb4fbf922018-01-29 18:28:1081 bool FinishDelayedInstallationIfReady(const std::string& extension_id,
82 bool install_immediately) override;
[email protected]59b0e602014-01-30 00:41:2483
84 private:
85 friend class ExtensionSystemSharedFactory;
86
87 // Owns the Extension-related systems that have a single instance
88 // shared between normal and incognito profiles.
Devlin Croninc5c5a0c2018-08-15 04:04:1089 class Shared : public KeyedService {
[email protected]59b0e602014-01-30 00:41:2490 public:
91 explicit Shared(Profile* profile);
dchengae36a4a2014-10-21 12:36:3692 ~Shared() override;
[email protected]59b0e602014-01-30 00:41:2493
94 // Initialization takes place in phases.
95 virtual void InitPrefs();
96 // This must not be called until all the providers have been created.
97 void RegisterManagementPolicyProviders();
xiyuanf6a4c6a62016-04-19 18:14:5498 void InitInstallGates();
[email protected]59b0e602014-01-30 00:41:2499 void Init(bool extensions_enabled);
100
[email protected]b33f0b112014-03-13 17:05:30101 // KeyedService implementation.
dchengae36a4a2014-10-21 12:36:36102 void Shutdown() override;
[email protected]59b0e602014-01-30 00:41:24103
104 StateStore* state_store();
105 StateStore* rules_store();
cmumford6ae8d462016-03-24 20:35:27106 scoped_refptr<ValueStoreFactory> store_factory() const;
[email protected]59b0e602014-01-30 00:41:24107 ExtensionService* extension_service();
108 RuntimeData* runtime_data();
109 ManagementPolicy* management_policy();
rdevlin.croninf5863da2015-09-10 19:21:45110 ServiceWorkerManager* service_worker_manager();
[email protected]15ad2ee2014-08-15 19:15:26111 SharedUserScriptMaster* shared_user_script_master();
[email protected]59b0e602014-01-30 00:41:24112 InfoMap* info_map();
[email protected]aab23102014-02-05 18:57:55113 QuotaService* quota_service();
treib926ee2d2015-08-06 10:55:42114 AppSorting* app_sorting();
Christopher Lamebb90202019-04-04 03:42:36115 const base::OneShotEvent& ready() const { return ready_; }
[email protected]fd3df7782014-05-08 23:54:27116 ContentVerifier* content_verifier();
[email protected]59b0e602014-01-30 00:41:24117
118 private:
[email protected]59b0e602014-01-30 00:41:24119 Profile* profile_;
120
121 // The services that are shared between normal and incognito profiles.
122
dchengc963c7142016-04-08 03:55:22123 std::unique_ptr<StateStore> state_store_;
124 std::unique_ptr<StateStoreNotificationObserver>
[email protected]479e3922014-07-30 07:12:57125 state_store_notification_observer_;
dchengc963c7142016-04-08 03:55:22126 std::unique_ptr<StateStore> rules_store_;
cmumford6ae8d462016-03-24 20:35:27127 scoped_refptr<ValueStoreFactoryImpl> store_factory_;
dchengc963c7142016-04-08 03:55:22128 std::unique_ptr<NavigationObserver> navigation_observer_;
129 std::unique_ptr<ServiceWorkerManager> service_worker_manager_;
[email protected]15ad2ee2014-08-15 19:15:26130 // Shared memory region manager for scripts statically declared in extension
131 // manifests. This region is shared between all extensions.
dchengc963c7142016-04-08 03:55:22132 std::unique_ptr<SharedUserScriptMaster> shared_user_script_master_;
133 std::unique_ptr<RuntimeData> runtime_data_;
[email protected]59b0e602014-01-30 00:41:24134 // ExtensionService depends on StateStore, Blacklist and RuntimeData.
dchengc963c7142016-04-08 03:55:22135 std::unique_ptr<ExtensionService> extension_service_;
136 std::unique_ptr<ManagementPolicy> management_policy_;
[email protected]59b0e602014-01-30 00:41:24137 // extension_info_map_ needs to outlive process_manager_.
138 scoped_refptr<InfoMap> extension_info_map_;
dchengc963c7142016-04-08 03:55:22139 std::unique_ptr<QuotaService> quota_service_;
140 std::unique_ptr<AppSorting> app_sorting_;
xiyuanf6a4c6a62016-04-19 18:14:54141 std::unique_ptr<InstallGate> update_install_gate_;
[email protected]59b0e602014-01-30 00:41:24142
[email protected]fd3df7782014-05-08 23:54:27143 // For verifying the contents of extensions read from disk.
144 scoped_refptr<ContentVerifier> content_verifier_;
145
dchengc963c7142016-04-08 03:55:22146 std::unique_ptr<UninstallPingSender> uninstall_ping_sender_;
asargent8380bd392016-03-21 23:47:33147
[email protected]59b0e602014-01-30 00:41:24148#if defined(OS_CHROMEOS)
dchengc963c7142016-04-08 03:55:22149 std::unique_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider>
[email protected]59b0e602014-01-30 00:41:24150 device_local_account_management_policy_provider_;
antrim58769562016-11-14 14:48:41151 std::unique_ptr<chromeos::SigninScreenPolicyProvider>
152 signin_screen_policy_provider_;
xiyuana0a6aaaa2016-04-19 23:34:16153 std::unique_ptr<InstallGate> kiosk_app_update_install_gate_;
[email protected]59b0e602014-01-30 00:41:24154#endif
155
Christopher Lamebb90202019-04-04 03:42:36156 base::OneShotEvent ready_;
[email protected]59b0e602014-01-30 00:41:24157 };
158
[email protected]59b0e602014-01-30 00:41:24159 Profile* profile_;
160
161 Shared* shared_;
162
[email protected]59b0e602014-01-30 00:41:24163 DISALLOW_COPY_AND_ASSIGN(ExtensionSystemImpl);
164};
165
166} // namespace extensions
167
168#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_SYSTEM_IMPL_H_