#include "chrome/browser/web_applications/commands/dedupe_install_urls_command.h"
#include "base/barrier_closure.h"
#include "base/containers/extend.h"
#include "base/containers/flat_map.h"
#include "base/containers/flat_set.h"
#include "base/functional/callback_helpers.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/to_string.h"
#include "chrome/browser/web_applications/callback_utils.h"
#include "chrome/browser/web_applications/jobs/uninstall/remove_install_url_job.h"
#include "chrome/browser/web_applications/locks/all_apps_lock.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/browser/web_applications/web_app_constants.h"
#include "chrome/browser/web_applications/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_install_finalizer.h"
#include "chrome/browser/web_applications/web_app_registrar.h"
#include "chrome/browser/web_applications/web_app_registry_update.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
namespace web_app {
ExternalManagementConfig;
ExternalConfigMap;
namespace {
bool g_suppress_for_testing = …;
base::flat_map<GURL, base::flat_set<webapps::AppId>> BuildInstallUrlToAppIdsMap(
const WebAppRegistrar& registrar,
base::Value::Dict& debug_value) { … }
const webapps::AppId& SelectWebAppToDedupeInto(
const WebAppRegistrar& registrar,
const base::flat_set<webapps::AppId>& app_ids_with_common_install_url) { … }
std::vector<std::unique_ptr<RemoveInstallUrlJob>>
BuildOperationsToDedupeInstallUrlConfigsIntoSelectedApp(
Profile& profile,
base::Value::Dict& jobs_debug_value,
const WebAppRegistrar& registrar,
ScopedRegistryUpdate& update,
const GURL& install_url,
const base::flat_set<webapps::AppId>& app_ids_with_common_install_url,
const webapps::AppId& id_to_dedupe_into) { … }
struct DedupeOperations { … };
DedupeOperations BuildOperationsToHaveOneAppPerInstallUrl(
Profile& profile,
base::Value::Dict& debug_value,
const WebAppRegistrar& registrar,
ScopedRegistryUpdate& update,
base::flat_map<GURL, base::flat_set<webapps::AppId>> install_url_to_apps) { … }
}
base::AutoReset<bool> DedupeInstallUrlsCommand::ScopedSuppressForTesting() { … }
DedupeInstallUrlsCommand::DedupeInstallUrlsCommand(
Profile& profile,
base::OnceClosure completed_callback)
: … { … }
DedupeInstallUrlsCommand::~DedupeInstallUrlsCommand() = default;
void DedupeInstallUrlsCommand::StartWithLock(
std::unique_ptr<AllAppsLock> lock) { … }
void DedupeInstallUrlsCommand::ProcessPendingJobsOrComplete() { … }
void DedupeInstallUrlsCommand::JobComplete(webapps::UninstallResultCode code) { … }
void DedupeInstallUrlsCommand::RecordMetrics() { … }
}