#include "chrome/browser/downgrade/downgrade_manager.h"
#include <iterator>
#include <optional>
#include <string_view>
#include <utility>
#include "base/command_line.h"
#include "base/enterprise_util.h"
#include "base/files/file_enumerator.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/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/syslog_logging.h"
#include "base/task/thread_pool.h"
#include "base/version.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/downgrade/downgrade_utils.h"
#include "chrome/browser/downgrade/snapshot_manager.h"
#include "chrome/browser/downgrade/user_data_downgrade.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/enterprise/browser/controller/browser_dm_token_storage.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "components/version_info/version_info_values.h"
#include "content/public/browser/browser_thread.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/installer/util/install_util.h"
#endif
namespace downgrade {
namespace {
bool g_snapshots_enabled_for_testing = …;
void MoveUserData(const base::FilePath& source, const base::FilePath& target) { … }
void MoveCache(const base::FilePath& disk_cache_dir) { … }
void DeleteAllRenamedUserDirectories(const base::FilePath& dir,
const base::FilePath& name) { … }
void DeleteMovedUserData(const base::FilePath& user_data_dir,
const base::FilePath& disk_cache_dir) { … }
bool UserDataSnapshotEnabled() { … }
#if BUILDFLAG(IS_WIN)
bool IsAdministratorDrivenDowngrade(uint16_t current_milestone) {
const auto downgrade_version = InstallUtil::GetDowngradeVersion();
return downgrade_version &&
downgrade_version->components()[0] > current_milestone;
}
#endif
}
bool DowngradeManager::PrepareUserDataDirectoryForCurrentVersion(
const base::FilePath& user_data_dir) { … }
void DowngradeManager::UpdateLastVersion(const base::FilePath& user_data_dir) { … }
void DowngradeManager::DeleteMovedUserDataSoon(
const base::FilePath& user_data_dir) { … }
void DowngradeManager::ProcessDowngrade(const base::FilePath& user_data_dir) { … }
void DowngradeManager::EnableSnapshotsForTesting(bool enable) { … }
DowngradeManager::Type DowngradeManager::GetDowngradeType(
const base::FilePath& user_data_dir,
const base::Version& current_version,
const base::Version& last_version) { … }
DowngradeManager::Type DowngradeManager::GetDowngradeTypeWithSnapshot(
const base::FilePath& user_data_dir,
const base::Version& current_version,
const base::Version& last_version) { … }
}