1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_SYSTEM_H_
#define CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_SYSTEM_H_
#include <string>
#include "base/memory/raw_ptr.h"
#include "base/one_shot_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/unloaded_extension_reason.h"
class Profile;
#if BUILDFLAG(IS_CHROMEOS)
namespace extensions {
class ExtensionsPermissionsTracker;
} // namespace extensions
namespace chromeos {
class DeviceLocalAccountManagementPolicyProvider;
class SigninScreenPolicyProvider;
} // namespace chromeos
#endif // BUILDFLAG(IS_CHROMEOS)
namespace value_store {
class ValueStoreFactory;
class ValueStoreFactoryImpl;
} // namespace value_store
namespace extensions {
class ChromeExtensionSystemSharedFactory;
class UninstallPingSender;
class InstallGate;
// The ExtensionSystem for ProfileImpl and OffTheRecordProfileImpl.
// Implementation details: non-shared services are owned by
// ChromeExtensionSystem, a KeyedService with separate incognito
// instances. A private Shared class (also a KeyedService,
// but with a shared instance for incognito) keeps the common services.
class ChromeExtensionSystem : public ExtensionSystem {
public:
using InstallUpdateCallback = ExtensionSystem::InstallUpdateCallback;
explicit ChromeExtensionSystem(Profile* profile);
ChromeExtensionSystem(const ChromeExtensionSystem&) = delete;
ChromeExtensionSystem& operator=(const ChromeExtensionSystem&) = delete;
~ChromeExtensionSystem() override;
// KeyedService implementation.
void Shutdown() override;
void InitForRegularProfile(bool extensions_enabled) override;
ExtensionService* extension_service() override; // shared
ManagementPolicy* management_policy() override; // shared
ServiceWorkerManager* service_worker_manager() override; // shared
UserScriptManager* user_script_manager() override; // shared
StateStore* state_store() override; // shared
StateStore* rules_store() override; // shared
StateStore* dynamic_user_scripts_store() override; // shared
scoped_refptr<value_store::ValueStoreFactory> store_factory()
override; // shared
QuotaService* quota_service() override; // shared
AppSorting* app_sorting() override; // shared
const base::OneShotEvent& ready() const override;
bool is_ready() const override;
ContentVerifier* content_verifier() override; // shared
std::unique_ptr<ExtensionSet> GetDependentExtensions(
const Extension* extension) override;
void InstallUpdate(const std::string& extension_id,
const std::string& public_key,
const base::FilePath& unpacked_dir,
bool install_immediately,
InstallUpdateCallback install_update_callback) override;
void PerformActionBasedOnOmahaAttributes(
const std::string& extension_id,
const base::Value::Dict& attributes) override;
private:
friend class ChromeExtensionSystemSharedFactory;
// Owns the Extension-related systems that have a single instance
// shared between normal and incognito profiles.
class Shared : public KeyedService {
public:
explicit Shared(Profile* profile);
~Shared() override;
// Initialization takes place in phases.
virtual void InitPrefs();
// This must not be called until all the providers have been created.
void RegisterManagementPolicyProviders();
void InitInstallGates();
void Init(bool extensions_enabled);
// KeyedService implementation.
void Shutdown() override;
StateStore* state_store();
StateStore* rules_store();
StateStore* dynamic_user_scripts_store();
scoped_refptr<value_store::ValueStoreFactory> store_factory() const;
ExtensionService* extension_service();
ManagementPolicy* management_policy();
ServiceWorkerManager* service_worker_manager();
UserScriptManager* user_script_manager();
QuotaService* quota_service();
AppSorting* app_sorting();
const base::OneShotEvent& ready() const { return ready_; }
bool is_ready() const { return ready_.is_signaled(); }
ContentVerifier* content_verifier();
private:
raw_ptr<Profile> profile_;
// The services that are shared between normal and incognito profiles.
std::unique_ptr<StateStore> state_store_;
std::unique_ptr<StateStore> rules_store_;
std::unique_ptr<StateStore> dynamic_user_scripts_store_;
scoped_refptr<value_store::ValueStoreFactoryImpl> store_factory_;
std::unique_ptr<ServiceWorkerManager> service_worker_manager_;
// Shared memory region manager for scripts statically declared in extension
// manifests. This region is shared between all extensions.
std::unique_ptr<UserScriptManager> user_script_manager_;
// ExtensionService depends on StateStore and Blocklist.
std::unique_ptr<ExtensionService> extension_service_;
std::unique_ptr<ManagementPolicy> management_policy_;
std::unique_ptr<QuotaService> quota_service_;
std::unique_ptr<AppSorting> app_sorting_;
std::unique_ptr<InstallGate> update_install_gate_;
// For verifying the contents of extensions read from disk.
scoped_refptr<ContentVerifier> content_verifier_;
std::unique_ptr<UninstallPingSender> uninstall_ping_sender_;
#if BUILDFLAG(IS_CHROMEOS)
std::unique_ptr<chromeos::DeviceLocalAccountManagementPolicyProvider>
device_local_account_management_policy_provider_;
std::unique_ptr<chromeos::SigninScreenPolicyProvider>
signin_screen_policy_provider_;
std::unique_ptr<InstallGate> kiosk_app_update_install_gate_;
std::unique_ptr<ExtensionsPermissionsTracker>
extensions_permissions_tracker_;
#endif
base::OneShotEvent ready_;
};
raw_ptr<Profile> profile_;
raw_ptr<Shared> shared_;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_CHROME_EXTENSION_SYSTEM_H_
|