| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return CommandLine(CommandLine::NO_PROGRAM); | 215 return CommandLine(CommandLine::NO_PROGRAM); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void InstallUtil::GetChromeVersion(BrowserDistribution* dist, | 218 void InstallUtil::GetChromeVersion(BrowserDistribution* dist, |
| 219 bool system_install, | 219 bool system_install, |
| 220 Version* version) { | 220 Version* version) { |
| 221 DCHECK(dist); | 221 DCHECK(dist); |
| 222 RegKey key; | 222 RegKey key; |
| 223 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 223 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 224 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), | 224 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), |
| 225 KEY_QUERY_VALUE); | 225 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
| 226 | 226 |
| 227 base::string16 version_str; | 227 base::string16 version_str; |
| 228 if (result == ERROR_SUCCESS) | 228 if (result == ERROR_SUCCESS) |
| 229 result = key.ReadValue(google_update::kRegVersionField, &version_str); | 229 result = key.ReadValue(google_update::kRegVersionField, &version_str); |
| 230 | 230 |
| 231 *version = Version(); | 231 *version = Version(); |
| 232 if (result == ERROR_SUCCESS && !version_str.empty()) { | 232 if (result == ERROR_SUCCESS && !version_str.empty()) { |
| 233 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " | 233 VLOG(1) << "Existing " << dist->GetDisplayName() << " version found " |
| 234 << version_str; | 234 << version_str; |
| 235 *version = Version(base::UTF16ToASCII(version_str)); | 235 *version = Version(base::UTF16ToASCII(version_str)); |
| 236 } else { | 236 } else { |
| 237 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); | 237 DCHECK_EQ(ERROR_FILE_NOT_FOUND, result); |
| 238 VLOG(1) << "No existing " << dist->GetDisplayName() | 238 VLOG(1) << "No existing " << dist->GetDisplayName() |
| 239 << " install found."; | 239 << " install found."; |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 | 242 |
| 243 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, | 243 void InstallUtil::GetCriticalUpdateVersion(BrowserDistribution* dist, |
| 244 bool system_install, | 244 bool system_install, |
| 245 Version* version) { | 245 Version* version) { |
| 246 DCHECK(dist); | 246 DCHECK(dist); |
| 247 RegKey key; | 247 RegKey key; |
| 248 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 248 HKEY reg_root = (system_install) ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 249 LONG result = | 249 LONG result = key.Open(reg_root, dist->GetVersionKey().c_str(), |
| 250 key.Open(reg_root, dist->GetVersionKey().c_str(), KEY_QUERY_VALUE); | 250 KEY_QUERY_VALUE | KEY_WOW64_32KEY); |
| 251 | 251 |
| 252 base::string16 version_str; | 252 base::string16 version_str; |
| 253 if (result == ERROR_SUCCESS) | 253 if (result == ERROR_SUCCESS) |
| 254 result = key.ReadValue(google_update::kRegCriticalVersionField, | 254 result = key.ReadValue(google_update::kRegCriticalVersionField, |
| 255 &version_str); | 255 &version_str); |
| 256 | 256 |
| 257 *version = Version(); | 257 *version = Version(); |
| 258 if (result == ERROR_SUCCESS && !version_str.empty()) { | 258 if (result == ERROR_SUCCESS && !version_str.empty()) { |
| 259 VLOG(1) << "Critical Update version for " << dist->GetDisplayName() | 259 VLOG(1) << "Critical Update version for " << dist->GetDisplayName() |
| 260 << " found " << version_str; | 260 << " found " << version_str; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 280 bool system_install, | 280 bool system_install, |
| 281 const base::string16& state_key, | 281 const base::string16& state_key, |
| 282 installer::InstallStatus status, | 282 installer::InstallStatus status, |
| 283 int string_resource_id, | 283 int string_resource_id, |
| 284 const base::string16* const launch_cmd, | 284 const base::string16* const launch_cmd, |
| 285 WorkItemList* install_list) { | 285 WorkItemList* install_list) { |
| 286 DCHECK(install_list); | 286 DCHECK(install_list); |
| 287 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 287 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 288 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; | 288 DWORD installer_result = (GetInstallReturnCode(status) == 0) ? 0 : 1; |
| 289 install_list->AddCreateRegKeyWorkItem( | 289 install_list->AddCreateRegKeyWorkItem( |
| 290 root, state_key, WorkItem::kWow64Default); | 290 root, state_key, KEY_WOW64_32KEY); |
| 291 install_list->AddSetRegValueWorkItem(root, | 291 install_list->AddSetRegValueWorkItem(root, |
| 292 state_key, | 292 state_key, |
| 293 WorkItem::kWow64Default, | 293 KEY_WOW64_32KEY, |
| 294 installer::kInstallerResult, | 294 installer::kInstallerResult, |
| 295 installer_result, | 295 installer_result, |
| 296 true); | 296 true); |
| 297 install_list->AddSetRegValueWorkItem(root, | 297 install_list->AddSetRegValueWorkItem(root, |
| 298 state_key, | 298 state_key, |
| 299 WorkItem::kWow64Default, | 299 KEY_WOW64_32KEY, |
| 300 installer::kInstallerError, | 300 installer::kInstallerError, |
| 301 static_cast<DWORD>(status), | 301 static_cast<DWORD>(status), |
| 302 true); | 302 true); |
| 303 if (string_resource_id != 0) { | 303 if (string_resource_id != 0) { |
| 304 base::string16 msg = installer::GetLocalizedString(string_resource_id); | 304 base::string16 msg = installer::GetLocalizedString(string_resource_id); |
| 305 install_list->AddSetRegValueWorkItem(root, | 305 install_list->AddSetRegValueWorkItem(root, |
| 306 state_key, | 306 state_key, |
| 307 WorkItem::kWow64Default, | 307 KEY_WOW64_32KEY, |
| 308 installer::kInstallerResultUIString, | 308 installer::kInstallerResultUIString, |
| 309 msg, | 309 msg, |
| 310 true); | 310 true); |
| 311 } | 311 } |
| 312 if (launch_cmd != NULL && !launch_cmd->empty()) { | 312 if (launch_cmd != NULL && !launch_cmd->empty()) { |
| 313 install_list->AddSetRegValueWorkItem( | 313 install_list->AddSetRegValueWorkItem( |
| 314 root, | 314 root, |
| 315 state_key, | 315 state_key, |
| 316 WorkItem::kWow64Default, | 316 KEY_WOW64_32KEY, |
| 317 installer::kInstallerSuccessLaunchCmdLine, | 317 installer::kInstallerSuccessLaunchCmdLine, |
| 318 *launch_cmd, | 318 *launch_cmd, |
| 319 true); | 319 true); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 void InstallUtil::UpdateInstallerStage(bool system_install, | 323 void InstallUtil::UpdateInstallerStage(bool system_install, |
| 324 const base::string16& state_key_path, | 324 const base::string16& state_key_path, |
| 325 installer::InstallerStage stage) { | 325 installer::InstallerStage stage) { |
| 326 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); | 326 DCHECK_LE(static_cast<installer::InstallerStage>(0), stage); |
| 327 DCHECK_GT(installer::NUM_STAGES, stage); | 327 DCHECK_GT(installer::NUM_STAGES, stage); |
| 328 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; | 328 const HKEY root = system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER; |
| 329 RegKey state_key; | 329 RegKey state_key; |
| 330 LONG result = state_key.Open(root, state_key_path.c_str(), | 330 LONG result = state_key.Open(root, state_key_path.c_str(), |
| 331 KEY_QUERY_VALUE | KEY_SET_VALUE); | 331 KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_WOW64_32KEY); |
| 332 if (result == ERROR_SUCCESS) { | 332 if (result == ERROR_SUCCESS) { |
| 333 if (stage == installer::NO_STAGE) { | 333 if (stage == installer::NO_STAGE) { |
| 334 result = state_key.DeleteValue(installer::kInstallerExtraCode1); | 334 result = state_key.DeleteValue(installer::kInstallerExtraCode1); |
| 335 LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) | 335 LOG_IF(ERROR, result != ERROR_SUCCESS && result != ERROR_FILE_NOT_FOUND) |
| 336 << "Failed deleting installer stage from " << state_key_path | 336 << "Failed deleting installer stage from " << state_key_path |
| 337 << "; result: " << result; | 337 << "; result: " << result; |
| 338 } else { | 338 } else { |
| 339 const DWORD extra_code_1 = static_cast<DWORD>(stage); | 339 const DWORD extra_code_1 = static_cast<DWORD>(stage); |
| 340 result = state_key.WriteValue(installer::kInstallerExtraCode1, | 340 result = state_key.WriteValue(installer::kInstallerExtraCode1, |
| 341 extra_code_1); | 341 extra_code_1); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 // Open the program and see if it references the expected file. | 637 // Open the program and see if it references the expected file. |
| 638 base::File file; | 638 base::File file; |
| 639 BY_HANDLE_FILE_INFORMATION info = {}; | 639 BY_HANDLE_FILE_INFORMATION info = {}; |
| 640 | 640 |
| 641 return (OpenForInfo(path, &file) && | 641 return (OpenForInfo(path, &file) && |
| 642 GetInfo(file, &info) && | 642 GetInfo(file, &info) && |
| 643 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && | 643 info.dwVolumeSerialNumber == file_info_.dwVolumeSerialNumber && |
| 644 info.nFileIndexHigh == file_info_.nFileIndexHigh && | 644 info.nFileIndexHigh == file_info_.nFileIndexHigh && |
| 645 info.nFileIndexLow == file_info_.nFileIndexLow); | 645 info.nFileIndexLow == file_info_.nFileIndexLow); |
| 646 } | 646 } |
| OLD | NEW |