#include "chrome/browser/extensions/api/storage/managed_value_store_cache.h"
#include <memory>
#include <utility>
#include "base/memory/raw_ptr.h"
#include "base/one_shot_event.h"
#include "base/scoped_observation.h"
#include "base/sequence_checker.h"
#include "base/task/sequenced_task_runner.h"
#include "base/types/expected.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/api/storage/policy_value_store.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/schema_registry_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/storage/storage_schema_manifest_handler.h"
#include "components/policy/core/common/schema.h"
#include "components/policy/core/common/schema_map.h"
#include "components/policy/core/common/schema_registry.h"
#include "components/value_store/value_store_factory.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/browser/api/storage/backend_task_runner.h"
#include "extensions/browser/api/storage/value_store_util.h"
#include "extensions/browser/extension_file_task_runner.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_id.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/manifest.h"
#include "extensions/common/manifest_constants.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#endif
BrowserContext;
BrowserThread;
namespace extensions {
class ExtensionRegistry;
namespace {
const value_store_util::ModelType kManagedModelType = …;
}
class ManagedValueStoreCache::ExtensionTracker
: public ExtensionRegistryObserver { … };
ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(
Profile* profile,
policy::PolicyDomain policy_domain)
: … { … }
void ManagedValueStoreCache::ExtensionTracker::OnExtensionWillBeInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update,
const std::string& old_name) { … }
void ManagedValueStoreCache::ExtensionTracker::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const Extension* extension,
extensions::UninstallReason reason) { … }
void ManagedValueStoreCache::ExtensionTracker::OnExtensionsReady() { … }
void ManagedValueStoreCache::ExtensionTracker::LoadSchemas(ExtensionSet added) { … }
bool ManagedValueStoreCache::ExtensionTracker::UsesManagedStorage(
const Extension* extension) const { … }
void ManagedValueStoreCache::ExtensionTracker::LoadSchemasOnFileTaskRunner(
ExtensionSet extensions,
base::WeakPtr<ExtensionTracker> self) { … }
void ManagedValueStoreCache::ExtensionTracker::Register(
const policy::ComponentMap* components) { … }
ManagedValueStoreCache::ManagedValueStoreCache(
Profile& profile,
scoped_refptr<value_store::ValueStoreFactory> factory,
SettingsChangedCallback observer)
: … { … }
ManagedValueStoreCache::~ManagedValueStoreCache() { … }
policy::PolicyDomain ManagedValueStoreCache::policy_domain() const { … }
void ManagedValueStoreCache::ShutdownOnUI() { … }
void ManagedValueStoreCache::RunWithValueStoreForExtension(
StorageCallback callback,
scoped_refptr<const Extension> extension) { … }
void ManagedValueStoreCache::DeleteStorageSoon(
const ExtensionId& extension_id) { … }
void ManagedValueStoreCache::OnPolicyServiceInitialized(
policy::PolicyDomain domain) { … }
void ManagedValueStoreCache::InitializeOnBackend() { … }
void ManagedValueStoreCache::OnPolicyUpdated(const policy::PolicyNamespace& ns,
const policy::PolicyMap& previous,
const policy::PolicyMap& current) { … }
policy::PolicyDomain ManagedValueStoreCache::GetPolicyDomain(
const Profile& profile) { … }
void ManagedValueStoreCache::UpdatePolicyOnBackend(
const ExtensionId& extension_id,
const policy::PolicyMap& new_policy) { … }
PolicyValueStore& ManagedValueStoreCache::GetOrCreateStore(
const ExtensionId& extension_id) { … }
bool ManagedValueStoreCache::HasStore(const ExtensionId& extension_id) const { … }
}