#include "components/component_updater/component_installer.h"
#include <cstdint>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "base/strings/string_util.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/task_traits.h"
#include "base/task/thread_pool.h"
#include "base/values.h"
#include "base/version.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "components/component_updater/component_updater_paths.h"
#include "components/component_updater/component_updater_service.h"
#include "components/crx_file/crx_verifier.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/update_query_params.h"
#include "components/update_client/utils.h"
#if BUILDFLAG(IS_APPLE)
#include "base/apple/backup_util.h"
#endif
namespace component_updater {
const char kNullVersion[] = …;
namespace {
Result;
InstallError;
}
ComponentInstallerPolicy::~ComponentInstallerPolicy() = default;
bool ComponentInstallerPolicy::AllowCachedCopies() const { … }
bool ComponentInstallerPolicy::AllowUpdatesOnMeteredConnections() const { … }
bool ComponentInstallerPolicy::AllowUpdates() const { … }
ComponentInstaller::RegistrationInfo::RegistrationInfo()
: … { … }
ComponentInstaller::RegistrationInfo::~RegistrationInfo() = default;
ComponentInstaller::ComponentInstaller(
std::unique_ptr<ComponentInstallerPolicy> installer_policy,
scoped_refptr<update_client::ActionHandler> action_handler,
base::TaskPriority task_priority)
: … { … }
ComponentInstaller::~ComponentInstaller() = default;
void ComponentInstaller::Register(ComponentUpdateService* cus,
base::OnceClosure callback) { … }
void ComponentInstaller::Register(
RegisterCallback register_callback,
base::OnceClosure callback,
const base::Version& registered_version,
const base::Version& max_previous_product_version) { … }
void ComponentInstaller::OnUpdateError(int error) { … }
Result ComponentInstaller::InstallHelper(const base::FilePath& unpack_path,
base::Value::Dict* manifest,
base::Version* version,
base::FilePath* install_path) { … }
void ComponentInstaller::Install(
const base::FilePath& unpack_path,
const std::string& ,
std::unique_ptr<InstallParams> ,
ProgressCallback ,
Callback callback) { … }
bool ComponentInstaller::GetInstalledFile(const std::string& file,
base::FilePath* installed_file) { … }
bool ComponentInstaller::Uninstall() { … }
bool ComponentInstaller::FindPreinstallation(
const base::FilePath& root,
scoped_refptr<RegistrationInfo> registration_info) { … }
std::optional<base::Value::Dict>
ComponentInstaller::GetValidInstallationManifest(const base::FilePath& path) { … }
std::optional<base::Version> ComponentInstaller::SelectComponentVersion(
const base::Version& registered_version,
const base::Version& max_previous_product_version,
const base::FilePath& base_dir,
scoped_refptr<RegistrationInfo> registration_info) { … }
void ComponentInstaller::DeleteUnselectedComponentVersions(
const base::FilePath& base_dir,
const std::optional<base::Version>& selected_version) { … }
std::optional<base::FilePath> ComponentInstaller::GetComponentDirectory() { … }
void ComponentInstaller::StartRegistration(
const base::Version& registered_version,
const base::Version& max_previous_product_version,
scoped_refptr<RegistrationInfo> registration_info) { … }
void ComponentInstaller::UninstallOnTaskRunner() { … }
void ComponentInstaller::FinishRegistration(
scoped_refptr<RegistrationInfo> registration_info,
RegisterCallback register_callback,
base::OnceClosure callback) { … }
void ComponentInstaller::ComponentReady(base::Value::Dict manifest) { … }
}