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..081f9e43ef7904c23b37b784ad1d9f1bb268cf2e 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"DowngrdeVersion"; |
| const wchar_t kStageBinaryPatching[] = L"binary_patching"; |
| const wchar_t kStageBuilding[] = L"building"; |
| const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; |
| @@ -627,6 +628,48 @@ bool InstallUtil::ProgramCompare::GetInfo(const base::File& file, |
| return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0; |
| } |
| +// static |
| +base::Version InstallUtil::GetDowngradeVersion(HKEY root) { |
|
grt (UTC plus 2)
2016/05/19 23:39:28
i think it's cleaner for this to take a bool syste
zmin
2016/05/20 00:52:25
I use HKEY instead of bool here because
1) Make it
grt (UTC plus 2)
2016/05/20 15:25:05
using HKEY leaks an implementation detail into the
zmin
2016/05/20 16:33:05
Sure, I'll do bool for both.
|
| + base::win::RegKey key; |
| + base::string16 downgrade_version; |
| + if (key.Open(root, |
| + BrowserDistribution::GetDistribution()->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::AddSetDowngradeVersionItem( |
|
grt (UTC plus 2)
2016/05/19 23:39:28
this should take a const AppRegistrationData& as i
zmin
2016/05/20 00:52:25
Done. But I'll use BrowserDistribution* which is a
grt (UTC plus 2)
2016/05/20 15:25:05
Why? I think it'll be easier to unittest using ARD
zmin
2016/05/20 16:33:05
There is no much difference. BrowserDistribution->
|
| + HKEY root, |
| + const base::Version& existing_version, |
| + WorkItemList* list) { |
| + DCHECK(list); |
| + if (!GetDowngradeVersion(root).IsValid()) { |
| + list->AddSetRegValueWorkItem( |
| + root, BrowserDistribution::GetDistribution()->GetStateKey(), |
| + KEY_WOW64_32KEY, kRegDowngradeVersion, |
| + base::ASCIIToUTF16(existing_version.GetString()), false); |
| + } |
| +} |
| + |
| +// static |
| +void InstallUtil::AddRemoveDowngradeVersionItem( |
| + HKEY root, |
| + const base::Version& new_version, |
| + WorkItemList* list) { |
| + DCHECK(list); |
| + base::Version downgrade_version = GetDowngradeVersion(root); |
| + if (downgrade_version.IsValid() && downgrade_version <= new_version) { |
| + list->AddDeleteRegValueWorkItem( |
| + root, BrowserDistribution::GetDistribution()->GetStateKey(), |
| + KEY_WOW64_32KEY, kRegDowngradeVersion); |
| + } |
| +} |
| + |
| InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) |
| : ProgramCompare(path_to_match, ComparisonType::FILE) {} |