Chromium Code Reviews| Index: chrome/installer/util/install_util.cc |
| diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc |
| index 8b6dfa75deab255b214ff5e749ab7e76949ad6a7..ff76fc66f999f80c40683ed963c5483629c45bc8 100644 |
| --- a/chrome/installer/util/install_util.cc |
| +++ b/chrome/installer/util/install_util.cc |
| @@ -44,6 +44,7 @@ using installer::ProductState; |
| namespace { |
| +const wchar_t kRegDowngradeVersion[] = L"DowngradeVersion"; |
| const wchar_t kStageBinaryPatching[] = L"binary_patching"; |
| const wchar_t kStageBuilding[] = L"building"; |
| const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; |
| @@ -627,6 +628,46 @@ bool InstallUtil::ProgramCompare::GetInfo(const base::File& file, |
| return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0; |
| } |
| +// static |
| +base::Version InstallUtil::GetDowngradeVersion( |
| + bool system_install, |
| + const BrowserDistribution* dist) { |
| + DCHECK(dist); |
| + base::win::RegKey key; |
| + base::string16 downgrade_version; |
| + if (key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, |
| + dist->GetStateKey().c_str(), |
| + KEY_QUERY_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS || |
| + key.ReadValue(kRegDowngradeVersion, &downgrade_version) != |
| + ERROR_SUCCESS) { |
| + return base::Version(); |
| + } |
| + return base::Version(base::UTF16ToASCII(downgrade_version)); |
| +} |
| + |
| +// static |
| +void InstallUtil::AddUpdateDowngradeVersionItem( |
| + bool system_install, |
| + const base::Version* current_version, |
| + const base::Version& new_version, |
| + const BrowserDistribution* dist, |
| + WorkItemList* list) { |
| + DCHECK(list); |
| + DCHECK(dist); |
|
grt (UTC plus 2)
2016/05/20 18:17:05
to enforce the "only call this for Chrome", add:
zmin
2016/05/20 19:11:21
Done.
|
| + base::Version downgrade_version = GetDowngradeVersion(system_install, dist); |
| + HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| + if (current_version == nullptr || |
|
grt (UTC plus 2)
2016/05/20 18:17:05
nit: if (!current_version
zmin
2016/05/20 19:11:21
Done.
|
| + (*current_version < new_version && |
|
grt (UTC plus 2)
2016/05/20 18:17:05
should this be <= so that the delete is done for s
zmin
2016/05/20 19:11:21
For same-version-repair, the |downgrade_version| s
|
| + ((!downgrade_version.IsValid() || downgrade_version <= new_version)))) { |
| + list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(), KEY_WOW64_32KEY, |
| + kRegDowngradeVersion); |
| + } else if (*current_version > new_version && !downgrade_version.IsValid()) { |
| + list->AddSetRegValueWorkItem( |
| + root, dist->GetStateKey(), KEY_WOW64_32KEY, kRegDowngradeVersion, |
| + base::ASCIIToUTF16(current_version->GetString()), true); |
| + } |
| +} |
| + |
| InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) |
| : ProgramCompare(path_to_match, ComparisonType::FILE) {} |