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