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"DowngradeVersion"; | |
| 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( | |
| 633 bool system_install, | |
| 634 const BrowserDistribution* dist) { | |
| 635 DCHECK(dist); | |
| 636 base::win::RegKey key; | |
| 637 base::string16 downgrade_version; | |
| 638 if (key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER, | |
| 639 dist->GetStateKey().c_str(), | |
| 640 KEY_QUERY_VALUE | KEY_WOW64_32KEY) != ERROR_SUCCESS || | |
| 641 key.ReadValue(kRegDowngradeVersion, &downgrade_version) != | |
| 642 ERROR_SUCCESS) { | |
| 643 return base::Version(); | |
| 644 } | |
| 645 return base::Version(base::UTF16ToASCII(downgrade_version)); | |
| 646 } | |
| 647 | |
| 648 // static | |
| 649 void InstallUtil::AddUpdateDowngradeVersionItem( | |
| 650 bool system_install, | |
| 651 const base::Version* current_version, | |
| 652 const base::Version& new_version, | |
| 653 const BrowserDistribution* dist, | |
| 654 WorkItemList* list) { | |
| 655 DCHECK(list); | |
| 656 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.
| |
| 657 base::Version downgrade_version = GetDowngradeVersion(system_install, dist); | |
| 658 HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | |
| 659 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.
| |
| 660 (*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
| |
| 661 ((!downgrade_version.IsValid() || downgrade_version <= new_version)))) { | |
| 662 list->AddDeleteRegValueWorkItem(root, dist->GetStateKey(), KEY_WOW64_32KEY, | |
| 663 kRegDowngradeVersion); | |
| 664 } else if (*current_version > new_version && !downgrade_version.IsValid()) { | |
| 665 list->AddSetRegValueWorkItem( | |
| 666 root, dist->GetStateKey(), KEY_WOW64_32KEY, kRegDowngradeVersion, | |
| 667 base::ASCIIToUTF16(current_version->GetString()), true); | |
| 668 } | |
| 669 } | |
| 670 | |
| 630 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) | 671 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match) |
| 631 : ProgramCompare(path_to_match, ComparisonType::FILE) {} | 672 : ProgramCompare(path_to_match, ComparisonType::FILE) {} |
| 632 | 673 |
| 633 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match, | 674 InstallUtil::ProgramCompare::ProgramCompare(const base::FilePath& path_to_match, |
| 634 ComparisonType comparison_type) | 675 ComparisonType comparison_type) |
| 635 : path_to_match_(path_to_match), | 676 : path_to_match_(path_to_match), |
| 636 file_info_(), | 677 file_info_(), |
| 637 comparison_type_(comparison_type) { | 678 comparison_type_(comparison_type) { |
| 638 DCHECK(!path_to_match_.empty()); | 679 DCHECK(!path_to_match_.empty()); |
| 639 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) { | 680 if (!OpenForInfo(path_to_match_, &file_, comparison_type_)) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 678 | 719 |
| 679 // Open the program and see if it references the expected file. | 720 // Open the program and see if it references the expected file. |
| 680 base::File file; | 721 base::File file; |
| 681 BY_HANDLE_FILE_INFORMATION info = {}; | 722 BY_HANDLE_FILE_INFORMATION info = {}; |
| 682 | 723 |
| 683 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) && | 724 return (OpenForInfo(path, &file, comparison_type_) && GetInfo(file, &info) && |
| 684 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 725 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 685 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 726 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 686 info.nFileIndexLow == file_info_.nFileIndexLow); | 727 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 687 } | 728 } |
| OLD | NEW |