#include "components/component_updater/component_updater_service.h"
#include <map>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.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/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "base/ranges/algorithm.h"
#include "base/sequence_checker.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/time.h"
#include "base/timer/timer.h"
#include "build/branding_buildflags.h"
#include "components/component_updater/component_installer.h"
#include "components/component_updater/component_updater_service_internal.h"
#include "components/component_updater/component_updater_utils.h"
#include "components/component_updater/pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/update_client/configurator.h"
#include "components/update_client/crx_update_item.h"
#include "components/update_client/update_client.h"
#include "components/update_client/update_client_errors.h"
#include "components/update_client/utils.h"
#include "url/gurl.h"
CrxInstaller;
UpdateClient;
namespace {
enum UpdateType { … };
}
namespace component_updater {
ComponentInfo::ComponentInfo(const std::string& id,
const std::string& fingerprint,
const std::u16string& name,
const base::Version& version,
const std::string& cohort_id)
: … { … }
ComponentInfo::ComponentInfo(const ComponentInfo& other) = default;
ComponentInfo& ComponentInfo::operator=(const ComponentInfo& other) = default;
ComponentInfo::ComponentInfo(ComponentInfo&& other) = default;
ComponentInfo& ComponentInfo::operator=(ComponentInfo&& other) = default;
ComponentInfo::~ComponentInfo() = default;
ComponentRegistration::ComponentRegistration(
const std::string& app_id,
const std::string& name,
std::vector<uint8_t> public_key_hash,
const base::Version& version,
const std::string& fingerprint,
std::map<std::string, std::string> installer_attributes,
scoped_refptr<update_client::ActionHandler> action_handler,
scoped_refptr<update_client::CrxInstaller> installer,
bool requires_network_encryption,
bool supports_group_policy_enable_component_updates,
bool allow_cached_copies,
bool allow_updates_on_metered_connection,
bool allow_updates)
: … { … }
ComponentRegistration::ComponentRegistration(
const ComponentRegistration& other) = default;
ComponentRegistration& ComponentRegistration::operator=(
const ComponentRegistration& other) = default;
ComponentRegistration::ComponentRegistration(ComponentRegistration&& other) =
default;
ComponentRegistration& ComponentRegistration::operator=(
ComponentRegistration&& other) = default;
ComponentRegistration::~ComponentRegistration() = default;
CrxUpdateService::CrxUpdateService(scoped_refptr<Configurator> config,
std::unique_ptr<UpdateScheduler> scheduler,
scoped_refptr<UpdateClient> update_client,
const std::string& brand)
: … { … }
CrxUpdateService::~CrxUpdateService() { … }
void CrxUpdateService::AddObserver(Observer* observer) { … }
void CrxUpdateService::RemoveObserver(Observer* observer) { … }
base::Version CrxUpdateService::GetRegisteredVersion(
const std::string& app_id) { … }
base::Version CrxUpdateService::GetMaxPreviousProductVersion(
const std::string& app_id) { … }
void CrxUpdateService::Start() { … }
void CrxUpdateService::Stop() { … }
bool CrxUpdateService::RegisterComponent(
const ComponentRegistration& component) { … }
bool CrxUpdateService::UnregisterComponent(const std::string& id) { … }
bool CrxUpdateService::DoUnregisterComponent(const std::string& id) { … }
std::vector<std::string> CrxUpdateService::GetComponentIDs() const { … }
std::vector<ComponentInfo> CrxUpdateService::GetComponents() const { … }
OnDemandUpdater& CrxUpdateService::GetOnDemandUpdater() { … }
update_client::CrxComponent CrxUpdateService::ToCrxComponent(
const ComponentRegistration& component) const { … }
std::optional<ComponentRegistration> CrxUpdateService::GetComponent(
const std::string& id) const { … }
const CrxUpdateItem* CrxUpdateService::GetComponentState(
const std::string& id) const { … }
void CrxUpdateService::MaybeThrottle(const std::string& id,
base::OnceClosure callback) { … }
void CrxUpdateService::OnDemandUpdate(const std::string& id,
Priority priority,
Callback callback) { … }
bool CrxUpdateService::OnDemandUpdateWithCooldown(const std::string& id) { … }
void CrxUpdateService::OnDemandUpdateInternal(const std::string& id,
Priority priority,
Callback callback) { … }
bool CrxUpdateService::CheckForUpdates(
UpdateScheduler::OnFinishedCallback on_finished) { … }
bool CrxUpdateService::GetComponentDetails(const std::string& id,
CrxUpdateItem* item) const { … }
void CrxUpdateService::GetCrxComponents(
const std::vector<std::string>& ids,
base::OnceCallback<void(const std::vector<std::optional<CrxComponent>>&)>
callback) { … }
void CrxUpdateService::OnUpdateComplete(Callback callback,
const base::TimeTicks& start_time,
update_client::Error error) { … }
void CrxUpdateService::OnEvent(Events event, const std::string& id) { … }
std::unique_ptr<ComponentUpdateService> ComponentUpdateServiceFactory(
scoped_refptr<Configurator> config,
std::unique_ptr<UpdateScheduler> scheduler,
const std::string& brand) { … }
void RegisterComponentUpdateServicePrefs(PrefRegistrySimple* registry) { … }
}