#ifndef CHROME_UPDATER_CONSTANTS_H_
#define CHROME_UPDATER_CONSTANTS_H_
#include <optional>
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/update_client/update_client_errors.h"
namespace updater {
inline constexpr char kInstallerVersion[] = "installer_version";
#if BUILDFLAG(IS_WIN)
inline constexpr char kExecutableName[] = "updater.exe";
#else
inline constexpr char kExecutableName[] = "updater";
#endif
inline constexpr char kUninstallCompanionAppSwitch[] = "uninstall";
extern const char kExecutableSuffix[];
inline constexpr char kNullVersion[] = "0.0.0.0";
inline constexpr char kServerSwitch[] = "server";
inline constexpr char kServerServiceSwitch[] = "service";
inline constexpr char kServerUpdateServiceInternalSwitchValue[] =
"update-internal";
inline constexpr char kServerUpdateServiceSwitchValue[] = "update";
inline constexpr char kWindowsServiceSwitch[] = "windows-service";
inline constexpr char kComServiceSwitch[] = "com-service";
inline constexpr char kCrashMeSwitch[] = "crash-me";
inline constexpr char kCrashHandlerSwitch[] = "crash-handler";
inline constexpr char kUpdateSwitch[] = "update";
inline constexpr char kUpdateAppsSwitch[] = "update-apps";
inline constexpr char kPatchWorkerSwitch[] = "patch-worker";
inline constexpr char kUnzipWorkerSwitch[] = "unzip-worker";
inline constexpr char kNetWorkerSwitch[] = "net-worker";
inline constexpr char kInstallSwitch[] = "install";
inline constexpr char kEulaRequiredSwitch[] = "eularequired";
inline constexpr char kOemSwitch[] = "oem";
inline constexpr char kInstallerDataSwitch[] = "installerdata";
inline constexpr char kUninstallSwitch[] = "uninstall";
inline constexpr char kUninstallSelfSwitch[] = "uninstall-self";
inline constexpr char kUninstallIfUnusedSwitch[] = "uninstall-if-unused";
inline constexpr char kWakeSwitch[] = "wake";
inline constexpr char kWakeAllSwitch[] = "wake-all";
inline constexpr char kSystemSwitch[] = "system";
inline constexpr char kTestSwitch[] = "test";
inline constexpr char kRecoverSwitch[] = "recover";
inline constexpr char kForceInstallSwitch[] = "force-install";
inline constexpr char kBrowserVersionSwitch[] = "browser-version";
inline constexpr char kSessionIdSwitch[] =
"sessionid";
inline constexpr char kAppGuidSwitch[] = "appguid";
inline constexpr char kMonitorSelfSwitch[] = "monitor-self";
inline constexpr char kMonitorSelfSwitchArgument[] = "monitor-self-argument";
inline constexpr char kInitDoneNotifierSwitch[] = "init-done-notifier";
inline constexpr char kEnableLoggingSwitch[] = "enable-logging";
inline constexpr char kLoggingModuleSwitch[] = "vmodule";
inline constexpr char kLoggingModuleSwitchValue[] =
#if BUILDFLAG(IS_WIN)
"*/components/winhttp/*=1,"
#endif
"*/components/update_client/*=2,"
"*/chrome/enterprise_companion/*=2,"
"*/chrome/updater/*=2";
inline constexpr char kAppIdSwitch[] = "app-id";
inline constexpr char kAppVersionSwitch[] = "app-version";
inline constexpr char kHealthCheckSwitch[] = "healthcheck";
inline constexpr char kEnterpriseSwitch[] =
"enterprise";
inline constexpr char kSilentSwitch[] = "silent";
inline constexpr char kAlwaysLaunchCmdSwitch[] = "alwayslaunchcmd";
inline constexpr char kHandoffSwitch[] = "handoff";
inline constexpr char kOfflineDirSwitch[] =
"offlinedir";
inline constexpr char kAppArgsSwitch[] = "appargs";
inline constexpr char kCmdLineExpectElevated[] = "expect-elevated";
inline constexpr char kCmdLineExpectDeElevated[] = "expect-de-elevated";
inline constexpr char kCmdLinePrefersUser[] = "prefers-user";
inline constexpr char kAppsDir[] = "apps";
inline constexpr char kUninstallScript[] = "uninstall.cmd";
inline constexpr char kDevOverrideKeyUrl[] = "url";
inline constexpr char kDevOverrideKeyCrashUploadUrl[] = "crash_upload_url";
inline constexpr char kDevOverrideKeyAppLogoUrl[] = "app_logo_url";
inline constexpr char kDevOverrideKeyEventLoggingUrl[] = "event_logging_url";
inline constexpr char kDevOverrideKeyUseCUP[] = "use_cup";
inline constexpr char kDevOverrideKeyInitialDelay[] = "initial_delay";
inline constexpr char kDevOverrideKeyServerKeepAliveSeconds[] =
"server_keep_alive";
inline constexpr char kDevOverrideKeyCrxVerifierFormat[] =
"crx_verifier_format";
inline constexpr char kDevOverrideKeyCrxPublicKeyHash[] = "crx_public_key_hash";
inline constexpr char kDevOverrideKeyMinumumEventLoggingCooldownSeconds[] =
"minimum_event_logging_cooldown_seconds";
inline constexpr char kDevOverrideKeyEventLoggingPermissionProviderAppId[] =
"event_logging_permission_provider_app_id";
#if BUILDFLAG(IS_MAC)
inline constexpr char
kDevOverrideKeyEventLoggingPermissionProviderDirectoryName[] =
"event_logging_permission_provider_directory_name";
#endif
inline constexpr char kDevOverrideKeyDictPolicies[] = "dict_policies";
inline constexpr char kDevOverrideKeyGroupPolicies[] = "group_policies";
inline constexpr char kDevOverrideKeyOverinstallTimeout[] =
"overinstall_timeout";
inline constexpr char kDevOverrideKeyIdleCheckPeriodSeconds[] =
"idle_check_period";
inline constexpr char kDevOverrideKeyManagedDevice[] = "managed_device";
inline constexpr char kDevOverrideKeyEnableDiffUpdates[] =
"enable_diff_updates";
inline constexpr char kDevOverrideKeyCecaConnectionTimeout[] =
"ceca_connection_timeout";
inline constexpr base::TimeDelta kWaitForAppInstaller = base::Minutes(15);
inline constexpr base::TimeDelta kWaitForSetupLock = base::Seconds(5);
inline constexpr base::TimeDelta kDefaultLastCheckPeriod =
base::Hours(4) + base::Minutes(30);
#if BUILDFLAG(IS_MAC)
inline constexpr int kWaitForLaunchctlUpdateSec = 5;
#endif
inline constexpr base::TimeDelta kMinimumEventLoggingCooldown =
base::Minutes(15);
inline constexpr double kUpdateCheckMinDelayFactor = 1.0;
inline constexpr double kUpdateCheckMaxDelayFactor = 1.2;
inline constexpr double kProbabilityOfIncreasedDelay = 0.1;
#if BUILDFLAG(IS_WIN)
inline constexpr int kCustomInstallErrorBase =
static_cast<int>(update_client::InstallError::CUSTOM_ERROR_BASE) + 74000;
#else
inline constexpr int kCustomInstallErrorBase =
static_cast<int>(update_client::InstallError::CUSTOM_ERROR_BASE);
#endif
inline constexpr int kErrorApplicationInstallerFailed =
kCustomInstallErrorBase + 3;
inline constexpr int kErrorMissingInstallParams = kCustomInstallErrorBase + 1;
inline constexpr int kErrorInvalidFileExtension = kCustomInstallErrorBase + 4;
inline constexpr int kErrorAppCommandLaunchFailed = kCustomInstallErrorBase + 5;
inline constexpr int kErrorAppCommandTimedOut = kCustomInstallErrorBase + 6;
#if BUILDFLAG(IS_WIN)
inline constexpr int kUpdaterErrorBase = 75000;
#else
inline constexpr int kUpdaterErrorBase = 0;
#endif
inline constexpr int kErrorOk = 0;
inline constexpr int kErrorFailedToLockPrefsMutex = kUpdaterErrorBase + 1;
inline constexpr int kErrorFailedToSwap = kUpdaterErrorBase + 2;
inline constexpr int kErrorRegistrationFailed = kUpdaterErrorBase + 3;
inline constexpr int kErrorPermissionDenied = kUpdaterErrorBase + 4;
inline constexpr int kErrorWaitFailedUninstall = kUpdaterErrorBase + 5;
inline constexpr int kErrorWaitFailedInstall = kUpdaterErrorBase + 6;
inline constexpr int kErrorPathServiceFailed = kUpdaterErrorBase + 7;
inline constexpr int kErrorComInitializationFailed = kUpdaterErrorBase + 8;
inline constexpr int kErrorUnknownCommandLine = kUpdaterErrorBase + 9;
inline constexpr int kErrorNoVersionedDirectory = kUpdaterErrorBase + 11;
inline constexpr int kErrorNoBaseDirectory = kUpdaterErrorBase + 12;
inline constexpr int kErrorPathTooLong = kUpdaterErrorBase + 13;
inline constexpr int kErrorProcessLaunchFailed = kUpdaterErrorBase + 14;
inline constexpr int kErrorFailedToCopyBundle = kUpdaterErrorBase + 15;
inline constexpr int kErrorFailedToDeleteFolder = kUpdaterErrorBase + 16;
inline constexpr int kErrorFailedToDeleteDataFolder = kUpdaterErrorBase + 17;
inline constexpr int kErrorFailedToGetVersionedInstallDirectory =
kUpdaterErrorBase + 18;
inline constexpr int kErrorFailedToGetInstallDir = kUpdaterErrorBase + 19;
inline constexpr int kErrorFailedToRemoveActiveUpdateServiceJobFromLaunchd =
kUpdaterErrorBase + 20;
inline constexpr int kErrorFailedToRemoveCandidateUpdateServiceJobFromLaunchd =
kUpdaterErrorBase + 21;
inline constexpr int kErrorFailedToRemoveUpdateServiceInternalJobFromLaunchd =
kUpdaterErrorBase + 22;
inline constexpr int kErrorFailedToRemoveWakeJobFromLaunchd =
kUpdaterErrorBase + 23;
inline constexpr int kErrorFailedToCreateUpdateServiceLaunchdJobPlist =
kUpdaterErrorBase + 24;
inline constexpr int kErrorFailedToCreateVersionedUpdateServiceLaunchdJobPlist =
kUpdaterErrorBase + 25;
inline constexpr int kErrorFailedToCreateUpdateServiceInternalLaunchdJobPlist =
kUpdaterErrorBase + 26;
inline constexpr int kErrorFailedToCreateWakeLaunchdJobPlist =
kUpdaterErrorBase + 27;
inline constexpr int kErrorFailedToStartLaunchdActiveServiceJob =
kUpdaterErrorBase + 28;
inline constexpr int kErrorFailedToStartLaunchdVersionedServiceJob =
kUpdaterErrorBase + 29;
inline constexpr int kErrorFailedToStartLaunchdUpdateServiceInternalJob =
kUpdaterErrorBase + 30;
inline constexpr int kErrorFailedToStartLaunchdWakeJob = kUpdaterErrorBase + 31;
inline constexpr int kErrorFailedAwaitingLaunchdUpdateServiceInternalJob =
kUpdaterErrorBase + 32;
inline constexpr int kErrorDMRegistrationFailed = kUpdaterErrorBase + 33;
inline constexpr int kErrorFailedToInstallLegacyUpdater =
kUpdaterErrorBase + 34;
inline constexpr int kErrorIpcDisconnect = kUpdaterErrorBase + 35;
inline constexpr int kErrorFailedToCopyBinary = kUpdaterErrorBase + 36;
inline constexpr int kErrorFailedToDeleteSocket = kUpdaterErrorBase + 37;
inline constexpr int kErrorFailedToLinkCurrent = kUpdaterErrorBase + 38;
inline constexpr int kErrorFailedToRenameCurrent = kUpdaterErrorBase + 39;
inline constexpr int kErrorFailedToInstallSystemdUnit = kUpdaterErrorBase + 40;
inline constexpr int kErrorFailedToRemoveSystemdUnit = kUpdaterErrorBase + 41;
inline constexpr int kErrorWrongUser = kUpdaterErrorBase + 42;
inline constexpr int kErrorFailedToGetSetupFiles = kUpdaterErrorBase + 43;
inline constexpr int kErrorFailedToRunInstallList = kUpdaterErrorBase + 44;
inline constexpr int kErrorIdle = kUpdaterErrorBase + 45;
inline constexpr int kErrorEulaRequired = kUpdaterErrorBase + 46;
inline constexpr int kErrorUnsupportedOperatingSystem = kUpdaterErrorBase + 47;
inline constexpr int kErrorTagParsing = kUpdaterErrorBase + 50;
inline constexpr int kErrorCreatingTempDir = kUpdaterErrorBase + 60;
inline constexpr int kErrorUnpackingResource = kUpdaterErrorBase + 61;
inline constexpr int kErrorInitializingBackupDir = kUpdaterErrorBase + 62;
inline constexpr int kErrorGettingUpdaterPath = kUpdaterErrorBase + 71;
inline constexpr int kErrorStattingPath = kUpdaterErrorBase + 72;
inline constexpr int kErrorLaunchingProcess = kUpdaterErrorBase + 73;
inline constexpr int kErrorPathOwnershipMismatch = kUpdaterErrorBase + 74;
inline constexpr int kErrorFailedToLockSetupMutex = kUpdaterErrorBase + 75;
inline constexpr int kErrorMojoConnectionFailure = kUpdaterErrorBase + 76;
inline constexpr int kErrorMojoRequestRejected = kUpdaterErrorBase + 77;
inline constexpr int kErrorNoConsoleUser = kUpdaterErrorBase + 78;
inline constexpr int kErrorPolicyFetchFailed = kUpdaterErrorBase + 79;
inline constexpr int kErrorFailedToUninstallCompanionApp =
kUpdaterErrorBase + 80;
inline constexpr int kErrorFailedToUninstallOtherVersion =
kUpdaterErrorBase + 81;
inline constexpr int kErrorNoObserverCompletionInfo = kUpdaterErrorBase + 82;
inline constexpr int kErrorNoApps = kUpdaterErrorBase + 83;
inline constexpr int kErrorPathReferencesParent = kUpdaterErrorBase + 84;
inline constexpr int kMaxAutoUpdateCheckPeriodMinutes = 43200;
inline constexpr int kMaxUpdatesSuppressedDurationMinutes = 960;
inline constexpr char kProxyModeDirect[] = "direct";
inline constexpr char kProxyModeAutoDetect[] = "auto_detect";
inline constexpr char kProxyModePacScript[] = "pac_script";
inline constexpr char kProxyModeFixedServers[] = "fixed_servers";
inline constexpr char kProxyModeSystem[] = "system";
inline constexpr char kDownloadPreferenceCacheable[] = "cacheable";
inline constexpr char kUTF8BOM[] = "\xEF\xBB\xBF";
inline constexpr int kPolicyNotSet = -1;
inline constexpr int kPolicyDisabled = 0;
inline constexpr int kPolicyEnabled = 1;
inline constexpr int kPolicyEnabledMachineOnly = 4;
inline constexpr int kPolicyManualUpdatesOnly = 2;
inline constexpr int kPolicyAutomaticUpdatesOnly = 3;
inline constexpr int kPolicyForceInstallMachine = 5;
inline constexpr int kPolicyForceInstallUser = 6;
inline constexpr bool kInstallPolicyDefault = kPolicyEnabled;
inline constexpr bool kUpdatePolicyDefault = kPolicyEnabled;
inline constexpr char kSourceDMPolicyManager[] = "Device Management";
inline constexpr char kSourceDefaultValuesPolicyManager[] = "Default";
inline constexpr char kSourceDictValuesPolicyManager[] = "DictValuePolicy";
#if BUILDFLAG(IS_WIN)
inline constexpr bool kPlatformPolicyManagerDefined = true;
inline constexpr char kSourcePlatformPolicyManager[] = "Group Policy";
inline constexpr bool kCloudPolicyOverridesPlatformPolicyDefaultValue = false;
#elif BUILDFLAG(IS_MAC)
inline constexpr bool kPlatformPolicyManagerDefined = true;
inline constexpr char kSourcePlatformPolicyManager[] = "Managed Preferences";
inline constexpr bool kCloudPolicyOverridesPlatformPolicyDefaultValue = true;
#else
inline constexpr bool kPlatformPolicyManagerDefined = false;
inline constexpr char kSourcePlatformPolicyManager[] = "not-defined";
inline constexpr bool kCloudPolicyOverridesPlatformPolicyDefaultValue = true;
#endif
enum class UninstallPingReason {
kUninstalled = 0,
kUserNotAnOwner = 1,
kNoAppsRemain = 2,
kNeverHadApps = 3,
};
inline constexpr int kErrorFailedToMoveDownloadedFile = 5;
inline constexpr int kErrorFailedToWriteFile = 6;
inline constexpr base::TimeDelta kInitialDelay = base::Seconds(1);
inline constexpr base::TimeDelta kServerKeepAliveTime = base::Seconds(10);
inline constexpr base::TimeDelta kCecaConnectionTimeout = base::Seconds(30);
inline constexpr int kMaxServerStartsBeforeFirstReg = 24;
inline constexpr int kNumAlreadyRunningMaxTries = 4;
inline constexpr base::TimeDelta kAlreadyRunningRetryInitialDelay =
base::Seconds(5);
inline constexpr int GOOPDATE_E_APP_INSTALL_DISABLED_BY_POLICY = 0x80040812;
inline constexpr int GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY = 0x80040813;
inline constexpr int GOOPDATE_E_APP_UPDATE_DISABLED_BY_POLICY_MANUAL =
0x8004081f;
inline constexpr int GOOPDATEINSTALL_E_FILENAME_INVALID = 0x80040900;
inline constexpr int GOOPDATEINSTALL_E_INSTALLER_FAILED_START = 0x80040901;
inline constexpr int GOOPDATEINSTALL_E_INSTALLER_FAILED = 0x80040902;
inline constexpr int GOOPDATEINSTALL_E_INSTALLER_TIMED_OUT = 0x80040904;
inline constexpr int GOOPDATEINSTALL_E_INSTALL_ALREADY_RUNNING = 0x80040907;
inline constexpr char kInstallSourceTaggedMetainstaller[] = "taggedmi";
inline constexpr char kInstallSourceOffline[] = "offline";
inline constexpr char kInstallSourcePolicy[] = "policy";
inline constexpr char kInstallSourceOnDemand[] = "ondemand";
inline constexpr int kRegistrationSuccess = 0;
inline constexpr int kRegistrationError = 1;
}
#endif