#include "chrome/browser/extensions/extension_management.h"
#include <memory>
#include <string>
#include <utility>
#include "base/containers/contains.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/observer_list.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/syslog_logging.h"
#include "base/trace_event/trace_event.h"
#include "base/values.h"
#include "base/version.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/cws_info_service.h"
#include "chrome/browser/extensions/extension_management_constants.h"
#include "chrome/browser/extensions/extension_management_internal.h"
#include "chrome/browser/extensions/external_policy_loader.h"
#include "chrome/browser/extensions/external_provider_impl.h"
#include "chrome/browser/extensions/forced_extensions/install_stage_tracker_factory.h"
#include "chrome/browser/extensions/permissions_based_management_policy_provider.h"
#include "chrome/browser/extensions/standard_management_policy_provider.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/pref_names.h"
#include "components/crx_file/id_util.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/pref_names.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "extensions/common/extension_urls.h"
#include "extensions/common/manifest_constants.h"
#include "extensions/common/manifest_url_handlers.h"
#include "extensions/common/permissions/api_permission_set.h"
#include "extensions/common/permissions/permission_set.h"
#include "extensions/common/url_pattern.h"
#include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#else
#include "components/enterprise/browser/reporting/common_pref_names.h"
#endif
namespace extensions {
ExtensionManagement::ExtensionManagement(Profile* profile)
: … { … }
ExtensionManagement::~ExtensionManagement() = default;
void ExtensionManagement::Shutdown() { … }
void ExtensionManagement::AddObserver(Observer* observer) { … }
void ExtensionManagement::RemoveObserver(Observer* observer) { … }
const std::vector<std::unique_ptr<ManagementPolicy::Provider>>&
ExtensionManagement::GetProviders() const { … }
bool ExtensionManagement::BlocklistedByDefault() const { … }
ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode(
const Extension* extension) { … }
ExtensionManagement::InstallationMode ExtensionManagement::GetInstallationMode(
const ExtensionId& extension_id,
const std::string& update_url) { … }
base::Value::Dict ExtensionManagement::GetForceInstallList() const { … }
base::Value::Dict ExtensionManagement::GetRecommendedInstallList() const { … }
bool ExtensionManagement::HasAllowlistedExtension() { … }
bool ExtensionManagement::IsUpdateUrlOverridden(const ExtensionId& id) { … }
GURL ExtensionManagement::GetEffectiveUpdateURL(const Extension& extension) { … }
bool ExtensionManagement::UpdatesFromWebstore(const Extension& extension) { … }
bool ExtensionManagement::IsInstallationExplicitlyAllowed(
const ExtensionId& id) { … }
bool ExtensionManagement::IsInstallationExplicitlyBlocked(
const ExtensionId& id) { … }
bool ExtensionManagement::IsOffstoreInstallAllowed(
const GURL& url,
const GURL& referrer_url) const { … }
bool ExtensionManagement::IsAllowedManifestType(
Manifest::Type manifest_type,
const std::string& extension_id) const { … }
bool ExtensionManagement::IsAllowedManifestVersion(
int manifest_version,
const std::string& extension_id,
Manifest::Type manifest_type) { … }
bool ExtensionManagement::IsAllowedManifestVersion(const Extension* extension) { … }
bool ExtensionManagement::IsExemptFromMV2DeprecationByPolicy(
int manifest_version,
const std::string& extension_id,
Manifest::Type manifest_type) { … }
bool ExtensionManagement::IsAllowedByUnpublishedAvailabilityPolicy(
const Extension* extension) { … }
APIPermissionSet ExtensionManagement::GetBlockedAPIPermissions(
const Extension* extension) { … }
APIPermissionSet ExtensionManagement::GetBlockedAPIPermissions(
const ExtensionId& extension_id,
const std::string& update_url) { … }
const URLPatternSet& ExtensionManagement::GetDefaultPolicyBlockedHosts() const { … }
const URLPatternSet& ExtensionManagement::GetDefaultPolicyAllowedHosts() const { … }
const URLPatternSet& ExtensionManagement::GetPolicyBlockedHosts(
const Extension* extension) { … }
const URLPatternSet& ExtensionManagement::GetPolicyAllowedHosts(
const Extension* extension) { … }
bool ExtensionManagement::UsesDefaultPolicyHostRestrictions(
const Extension* extension) { … }
std::unique_ptr<const PermissionSet> ExtensionManagement::GetBlockedPermissions(
const Extension* extension) { … }
bool ExtensionManagement::IsPermissionSetAllowed(const Extension* extension,
const PermissionSet& perms) { … }
bool ExtensionManagement::IsPermissionSetAllowed(
const ExtensionId& extension_id,
const std::string& update_url,
const PermissionSet& perms) { … }
const std::string ExtensionManagement::BlockedInstallMessage(
const ExtensionId& id) { … }
ExtensionIdSet ExtensionManagement::GetForcePinnedList() const { … }
bool ExtensionManagement::IsFileUrlNavigationAllowed(const ExtensionId& id) { … }
bool ExtensionManagement::CheckMinimumVersion(const Extension* extension,
std::string* required_version) { … }
void ExtensionManagement::Refresh() { … }
bool ExtensionManagement::ParseById(const std::string& extension_id,
const base::Value::Dict& subdict) { … }
internal::IndividualSettings* ExtensionManagement::GetSettingsForId(
const std::string& extension_id) { … }
void ExtensionManagement::LoadDeferredExtensionSetting(
const std::string& extension_id) { … }
const base::Value* ExtensionManagement::LoadPreference(
const char* pref_name,
bool force_managed,
base::Value::Type expected_type) const { … }
const base::Value::Dict* ExtensionManagement::LoadDictPreference(
const char* pref_name,
bool force_managed) const { … }
const base::Value::List* ExtensionManagement::LoadListPreference(
const char* pref_name,
bool force_managed) const { … }
void ExtensionManagement::OnExtensionPrefChanged() { … }
void ExtensionManagement::NotifyExtensionManagementPrefChanged() { … }
void ExtensionManagement::ReportExtensionManagementInstallCreationStage(
InstallStageTracker::InstallCreationStage forced_stage,
InstallStageTracker::InstallCreationStage other_stage) { … }
base::Value::Dict ExtensionManagement::GetInstallListByMode(
InstallationMode installation_mode) const { … }
void ExtensionManagement::UpdateForcedExtensions(
const base::Value::Dict* extension_dict) { … }
internal::IndividualSettings* ExtensionManagement::AccessById(
const ExtensionId& id) { … }
internal::IndividualSettings* ExtensionManagement::AccessByUpdateUrl(
const std::string& update_url) { … }
ExtensionManagement* ExtensionManagementFactory::GetForBrowserContext(
content::BrowserContext* context) { … }
ExtensionManagementFactory* ExtensionManagementFactory::GetInstance() { … }
ExtensionManagementFactory::ExtensionManagementFactory()
: … { … }
ExtensionManagementFactory::~ExtensionManagementFactory() { … }
std::unique_ptr<KeyedService>
ExtensionManagementFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const { … }
void ExtensionManagementFactory::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* user_prefs) { … }
}