| 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 #include "chrome/installer/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 installer::kChromeOldExe, | 655 installer::kChromeOldExe, |
| 656 }; | 656 }; |
| 657 | 657 |
| 658 for (int i = 0; i < arraysize(kChromeFilenames); ++i) { | 658 for (int i = 0; i < arraysize(kChromeFilenames); ++i) { |
| 659 base::FilePath chrome_exe(target_path().Append(kChromeFilenames[i])); | 659 base::FilePath chrome_exe(target_path().Append(kChromeFilenames[i])); |
| 660 scoped_ptr<FileVersionInfo> file_version_info( | 660 scoped_ptr<FileVersionInfo> file_version_info( |
| 661 FileVersionInfo::CreateFileVersionInfo(chrome_exe)); | 661 FileVersionInfo::CreateFileVersionInfo(chrome_exe)); |
| 662 if (file_version_info) { | 662 if (file_version_info) { |
| 663 base::string16 version_string = file_version_info->file_version(); | 663 base::string16 version_string = file_version_info->file_version(); |
| 664 if (!version_string.empty() && IsStringASCII(version_string)) | 664 if (!version_string.empty() && IsStringASCII(version_string)) |
| 665 existing_versions->insert(WideToASCII(version_string)); | 665 existing_versions->insert(base::UTF16ToASCII(version_string)); |
| 666 } | 666 } |
| 667 } | 667 } |
| 668 } | 668 } |
| 669 | 669 |
| 670 void InstallerState::RemoveOldVersionDirectories( | 670 void InstallerState::RemoveOldVersionDirectories( |
| 671 const Version& new_version, | 671 const Version& new_version, |
| 672 Version* existing_version, | 672 Version* existing_version, |
| 673 const base::FilePath& temp_path) const { | 673 const base::FilePath& temp_path) const { |
| 674 Version version; | 674 Version version; |
| 675 scoped_ptr<WorkItem> item; | 675 scoped_ptr<WorkItem> item; |
| 676 | 676 |
| 677 std::set<std::string> existing_version_strings; | 677 std::set<std::string> existing_version_strings; |
| 678 existing_version_strings.insert(new_version.GetString()); | 678 existing_version_strings.insert(new_version.GetString()); |
| 679 if (existing_version) | 679 if (existing_version) |
| 680 existing_version_strings.insert(existing_version->GetString()); | 680 existing_version_strings.insert(existing_version->GetString()); |
| 681 | 681 |
| 682 // Make sure not to delete any version dir that is "referenced" by an existing | 682 // Make sure not to delete any version dir that is "referenced" by an existing |
| 683 // Chrome executable. | 683 // Chrome executable. |
| 684 GetExistingExeVersions(&existing_version_strings); | 684 GetExistingExeVersions(&existing_version_strings); |
| 685 | 685 |
| 686 // Try to delete all directories that are not in the set we care to keep. | 686 // Try to delete all directories that are not in the set we care to keep. |
| 687 base::FileEnumerator version_enum(target_path(), false, | 687 base::FileEnumerator version_enum(target_path(), false, |
| 688 base::FileEnumerator::DIRECTORIES); | 688 base::FileEnumerator::DIRECTORIES); |
| 689 for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); | 689 for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); |
| 690 next_version = version_enum.Next()) { | 690 next_version = version_enum.Next()) { |
| 691 base::FilePath dir_name(next_version.BaseName()); | 691 base::FilePath dir_name(next_version.BaseName()); |
| 692 version = Version(WideToASCII(dir_name.value())); | 692 version = Version(base::UTF16ToASCII(dir_name.value())); |
| 693 // Delete the version folder if it is less than the new version and not | 693 // Delete the version folder if it is less than the new version and not |
| 694 // equal to the old version (if we have an old version). | 694 // equal to the old version (if we have an old version). |
| 695 if (version.IsValid() && | 695 if (version.IsValid() && |
| 696 existing_version_strings.count(version.GetString()) == 0) { | 696 existing_version_strings.count(version.GetString()) == 0) { |
| 697 // Note: temporarily log old version deletion at ERROR level to make it | 697 // Note: temporarily log old version deletion at ERROR level to make it |
| 698 // more likely we see this in the installer log. | 698 // more likely we see this in the installer log. |
| 699 LOG(ERROR) << "Deleting old version directory: " << next_version.value(); | 699 LOG(ERROR) << "Deleting old version directory: " << next_version.value(); |
| 700 | 700 |
| 701 // Attempt to recursively delete the old version dir. | 701 // Attempt to recursively delete the old version dir. |
| 702 bool delete_succeeded = base::DeleteFile(next_version, true); | 702 bool delete_succeeded = base::DeleteFile(next_version, true); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 823 } | 823 } |
| 824 if (!install_list->Do()) | 824 if (!install_list->Do()) |
| 825 LOG(ERROR) << "Failed to record installer error information in registry."; | 825 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 826 } | 826 } |
| 827 | 827 |
| 828 bool InstallerState::RequiresActiveSetup() const { | 828 bool InstallerState::RequiresActiveSetup() const { |
| 829 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 829 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 830 } | 830 } |
| 831 | 831 |
| 832 } // namespace installer | 832 } // namespace installer |
| OLD | NEW |