chromium/chrome/browser/extensions/manifest_v2_experiment_manager.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// Whether to override the MV2 deprecation for testing purposes.
bool g_allow_mv2_for_testing =;

// Returns the suffix to use for histograms related to the manifest location
// grouping.
const char* GetHistogramManifestLocation(mojom::ManifestLocation location) {}

// Stores the bit for whether the user has acknowledged the MV2 deprecation
// notice for a given extension in the warning stage.
constexpr PrefMap kMV2DeprecationExtensionWarningAcknowledgedPref =;

// Stores the bit for whether the user has acknowledged the MV2 deprecation
// notice for a given extension in the disabled stage.
constexpr PrefMap kMV2DeprecationExtensionDisabledAcknowledgedPref =;

// Stores a bit for whether the extension has been disabled as part of the
// MV2 deprecation.
constexpr PrefMap kMV2DeprecationDidDisablePref =;

// Stores a bit for whether the extension was re-enabled after being previously
// disabled as part of the MV2 deprecation.
// We store this separately from kMV2DeprecationDidDisablePref (as opposed to
// relying on an enum or a single bool) since there are multiple phases and
// causes for extensions to be disabled and re-enabled, and we only want to
// record that a user re-enables it if it was explicitly disabled by this phase
// of the experiment.
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 {}

// Determines the current stage of the MV2 deprecation experiments.
MV2ExperimentStage CalculateCurrentExperimentStage() {}

// Returns the pref that stores whether the user has acknowledged the MV2
// deprecation notice for a given extension in `experiment_stage`.
PrefMap GetExtensionAcknowledgedPrefFor(MV2ExperimentStage experiment_stage) {}

// Returns the pref that stores whether the user has acknowledged the MV2
// deprecation global notice in `experiment_stage`.
PrefMap GetGlobalNoticeAcknowledgedPrefFor(
    MV2ExperimentStage experiment_stage) {}

// Returns true if extensions should be disabled if the user is in the given
// `stage` of the MV2 experiments. Extracted into this method to make it easier
// to update as we add more stages.
bool ShouldDisableExtensionsForExperimentStage(MV2ExperimentStage stage) {}

}  // namespace

ManifestV2ExperimentManager::ManifestV2ExperimentManager(
    content::BrowserContext* browser_context)
    :{}

ManifestV2ExperimentManager::~ManifestV2ExperimentManager() = default;

// static
ManifestV2ExperimentManager* ManifestV2ExperimentManager::Get(
    content::BrowserContext* browser_context) {}

// static
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) {}

}  // namespace extensions