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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
| 14 #include "base/files/file_enumerator.h" |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/string_util.h" | 17 #include "base/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
18 #include "base/win/registry.h" | 19 #include "base/win/registry.h" |
19 #include "base/win/scoped_handle.h" | 20 #include "base/win/scoped_handle.h" |
20 #include "chrome/installer/util/delete_tree_work_item.h" | 21 #include "chrome/installer/util/delete_tree_work_item.h" |
21 #include "chrome/installer/util/helper.h" | 22 #include "chrome/installer/util/helper.h" |
22 #include "chrome/installer/util/install_util.h" | 23 #include "chrome/installer/util/install_util.h" |
23 #include "chrome/installer/util/installation_state.h" | 24 #include "chrome/installer/util/installation_state.h" |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 std::set<std::string> existing_version_strings; | 643 std::set<std::string> existing_version_strings; |
643 existing_version_strings.insert(new_version.GetString()); | 644 existing_version_strings.insert(new_version.GetString()); |
644 if (existing_version) | 645 if (existing_version) |
645 existing_version_strings.insert(existing_version->GetString()); | 646 existing_version_strings.insert(existing_version->GetString()); |
646 | 647 |
647 // Make sure not to delete any version dir that is "referenced" by an existing | 648 // Make sure not to delete any version dir that is "referenced" by an existing |
648 // Chrome executable. | 649 // Chrome executable. |
649 GetExistingExeVersions(&existing_version_strings); | 650 GetExistingExeVersions(&existing_version_strings); |
650 | 651 |
651 // Try to delete all directories that are not in the set we care to keep. | 652 // Try to delete all directories that are not in the set we care to keep. |
652 file_util::FileEnumerator version_enum(target_path(), false, | 653 base::FileEnumerator version_enum(target_path(), false, |
653 file_util::FileEnumerator::DIRECTORIES); | 654 base::FileEnumerator::DIRECTORIES); |
654 for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); | 655 for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); |
655 next_version = version_enum.Next()) { | 656 next_version = version_enum.Next()) { |
656 base::FilePath dir_name(next_version.BaseName()); | 657 base::FilePath dir_name(next_version.BaseName()); |
657 version = Version(WideToASCII(dir_name.value())); | 658 version = Version(WideToASCII(dir_name.value())); |
658 // Delete the version folder if it is less than the new version and not | 659 // Delete the version folder if it is less than the new version and not |
659 // equal to the old version (if we have an old version). | 660 // equal to the old version (if we have an old version). |
660 if (version.IsValid() && | 661 if (version.IsValid() && |
661 existing_version_strings.count(version.GetString()) == 0) { | 662 existing_version_strings.count(version.GetString()) == 0) { |
662 // Note: temporarily log old version deletion at ERROR level to make it | 663 // Note: temporarily log old version deletion at ERROR level to make it |
663 // more likely we see this in the installer log. | 664 // more likely we see this in the installer log. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 } | 791 } |
791 if (!install_list->Do()) | 792 if (!install_list->Do()) |
792 LOG(ERROR) << "Failed to record installer error information in registry."; | 793 LOG(ERROR) << "Failed to record installer error information in registry."; |
793 } | 794 } |
794 | 795 |
795 bool InstallerState::RequiresActiveSetup() const { | 796 bool InstallerState::RequiresActiveSetup() const { |
796 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); | 797 return system_install() && FindProduct(BrowserDistribution::CHROME_BROWSER); |
797 } | 798 } |
798 | 799 |
799 } // namespace installer | 800 } // namespace installer |
OLD | NEW |