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