| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/package.h" | 5 #include "chrome/installer/util/package.h" | 
| 6 | 6 | 
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" | 
| 8 #include "base/logging.h" | 8 #include "base/logging.h" | 
|  | 9 #include "base/string_util.h" | 
| 9 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" | 
| 10 #include "base/win/registry.h" | 11 #include "base/win/registry.h" | 
| 11 #include "chrome/installer/util/channel_info.h" | 12 #include "chrome/installer/util/channel_info.h" | 
| 12 #include "chrome/installer/util/delete_tree_work_item.h" | 13 #include "chrome/installer/util/delete_tree_work_item.h" | 
| 13 #include "chrome/installer/util/google_update_constants.h" | 14 #include "chrome/installer/util/google_update_constants.h" | 
| 14 #include "chrome/installer/util/master_preferences.h" | 15 #include "chrome/installer/util/master_preferences.h" | 
| 15 #include "chrome/installer/util/package_properties.h" | 16 #include "chrome/installer/util/package_properties.h" | 
| 16 #include "chrome/installer/util/product.h" | 17 #include "chrome/installer/util/product.h" | 
| 17 | 18 | 
| 18 using base::win::RegKey; | 19 using base::win::RegKey; | 
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 80     RegKey chrome_key(root, product->distribution()->GetVersionKey().c_str(), | 81     RegKey chrome_key(root, product->distribution()->GetVersionKey().c_str(), | 
| 81                       KEY_READ); | 82                       KEY_READ); | 
| 82     std::wstring version; | 83     std::wstring version; | 
| 83     if (new_chrome_exists) | 84     if (new_chrome_exists) | 
| 84       chrome_key.ReadValue(google_update::kRegOldVersionField, &version); | 85       chrome_key.ReadValue(google_update::kRegOldVersionField, &version); | 
| 85 | 86 | 
| 86     if (version.empty()) | 87     if (version.empty()) | 
| 87       chrome_key.ReadValue(google_update::kRegVersionField, &version); | 88       chrome_key.ReadValue(google_update::kRegVersionField, &version); | 
| 88 | 89 | 
| 89     if (!version.empty()) { | 90     if (!version.empty()) { | 
| 90       scoped_ptr<Version> this_version(Version::GetVersionFromString(version)); | 91       scoped_ptr<Version> this_version(Version::GetVersionFromString( | 
|  | 92                                            WideToASCII(version))); | 
| 91       if (this_version.get()) { | 93       if (this_version.get()) { | 
| 92         if (!current_version.get() || | 94         if (!current_version.get() || | 
| 93             (current_version->CompareTo(*this_version) > 0)) { | 95             (current_version->CompareTo(*this_version) > 0)) { | 
| 94           current_version.reset(this_version.release()); | 96           current_version.reset(this_version.release()); | 
| 95         } else if (current_version.get()) { | 97         } else if (current_version.get()) { | 
| 96           DCHECK_EQ(current_version->GetString(), this_version->GetString()) | 98           DCHECK_EQ(current_version->GetString(), this_version->GetString()) | 
| 97               << "found distributions of different versions in the same " | 99               << "found distributions of different versions in the same " | 
| 98                  "installation folder!"; | 100                  "installation folder!"; | 
| 99         } | 101         } | 
| 100       } | 102       } | 
| 101     } | 103     } | 
| 102   } | 104   } | 
| 103 | 105 | 
| 104   return current_version.release(); | 106   return current_version.release(); | 
| 105 } | 107 } | 
| 106 | 108 | 
| 107 void Package::RemoveOldVersionDirectories( | 109 void Package::RemoveOldVersionDirectories( | 
| 108     const Version& latest_version) const { | 110     const Version& latest_version) const { | 
| 109   file_util::FileEnumerator version_enum(path_, false, | 111   file_util::FileEnumerator version_enum(path_, false, | 
| 110       file_util::FileEnumerator::DIRECTORIES); | 112       file_util::FileEnumerator::DIRECTORIES); | 
| 111   scoped_ptr<Version> version; | 113   scoped_ptr<Version> version; | 
| 112 | 114 | 
| 113   // We try to delete all directories whose versions are lower than | 115   // We try to delete all directories whose versions are lower than | 
| 114   // latest_version. | 116   // latest_version. | 
| 115   FilePath next_version = version_enum.Next(); | 117   FilePath next_version = version_enum.Next(); | 
| 116   while (!next_version.empty()) { | 118   while (!next_version.empty()) { | 
| 117     file_util::FileEnumerator::FindInfo find_data = {0}; | 119     file_util::FileEnumerator::FindInfo find_data = {0}; | 
| 118     version_enum.GetFindInfo(&find_data); | 120     version_enum.GetFindInfo(&find_data); | 
| 119     VLOG(1) << "directory found: " << find_data.cFileName; | 121     VLOG(1) << "directory found: " << find_data.cFileName; | 
| 120     version.reset(Version::GetVersionFromString(find_data.cFileName)); | 122     version.reset(Version::GetVersionFromString( | 
|  | 123                       WideToASCII(find_data.cFileName))); | 
| 121     if (version.get() && (latest_version.CompareTo(*version) > 0)) { | 124     if (version.get() && (latest_version.CompareTo(*version) > 0)) { | 
| 122       std::vector<FilePath> key_files; | 125       std::vector<FilePath> key_files; | 
| 123       for (Products::const_iterator it = products_.begin(); | 126       for (Products::const_iterator it = products_.begin(); | 
| 124           it != products_.end(); ++it) { | 127           it != products_.end(); ++it) { | 
| 125         BrowserDistribution* dist = it->get()->distribution(); | 128         BrowserDistribution* dist = it->get()->distribution(); | 
| 126         std::vector<FilePath> dist_key_files(dist->GetKeyFiles()); | 129         std::vector<FilePath> dist_key_files(dist->GetKeyFiles()); | 
| 127         std::vector<FilePath>::const_iterator key_file_iter( | 130         std::vector<FilePath>::const_iterator key_file_iter( | 
| 128             dist_key_files.begin()); | 131             dist_key_files.begin()); | 
| 129         for (; key_file_iter != dist_key_files.end(); ++key_file_iter) { | 132         for (; key_file_iter != dist_key_files.end(); ++key_file_iter) { | 
| 130           key_files.push_back(next_version.Append(*key_file_iter)); | 133           key_files.push_back(next_version.Append(*key_file_iter)); | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 178                   << dist->GetApplicationName(); | 181                   << dist->GetApplicationName(); | 
| 179       } | 182       } | 
| 180     } | 183     } | 
| 181   } | 184   } | 
| 182 | 185 | 
| 183   return ret; | 186   return ret; | 
| 184 } | 187 } | 
| 185 | 188 | 
| 186 }  // namespace installer | 189 }  // namespace installer | 
| 187 | 190 | 
| OLD | NEW | 
|---|