Index: chrome/installer/setup/setup_main.cc |
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc |
index 15998d1bb97eec20b37bd7bfa9c4fd41d62b74db..48484e698bac5347b7366df1bcc445f0f997a167 100644 |
--- a/chrome/installer/setup/setup_main.cc |
+++ b/chrome/installer/setup/setup_main.cc |
@@ -80,6 +80,7 @@ using installer::Products; |
const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
+const wchar_t kDisplayVersion[] = L"DisplayVersion"; |
const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
MiniDumpWithProcessThreadData | // Get PEB and TEB. |
@@ -88,6 +89,32 @@ const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
namespace { |
+// Overwrite an existing DisplayVersion as written by the MSI installer |
+// with the real version number of Chrome. |
+LONG OverwriteDisplayVersion(const base::string16& path, |
+ const base::string16& value) { |
+ base::win::RegKey key; |
+ LONG result = 0; |
+ if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(), |
+ KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_64KEY)) |
+ != ERROR_SUCCESS) { |
+ LOG(ERROR) << "Failed to set DisplayVersion: " << path << " not found"; |
+ return result; |
+ } |
+ if ((result = key.HasValue(kDisplayVersion)) != ERROR_SUCCESS) { |
+ LOG(ERROR) << "Failed to set DisplayVersion: " << kDisplayVersion |
+ << " not found under " << path; |
+ return result; |
+ } |
+ if ((result = key.WriteValue(kDisplayVersion, value.c_str())) |
+ != ERROR_SUCCESS) { |
+ LOG(ERROR) << "Failed to set DisplayVersion: " << kDisplayVersion |
+ << " could not be written under " << path; |
+ return result; |
+ } |
+ return ERROR_SUCCESS; |
+} |
+ |
// Returns NULL if no compressed archive is available for processing, otherwise |
// returns a patch helper configured to uncompress and patch. |
scoped_ptr<installer::ArchivePatchHelper> CreateChromeArchiveHelper( |
@@ -918,6 +945,18 @@ bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
const base::CommandLine& cmd_line, |
InstallerState* installer_state, |
int* exit_code) { |
+ // This option is independent of all others so doesn't belong in the if/else |
+ // block below. |
+ if (cmd_line.HasSwitch(installer::switches::kDelay)) { |
+ const std::string delay_seconds_string( |
+ cmd_line.GetSwitchValueASCII(installer::switches::kDelay)); |
+ int delay_seconds; |
+ if (base::StringToInt(delay_seconds_string, &delay_seconds) && |
+ delay_seconds > 0) { |
+ ::Sleep(delay_seconds * 1000); |
+ } |
+ } |
+ |
// TODO(gab): Add a local |status| variable which each block below sets; |
// only determine the |exit_code| from |status| at the end (this will allow |
// this method to validate that |
@@ -1152,6 +1191,14 @@ bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
bool updates_enabled = GoogleUpdateSettings::ReenableAutoupdates(); |
*exit_code = updates_enabled ? installer::REENABLE_UPDATES_SUCCEEDED : |
installer::REENABLE_UPDATES_FAILED; |
+ } else if (cmd_line.HasSwitch(installer::switches::kSetDisplayVersionPath)) { |
+ const base::string16 registry_path( |
+ cmd_line.GetSwitchValueNative( |
+ installer::switches::kSetDisplayVersionPath)); |
+ const base::string16 registry_value( |
+ cmd_line.GetSwitchValueNative( |
+ installer::switches::kSetDisplayVersionValue)); |
+ *exit_code = OverwriteDisplayVersion(registry_path, registry_value); |
} else { |
handled = false; |
} |