#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/browser/upgrade_detector/upgrade_detector_impl.h"
#include <stdint.h>
#include <optional>
#include <string>
#include "base/build_time.h"
#include "base/check_op.h"
#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/no_destructor.h"
#include "base/notreached.h"
#include "base/ranges/algorithm.h"
#include "base/task/sequenced_task_runner.h"
#include "base/time/clock.h"
#include "base/time/default_clock.h"
#include "base/time/default_tick_clock.h"
#include "base/time/tick_clock.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/buildflags.h"
#include "chrome/browser/enterprise/browser_management/management_service_factory.h"
#include "chrome/browser/google/google_brand.h"
#include "chrome/browser/obsolete_system/obsolete_system.h"
#include "chrome/browser/upgrade_detector/build_state.h"
#include "chrome/browser/upgrade_detector/get_installed_version.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "components/network_time/network_time_tracker.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#if BUILDFLAG(IS_WIN)
#include "chrome/installer/util/google_update_settings.h"
#endif
namespace {
constexpr auto kDefaultVeryLowThreshold = …;
constexpr auto kDefaultLowThreshold = …;
constexpr auto kDefaultElevatedThreshold = …;
constexpr auto kDefaultHighThreshold = …;
constexpr auto kDefaultGraceThreshold = …;
constexpr auto kNotifyCycleTime = …;
constexpr auto kNotifyCycleTimeForTesting = …;
constexpr auto kOutdatedBuildDetectorPeriod = …;
constexpr auto kOutdatedBuildAge = …;
bool ShouldDetectOutdatedBuilds() { … }
bool SimulatingOutdated() { … }
bool IsTesting() { … }
}
UpgradeDetectorImpl::UpgradeDetectorImpl(const base::Clock* clock,
const base::TickClock* tick_clock)
: … { … }
UpgradeDetectorImpl::~UpgradeDetectorImpl() { … }
void UpgradeDetectorImpl::StartUpgradeNotificationTimer() { … }
void UpgradeDetectorImpl::CalculateThresholds() { … }
void UpgradeDetectorImpl::DoCalculateThresholds() { … }
void UpgradeDetectorImpl::StartOutdatedBuildDetector() { … }
void UpgradeDetectorImpl::DetectOutdatedInstall() { … }
void UpgradeDetectorImpl::UpgradeDetected(UpgradeAvailable upgrade_available) { … }
void UpgradeDetectorImpl::OnExperimentChangesDetected(Severity severity) { … }
void UpgradeDetectorImpl::NotifyOnUpgradeWithTimePassed(
base::TimeDelta time_passed) { … }
base::TimeDelta UpgradeDetectorImpl::GetThresholdForLevel(
UpgradeNotificationAnnoyanceLevel level) { … }
UpgradeDetectorImpl::LevelIndex
UpgradeDetectorImpl::AnnoyanceLevelToStagesIndex(
UpgradeNotificationAnnoyanceLevel level) { … }
UpgradeDetector::UpgradeNotificationAnnoyanceLevel
UpgradeDetectorImpl::StageIndexToAnnoyanceLevel(size_t index) { … }
void UpgradeDetectorImpl::OnMonitoredPrefsChanged() { … }
void UpgradeDetectorImpl::NotifyOnUpgrade() { … }
UpgradeDetectorImpl* UpgradeDetectorImpl::GetInstance() { … }
void UpgradeDetectorImpl::Init() { … }
void UpgradeDetectorImpl::Shutdown() { … }
base::Time UpgradeDetectorImpl::GetAnnoyanceLevelDeadline(
UpgradeNotificationAnnoyanceLevel level) { … }
void UpgradeDetectorImpl::OnUpdate(const BuildState* build_state) { … }
UpgradeDetector* UpgradeDetector::GetInstance() { … }
base::TimeDelta UpgradeDetector::GetDefaultHighAnnoyanceThreshold() { … }
base::TimeDelta UpgradeDetector::GetDefaultElevatedAnnoyanceThreshold() { … }
UpgradeDetector::RelaunchWindow UpgradeDetector::GetDefaultRelaunchWindow() { … }