#include "chrome/browser/profiles/delete_profile_helper.h"
#include <memory>
#include "base/check.h"
#include "base/check_is_test.h"
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/json/values_util.h"
#include "base/logging.h"
#include "base/task/thread_pool.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_features.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_core_service.h"
#include "chrome/browser/download/download_core_service_factory.h"
#include "chrome/browser/profiles/keep_alive/profile_keep_alive_types.h"
#include "chrome/browser/profiles/nuke_profile_directory_utils.h"
#include "chrome/browser/profiles/profile_attributes_entry.h"
#include "chrome/browser/profiles/profile_attributes_storage.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/sync/sync_service_factory.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/pref_names.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/signin/public/identity_manager/identity_manager.h"
#include "components/signin/public/identity_manager/primary_account_mutator.h"
#include "components/sync/service/sync_service.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
namespace {
void ProfileCleanedUp(base::Value profile_path_value) { … }
void RemoveFromLastActiveProfilesPrefList(const base::FilePath& path) { … }
bool IsRegisteredAsEphemeral(ProfileAttributesStorage* storage,
const base::FilePath& profile_dir) { … }
void DisableSyncForProfileDeletion(Profile* profile) { … }
}
DeleteProfileHelper::DeleteProfileHelper(ProfileManager& profile_manager)
: … { … }
DeleteProfileHelper::~DeleteProfileHelper() = default;
void DeleteProfileHelper::MaybeScheduleProfileForDeletion(
const base::FilePath& profile_dir,
ProfileLoadedCallback callback,
ProfileMetrics::ProfileDelete deletion_source) { … }
void DeleteProfileHelper::ScheduleEphemeralProfileForDeletion(
const base::FilePath& profile_dir,
std::unique_ptr<ScopedProfileKeepAlive> keep_alive) { … }
void DeleteProfileHelper::CleanUpEphemeralProfiles() { … }
void DeleteProfileHelper::CleanUpDeletedProfiles() { … }
void DeleteProfileHelper::EnsureActiveProfileExistsBeforeDeletion(
std::unique_ptr<ScopedKeepAlive> keep_alive,
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive,
ProfileLoadedCallback callback,
const base::FilePath& profile_dir) { … }
void DeleteProfileHelper::FinishDeletingProfile(
const base::FilePath& profile_dir,
const base::FilePath& new_active_profile_dir,
std::unique_ptr<ScopedProfileKeepAlive> keep_alive) { … }
void DeleteProfileHelper::OnLoadProfileForProfileDeletion(
const base::FilePath& profile_dir,
std::unique_ptr<ScopedProfileKeepAlive> keep_alive,
Profile* profile) { … }
void DeleteProfileHelper::OnNewActiveProfileInitialized(
const base::FilePath& profile_to_delete_path,
const base::FilePath& new_active_profile_path,
ProfileLoadedCallback callback,
std::unique_ptr<ScopedKeepAlive> keep_alive,
std::unique_ptr<ScopedProfileKeepAlive> profile_keep_alive,
Profile* loaded_profile) { … }