Index: chrome/installer/setup/setup_main.cc |
diff --git a/chrome/installer/setup/setup_main.cc b/chrome/installer/setup/setup_main.cc |
index 571964c0beab98ea45b0c5e66a36fb50c550f109..6345eaebf7552f4e30d9770d3de975cc9cb73547 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,26 @@ 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(base::string16 path, base::string16 value) { |
robertshield
2015/08/08 04:32:38
pass by reference, no need to make a copy: const b
bcwhite
2015/08/13 16:25:58
Done.
|
+ base::win::RegKey key; |
+ LONG result; |
robertshield
2015/08/08 04:32:39
= 0
bcwhite
2015/08/13 16:25:58
Done.
|
+ std::wstring existing; |
robertshield
2015/08/08 04:32:39
Should be able to use base::string16 here
bcwhite
2015/08/13 16:25:58
Done.
|
+ if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(), |
+ KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_64KEY)) |
+ != ERROR_SUCCESS) { |
+ return result; |
+ } |
+ if ((result = key.ReadValue(kDisplayVersion, &existing)) != ERROR_SUCCESS) |
robertshield
2015/08/08 04:33:30
We should log to the installer log when the value
bcwhite
2015/08/13 16:25:58
Done.
|
+ return result; |
robertshield
2015/08/08 04:32:39
It looks like we don't use the value of |existing|
bcwhite
2015/08/13 16:25:58
Done.
|
+ if ((result = key.WriteValue(kDisplayVersion, value.c_str())) |
+ != ERROR_SUCCESS) { |
+ 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( |
@@ -1152,6 +1173,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; |
} |
@@ -1659,6 +1688,15 @@ int WINAPI wWinMain(HINSTANCE instance, HINSTANCE prev_instance, |
if (installer::ContainsUnsupportedSwitch(cmd_line)) |
return installer::UNSUPPORTED_OPTION; |
+ if (cmd_line.HasSwitch(installer::switches::kDelay)) { |
robertshield
2015/08/08 04:32:39
Could this block be placed at the top of HandleNon
bcwhite
2015/08/13 16:25:58
Done.
|
+ std::string delay_seconds_string( |
robertshield
2015/08/08 04:32:38
const
bcwhite
2015/08/13 16:25:58
Done.
|
+ cmd_line.GetSwitchValueASCII(installer::switches::kDelay)); |
+ int delay_seconds = std::stoi(delay_seconds_string); |
robertshield
2015/08/08 04:32:38
Most code I see uses base::StringToInt rather than
bcwhite
2015/08/13 16:25:58
Done.
|
+ if (delay_seconds > 0) { |
+ ::Sleep(delay_seconds * 1000); |
+ } |
+ } |
+ |
// A variety of installer operations require the path to the current |
// executable. Get it once here for use throughout these operations. Note that |
// the path service is the authoritative source for this path. One might think |