#include "chrome/browser/extensions/manifest_v2_experiment_manager.h"
#include "base/functional/callback_forward.h"
#include "base/metrics/histogram_functions.h"
#include "base/one_shot_event.h"
#include "base/strings/stringprintf.h"
#include "base/types/pass_key.h"
#include "chrome/browser/extensions/extension_management.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system_factory.h"
#include "chrome/browser/extensions/mv2_experiment_stage.h"
#include "chrome/browser/extensions/profile_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_keyed_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "extensions/browser/disable_reason.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_prefs_factory.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_factory.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/pref_names.h"
#include "extensions/browser/pref_types.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_features.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
namespace extensions {
namespace {
bool g_allow_mv2_for_testing = …;
const char* GetHistogramManifestLocation(mojom::ManifestLocation location) { … }
constexpr PrefMap kMV2DeprecationExtensionWarningAcknowledgedPref = …;
constexpr PrefMap kMV2DeprecationExtensionDisabledAcknowledgedPref = …;
constexpr PrefMap kMV2DeprecationDidDisablePref = …;
constexpr PrefMap kMV2DeprecationUserReEnabledPref = …;
class ManifestV2ExperimentManagerFactory : public ProfileKeyedServiceFactory { … };
ManifestV2ExperimentManagerFactory::ManifestV2ExperimentManagerFactory()
: … { … }
ManifestV2ExperimentManager*
ManifestV2ExperimentManagerFactory::GetForBrowserContext(
content::BrowserContext* browser_context) { … }
KeyedService* ManifestV2ExperimentManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const { … }
bool ManifestV2ExperimentManagerFactory::ServiceIsCreatedWithBrowserContext()
const { … }
MV2ExperimentStage CalculateCurrentExperimentStage() { … }
PrefMap GetExtensionAcknowledgedPrefFor(MV2ExperimentStage experiment_stage) { … }
PrefMap GetGlobalNoticeAcknowledgedPrefFor(
MV2ExperimentStage experiment_stage) { … }
bool ShouldDisableExtensionsForExperimentStage(MV2ExperimentStage stage) { … }
}
ManifestV2ExperimentManager::ManifestV2ExperimentManager(
content::BrowserContext* browser_context)
: … { … }
ManifestV2ExperimentManager::~ManifestV2ExperimentManager() = default;
ManifestV2ExperimentManager* ManifestV2ExperimentManager::Get(
content::BrowserContext* browser_context) { … }
BrowserContextKeyedServiceFactory* ManifestV2ExperimentManager::GetFactory() { … }
MV2ExperimentStage ManifestV2ExperimentManager::GetCurrentExperimentStage() { … }
bool ManifestV2ExperimentManager::IsExtensionAffected(
const Extension& extension) { … }
bool ManifestV2ExperimentManager::ShouldBlockExtensionInstallation(
const ExtensionId& extension_id,
int manifest_version,
Manifest::Type manifest_type,
mojom::ManifestLocation manifest_location,
const HashedExtensionId& hashed_id) { … }
bool ManifestV2ExperimentManager::DidUserAcknowledgeNotice(
const ExtensionId& extension_id) { … }
void ManifestV2ExperimentManager::MarkNoticeAsAcknowledged(
const ExtensionId& extension_id) { … }
bool ManifestV2ExperimentManager::DidUserAcknowledgeNoticeGlobally() { … }
void ManifestV2ExperimentManager::MarkNoticeAsAcknowledgedGlobally() { … }
ExtensionPrefs* ManifestV2ExperimentManager::extension_prefs() { … }
void ManifestV2ExperimentManager::OnExtensionSystemReady() { … }
base::CallbackListSubscription
ManifestV2ExperimentManager::RegisterOnManagerReadyCallback(
base::RepeatingClosure callback) { … }
void ManifestV2ExperimentManager::SetHasTriggeredDisabledDialog(
bool has_triggered) { … }
void ManifestV2ExperimentManager::DisableAffectedExtensions() { … }
void ManifestV2ExperimentManager::CheckDisabledExtensions() { … }
void ManifestV2ExperimentManager::MaybeReEnableExtension(
const Extension& extension) { … }
bool ManifestV2ExperimentManager::DidUserReEnableExtension(
const ExtensionId& extension_id) { … }
void ManifestV2ExperimentManager::EmitMetricsForProfileReady() { … }
void ManifestV2ExperimentManager::RecordUkmForExtension(
const GURL& extension_url,
ExtensionMV2DeprecationAction action) { … }
void ManifestV2ExperimentManager::OnExtensionLoaded(
content::BrowserContext* browser_context,
const Extension* extension) { … }
void ManifestV2ExperimentManager::OnExtensionInstalled(
content::BrowserContext* browser_context,
const Extension* extension,
bool is_update) { … }
void ManifestV2ExperimentManager::OnExtensionUninstalled(
content::BrowserContext* browser_context,
const Extension* extension,
UninstallReason uninstall_reason) { … }
void ManifestV2ExperimentManager::OnManagementPolicyChanged() { … }
bool ManifestV2ExperimentManager::DidUserReEnableExtensionForTesting(
const ExtensionId& extension_id) { … }
void ManifestV2ExperimentManager::DisableAffectedExtensionsForTesting() { … }
void ManifestV2ExperimentManager::EmitMetricsForProfileReadyForTesting() { … }
base::AutoReset<bool> ManifestV2ExperimentManager::AllowMV2ExtensionsForTesting(
base::PassKey<ScopedTestMV2Enabler> pass_key) { … }
}