Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // See the corresponding header file for description of the functions in this | 5 // See the corresponding header file for description of the functions in this |
| 6 // file. | 6 // file. |
| 7 | 7 |
| 8 #include "chrome/installer/util/install_util.h" | 8 #include "chrome/installer/util/install_util.h" |
| 9 | 9 |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 37 #include "chrome/installer/util/installation_state.h" | 37 #include "chrome/installer/util/installation_state.h" |
| 38 #include "chrome/installer/util/l10n_string_util.h" | 38 #include "chrome/installer/util/l10n_string_util.h" |
| 39 #include "chrome/installer/util/util_constants.h" | 39 #include "chrome/installer/util/util_constants.h" |
| 40 #include "chrome/installer/util/work_item_list.h" | 40 #include "chrome/installer/util/work_item_list.h" |
| 41 | 41 |
| 42 using base::win::RegKey; | 42 using base::win::RegKey; |
| 43 using installer::ProductState; | 43 using installer::ProductState; |
| 44 | 44 |
| 45 namespace { | 45 namespace { |
| 46 | 46 |
| 47 const wchar_t kRegDowngradeVersion[] = L"DowngrdeVersion"; | |
| 47 const wchar_t kStageBinaryPatching[] = L"binary_patching"; | 48 const wchar_t kStageBinaryPatching[] = L"binary_patching"; |
| 48 const wchar_t kStageBuilding[] = L"building"; | 49 const wchar_t kStageBuilding[] = L"building"; |
| 49 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; | 50 const wchar_t kStageConfiguringAutoLaunch[] = L"configuring_auto_launch"; |
| 50 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs"; | 51 const wchar_t kStageCopyingPreferencesFile[] = L"copying_prefs"; |
| 51 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts"; | 52 const wchar_t kStageCreatingShortcuts[] = L"creating_shortcuts"; |
| 52 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching"; | 53 const wchar_t kStageEnsemblePatching[] = L"ensemble_patching"; |
| 53 const wchar_t kStageExecuting[] = L"executing"; | 54 const wchar_t kStageExecuting[] = L"executing"; |
| 54 const wchar_t kStageFinishing[] = L"finishing"; | 55 const wchar_t kStageFinishing[] = L"finishing"; |
| 55 const wchar_t kStagePreconditions[] = L"preconditions"; | 56 const wchar_t kStagePreconditions[] = L"preconditions"; |
| 56 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy"; | 57 const wchar_t kStageRefreshingPolicy[] = L"refreshing_policy"; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 } | 621 } |
| 621 | 622 |
| 622 // Populate |info| for |file|, returning true on success. | 623 // Populate |info| for |file|, returning true on success. |
| 623 // static | 624 // static |
| 624 bool InstallUtil::ProgramCompare::GetInfo(const base::File& file, | 625 bool InstallUtil::ProgramCompare::GetInfo(const base::File& file, |
| 625 BY_HANDLE_FILE_INFORMATION* info) { | 626 BY_HANDLE_FILE_INFORMATION* info) { |
| 626 DCHECK(file.IsValid()); | 627 DCHECK(file.IsValid()); |
| 627 return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0; | 628 return GetFileInformationByHandle(file.GetPlatformFile(), info) != 0; |
| 628 } | 629 } |
| 629 | 630 |
| 631 // static | |
| 632 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.
| |
| 633 base::win::RegKey key; | |
| 634 base::string16 downgrade_version; | |
| 635 if (key.Open(root, | |
| 636 BrowserDistribution::GetDistribution()->GetStateKey().c_str(), | |
| 637 KEY_QUERY_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS || | |
| 638 key.ReadValue(kRegDowngradeVersion, &downgrade_version) != | |
| 639 ERROR_SUCCESS) { | |
| 640 return base::Version(); | |
| 641 } | |
| 642 return base::Version(base::UTF16ToASCII(downgrade_version)); | |
| 643 } | |
| 644 | |
| 645 // static | |
| 646 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->
| |
| 647 HKEY root, | |
| 648 const base::Version& existing_version, | |
| 649 WorkItemList* list) { | |
| 650 DCHECK(list); | |
| 651 if (!GetDowngradeVersion(root).IsValid()) { | |
| 652 list->AddSetRegValueWorkItem( | |
| 653 root, BrowserDistribution::GetDistribution()->GetStateKey(), | |
| 654 KEY_WOW64_32KEY, kRegDowngradeVersion, | |
| 655 base::ASCIIToUTF16(existing_version.GetString()), false); | |
| 656 } | |
| 657 } | |
| 658 | |
| 659 // static | |
| 660 void InstallUtil::AddRemoveDowngradeVersionItem( | |
| 661 HKEY root, | |
| 662 const base::Version& new_version, | |
| 663 WorkItemList* list) { | |
| 664 DCHECK(list); | |
| 665 base::Version downgrade_version = GetDowngradeVersion(root); | |
| 666 if (downgrade_version.IsValid() && downgrade_version <= new_version) { | |
| 667 list->AddDeleteRegValueWorkItem( | |
| 668 root, BrowserDistribution::GetDistribution()->GetStateKey(), | |
| 669 KEY_WOW64_32KEY, kRegDowngradeVersion); | |
| 670 } | |
| 671 } | |
| 672 | |
| 630 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) | 673 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) |
| 631 : ProgramCompare(path_to_match, ComparisonType::FILE) {} | 674 : ProgramCompare(path_to_match, ComparisonType::FILE) {} |
| 632 | 675 |
| 633 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match, | 676 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match, |
| 634 ComparisonType comparison_type) | 677 ComparisonType comparison_type) |
| 635 : path_to_match_(path_to_match), | 678 : path_to_match_(path_to_match), |
| 636 file_info_(), | 679 file_info_(), |
| 637 comparison_type_(comparison_type) { | 680 comparison_type_(comparison_type) { |
| 638 DCHECK(!path_to_match_.empty()); | 681 DCHECK(!path_to_match_.empty()); |
| 639 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) { | 682 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 | 721 |
| 679 // Open the program and see if it references the expected file. | 722 // Open the program and see if it references the expected file. |
| 680 base::File file; | 723 base::File file; |
| 681 BY_HANDLE_FILE_INFORMATION info = {}; | 724 BY_HANDLE_FILE_INFORMATION info = {}; |
| 682 | 725 |
| 683 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) && | 726 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) && |
| 684 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 727 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 685 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 728 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 686 info.nFileIndexLow == file_info_.nFileIndexLow); | 729 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 687 } | 730 } |
| OLD | NEW |