| 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 // This file declares util functions for setup project. | 5 // This file declares util functions for setup project. |
| 6 | 6 |
| 7 #include "chrome/installer/setup/setup_util.h" | 7 #include "chrome/installer/setup/setup_util.h" |
| 8 | 8 |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 patch_status + kBsdiffErrorOffset : 0; | 132 patch_status + kBsdiffErrorOffset : 0; |
| 133 | 133 |
| 134 LOG_IF(ERROR, exit_code) | 134 LOG_IF(ERROR, exit_code) |
| 135 << "Failed to apply bsdiff patch " << patch.value() | 135 << "Failed to apply bsdiff patch " << patch.value() |
| 136 << " to file " << src.value() << " and generating file " << dest.value() | 136 << " to file " << src.value() << " and generating file " << dest.value() |
| 137 << ". err=" << exit_code; | 137 << ". err=" << exit_code; |
| 138 | 138 |
| 139 return exit_code; | 139 return exit_code; |
| 140 } | 140 } |
| 141 | 141 |
| 142 base::Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { | 142 Version* GetMaxVersionFromArchiveDir(const base::FilePath& chrome_path) { |
| 143 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); | 143 VLOG(1) << "Looking for Chrome version folder under " << chrome_path.value(); |
| 144 base::FileEnumerator version_enum(chrome_path, false, | 144 base::FileEnumerator version_enum(chrome_path, false, |
| 145 base::FileEnumerator::DIRECTORIES); | 145 base::FileEnumerator::DIRECTORIES); |
| 146 // TODO(tommi): The version directory really should match the version of | 146 // TODO(tommi): The version directory really should match the version of |
| 147 // setup.exe. To begin with, we should at least DCHECK that that's true. | 147 // setup.exe. To begin with, we should at least DCHECK that that's true. |
| 148 | 148 |
| 149 scoped_ptr<base::Version> max_version(new base::Version("0.0.0.0")); | 149 scoped_ptr<Version> max_version(new Version("0.0.0.0")); |
| 150 bool version_found = false; | 150 bool version_found = false; |
| 151 | 151 |
| 152 while (!version_enum.Next().empty()) { | 152 while (!version_enum.Next().empty()) { |
| 153 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); | 153 base::FileEnumerator::FileInfo find_data = version_enum.GetInfo(); |
| 154 VLOG(1) << "directory found: " << find_data.GetName().value(); | 154 VLOG(1) << "directory found: " << find_data.GetName().value(); |
| 155 | 155 |
| 156 scoped_ptr<base::Version> found_version( | 156 scoped_ptr<Version> found_version( |
| 157 new base::Version(WideToASCII(find_data.GetName().value()))); | 157 new Version(WideToASCII(find_data.GetName().value()))); |
| 158 if (found_version->IsValid() && | 158 if (found_version->IsValid() && |
| 159 found_version->CompareTo(*max_version.get()) > 0) { | 159 found_version->CompareTo(*max_version.get()) > 0) { |
| 160 max_version.reset(found_version.release()); | 160 max_version.reset(found_version.release()); |
| 161 version_found = true; | 161 version_found = true; |
| 162 } | 162 } |
| 163 } | 163 } |
| 164 | 164 |
| 165 return (version_found ? max_version.release() : NULL); | 165 return (version_found ? max_version.release() : NULL); |
| 166 } | 166 } |
| 167 | 167 |
| 168 base::FilePath FindArchiveToPatch(const InstallationState& original_state, | 168 base::FilePath FindArchiveToPatch(const InstallationState& original_state, |
| 169 const InstallerState& installer_state) { | 169 const InstallerState& installer_state) { |
| 170 // Check based on the version number advertised to Google Update, since that | 170 // Check based on the version number advertised to Google Update, since that |
| 171 // is the value used to select a specific differential update. If an archive | 171 // is the value used to select a specific differential update. If an archive |
| 172 // can't be found using that, fallback to using the newest version present. | 172 // can't be found using that, fallback to using the newest version present. |
| 173 base::FilePath patch_source; | 173 base::FilePath patch_source; |
| 174 const ProductState* product = | 174 const ProductState* product = |
| 175 original_state.GetProductState(installer_state.system_install(), | 175 original_state.GetProductState(installer_state.system_install(), |
| 176 installer_state.state_type()); | 176 installer_state.state_type()); |
| 177 if (product) { | 177 if (product) { |
| 178 patch_source = installer_state.GetInstallerDirectory(product->version()) | 178 patch_source = installer_state.GetInstallerDirectory(product->version()) |
| 179 .Append(installer::kChromeArchive); | 179 .Append(installer::kChromeArchive); |
| 180 if (base::PathExists(patch_source)) | 180 if (base::PathExists(patch_source)) |
| 181 return patch_source; | 181 return patch_source; |
| 182 } | 182 } |
| 183 scoped_ptr<base::Version> version( | 183 scoped_ptr<Version> version( |
| 184 installer::GetMaxVersionFromArchiveDir(installer_state.target_path())); | 184 installer::GetMaxVersionFromArchiveDir(installer_state.target_path())); |
| 185 if (version) { | 185 if (version) { |
| 186 patch_source = installer_state.GetInstallerDirectory(*version) | 186 patch_source = installer_state.GetInstallerDirectory(*version) |
| 187 .Append(installer::kChromeArchive); | 187 .Append(installer::kChromeArchive); |
| 188 if (base::PathExists(patch_source)) | 188 if (base::PathExists(patch_source)) |
| 189 return patch_source; | 189 return patch_source; |
| 190 } | 190 } |
| 191 return base::FilePath(); | 191 return base::FilePath(); |
| 192 } | 192 } |
| 193 | 193 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 ::CloseHandle(pi.hThread); | 245 ::CloseHandle(pi.hThread); |
| 246 ::CloseHandle(pi.hProcess); | 246 ::CloseHandle(pi.hProcess); |
| 247 } | 247 } |
| 248 | 248 |
| 249 return ok != FALSE; | 249 return ok != FALSE; |
| 250 } | 250 } |
| 251 | 251 |
| 252 bool GetExistingHigherInstaller( | 252 bool GetExistingHigherInstaller( |
| 253 const InstallationState& original_state, | 253 const InstallationState& original_state, |
| 254 bool system_install, | 254 bool system_install, |
| 255 const base::Version& installer_version, | 255 const Version& installer_version, |
| 256 base::FilePath* setup_exe) { | 256 base::FilePath* setup_exe) { |
| 257 DCHECK(setup_exe); | 257 DCHECK(setup_exe); |
| 258 bool trying_single_browser = false; | 258 bool trying_single_browser = false; |
| 259 const ProductState* existing_state = | 259 const ProductState* existing_state = |
| 260 original_state.GetProductState(system_install, | 260 original_state.GetProductState(system_install, |
| 261 BrowserDistribution::CHROME_BINARIES); | 261 BrowserDistribution::CHROME_BINARIES); |
| 262 if (!existing_state) { | 262 if (!existing_state) { |
| 263 // The binaries aren't installed, but perhaps a single-install Chrome is. | 263 // The binaries aren't installed, but perhaps a single-install Chrome is. |
| 264 trying_single_browser = true; | 264 trying_single_browser = true; |
| 265 existing_state = | 265 existing_state = |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 | 484 |
| 485 ScopedTokenPrivilege::~ScopedTokenPrivilege() { | 485 ScopedTokenPrivilege::~ScopedTokenPrivilege() { |
| 486 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { | 486 if (is_enabled_ && previous_privileges_.PrivilegeCount != 0) { |
| 487 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, | 487 ::AdjustTokenPrivileges(token_, FALSE, &previous_privileges_, |
| 488 sizeof(TOKEN_PRIVILEGES), NULL, NULL); | 488 sizeof(TOKEN_PRIVILEGES), NULL, NULL); |
| 489 } | 489 } |
| 490 } | 490 } |
| 491 | 491 |
| 492 } // namespace installer | 492 } // namespace installer |
| OLD | NEW |