#include "chrome/browser/extensions/forced_extensions/install_stage_tracker.h"
#include "base/check_op.h"
#include "base/observer_list.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/extensions/forced_extensions/install_stage_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/install/sandboxed_unpacker_failure_reason.h"
#include "net/base/net_errors.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "components/user_manager/user_type.h"
#endif
namespace extensions {
namespace {
bool ShouldOverrideCurrentStage(
std::optional<InstallStageTracker::Stage> current_stage,
InstallStageTracker::Stage new_stage) { … }
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
InstallStageTracker::UserInfo::UserInfo() = default;
InstallStageTracker::UserInfo::UserInfo(const UserInfo&) = default;
InstallStageTracker::UserInfo::UserInfo(user_manager::UserType user_type,
bool is_new_user,
bool is_user_present)
: user_type(user_type),
is_new_user(is_new_user),
is_user_present(is_user_present) {}
#endif
InstallStageTracker::InstallationData::InstallationData() = default;
InstallStageTracker::InstallationData::~InstallationData() = default;
InstallStageTracker::InstallationData::InstallationData(
const InstallationData&) = default;
std::string InstallStageTracker::GetFormattedInstallationData(
const InstallationData& data) { … }
InstallStageTracker::Observer::~Observer() = default;
InstallStageTracker::InstallStageTracker(const content::BrowserContext* context)
: … { … }
InstallStageTracker::~InstallStageTracker() = default;
InstallStageTracker* InstallStageTracker::Get(
content::BrowserContext* context) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
InstallStageTracker::UserInfo InstallStageTracker::GetUserInfo(
Profile* profile) {
const user_manager::User* user =
ash::ProfileHelper::Get()->GetUserByProfile(profile);
if (!user)
return UserInfo();
bool is_new_user = user_manager::UserManager::Get()->IsCurrentUserNew() ||
profile->IsNewProfile();
UserInfo current_user(user->GetType(), is_new_user, true);
return current_user;
}
#endif
void InstallStageTracker::ReportInfoOnNoUpdatesFailure(
const ExtensionId& id,
const std::string& info) { … }
void InstallStageTracker::ReportManifestInvalidFailure(
const ExtensionId& id,
const ExtensionDownloaderDelegate::FailureData& failure_data) { … }
void InstallStageTracker::ReportInstallCreationStage(
const ExtensionId& id,
InstallCreationStage stage) { … }
void InstallStageTracker::ReportInstallationStage(const ExtensionId& id,
Stage stage) { … }
void InstallStageTracker::ReportDownloadingStage(
const ExtensionId& id,
ExtensionDownloaderDelegate::Stage stage) { … }
void InstallStageTracker::ReportCRXInstallationStage(const ExtensionId& id,
InstallationStage stage) { … }
void InstallStageTracker::ReportDownloadingCacheStatus(
const ExtensionId& id,
ExtensionDownloaderDelegate::CacheStatus cache_status) { … }
InstallStageTracker::AppStatusError
InstallStageTracker::GetManifestInvalidAppStatusError(
const std::string& status) { … }
void InstallStageTracker::ReportFetchErrorCodes(
const ExtensionId& id,
const ExtensionDownloaderDelegate::FailureData& failure_data) { … }
void InstallStageTracker::ReportFetchError(
const ExtensionId& id,
FailureReason reason,
const ExtensionDownloaderDelegate::FailureData& failure_data) { … }
void InstallStageTracker::ReportFailure(const ExtensionId& id,
FailureReason reason) { … }
void InstallStageTracker::ReportExtensionType(const ExtensionId& id,
Manifest::Type extension_type) { … }
void InstallStageTracker::ReportCrxInstallError(
const ExtensionId& id,
FailureReason reason,
CrxInstallErrorDetail crx_install_error) { … }
void InstallStageTracker::ReportSandboxedUnpackerFailureReason(
const ExtensionId& id,
const CrxInstallError& crx_install_error) { … }
InstallStageTracker::InstallationData InstallStageTracker::Get(
const ExtensionId& id) { … }
void InstallStageTracker::Clear() { … }
void InstallStageTracker::AddObserver(Observer* observer) { … }
void InstallStageTracker::RemoveObserver(Observer* observer) { … }
void InstallStageTracker::NotifyObserversOfFailure(
const ExtensionId& id,
FailureReason reason,
const InstallationData& data) { … }
}