| 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 <string> | 5 #include <string> |
| 6 #include <windows.h> | 6 #include <windows.h> |
| 7 #include <msi.h> | 7 #include <msi.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 return install_status; | 224 return install_status; |
| 225 | 225 |
| 226 // For install the default location for chrome.packed.7z is in current | 226 // For install the default location for chrome.packed.7z is in current |
| 227 // folder, so get that value first. | 227 // folder, so get that value first. |
| 228 std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program()); | 228 std::wstring archive = file_util::GetDirectoryFromPath(cmd_line.program()); |
| 229 file_util::AppendToPath(&archive, | 229 file_util::AppendToPath(&archive, |
| 230 std::wstring(installer::kChromeCompressedArchive)); | 230 std::wstring(installer::kChromeCompressedArchive)); |
| 231 | 231 |
| 232 // If --install-archive is given, get the user specified value | 232 // If --install-archive is given, get the user specified value |
| 233 if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) { | 233 if (cmd_line.HasSwitch(installer_util::switches::kInstallArchive)) { |
| 234 archive = cmd_line.GetSwitchValue( | 234 archive = cmd_line.GetSwitchValueNative( |
| 235 installer_util::switches::kInstallArchive); | 235 installer_util::switches::kInstallArchive); |
| 236 } | 236 } |
| 237 LOG(INFO) << "Archive found to install Chrome " << archive; | 237 LOG(INFO) << "Archive found to install Chrome " << archive; |
| 238 | 238 |
| 239 // Create a temp folder where we will unpack Chrome archive. If it fails, | 239 // Create a temp folder where we will unpack Chrome archive. If it fails, |
| 240 // then we are doomed, so return immediately and no cleanup is required. | 240 // then we are doomed, so return immediately and no cleanup is required. |
| 241 FilePath temp_path; | 241 FilePath temp_path; |
| 242 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 242 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
| 243 LOG(ERROR) << "Could not create temporary path."; | 243 LOG(ERROR) << "Could not create temporary path."; |
| 244 InstallUtil::WriteInstallerResult(system_level, | 244 InstallUtil::WriteInstallerResult(system_level, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 LOG(ERROR) << "Higher version is already installed."; | 280 LOG(ERROR) << "Higher version is already installed."; |
| 281 install_status = installer_util::HIGHER_VERSION_EXISTS; | 281 install_status = installer_util::HIGHER_VERSION_EXISTS; |
| 282 InstallUtil::WriteInstallerResult(system_level, install_status, | 282 InstallUtil::WriteInstallerResult(system_level, install_status, |
| 283 IDS_INSTALL_HIGHER_VERSION_BASE, | 283 IDS_INSTALL_HIGHER_VERSION_BASE, |
| 284 NULL); | 284 NULL); |
| 285 } else { | 285 } else { |
| 286 // We want to keep uncompressed archive (chrome.7z) that we get after | 286 // We want to keep uncompressed archive (chrome.7z) that we get after |
| 287 // uncompressing and binary patching. Get the location for this file. | 287 // uncompressing and binary patching. Get the location for this file. |
| 288 std::wstring archive_to_copy(temp_path.ToWStringHack()); | 288 std::wstring archive_to_copy(temp_path.ToWStringHack()); |
| 289 file_util::AppendToPath(&archive_to_copy, installer::kChromeArchive); | 289 file_util::AppendToPath(&archive_to_copy, installer::kChromeArchive); |
| 290 std::wstring prefs_source_path = cmd_line.GetSwitchValue( | 290 std::wstring prefs_source_path = cmd_line.GetSwitchValueNative( |
| 291 installer_util::switches::kInstallerData); | 291 installer_util::switches::kInstallerData); |
| 292 install_status = installer::InstallOrUpdateChrome( | 292 install_status = installer::InstallOrUpdateChrome( |
| 293 cmd_line.program(), archive_to_copy, temp_path.ToWStringHack(), | 293 cmd_line.program(), archive_to_copy, temp_path.ToWStringHack(), |
| 294 prefs_source_path, prefs, *installer_version, installed_version); | 294 prefs_source_path, prefs, *installer_version, installed_version); |
| 295 | 295 |
| 296 int install_msg_base = IDS_INSTALL_FAILED_BASE; | 296 int install_msg_base = IDS_INSTALL_FAILED_BASE; |
| 297 std::wstring chrome_exe; | 297 std::wstring chrome_exe; |
| 298 if (install_status == installer_util::SAME_VERSION_REPAIR_FAILED) { | 298 if (install_status == installer_util::SAME_VERSION_REPAIR_FAILED) { |
| 299 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; | 299 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; |
| 300 } else if (install_status != installer_util::INSTALL_FAILED) { | 300 } else if (install_status != installer_util::INSTALL_FAILED) { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 system_level); | 347 system_level); |
| 348 } | 348 } |
| 349 | 349 |
| 350 // Delete temporary files. These include install temporary directory | 350 // Delete temporary files. These include install temporary directory |
| 351 // and master profile file if present. Note that we do not care about rollback | 351 // and master profile file if present. Note that we do not care about rollback |
| 352 // here and we schedule for deletion on reboot below if the deletes fail. As | 352 // here and we schedule for deletion on reboot below if the deletes fail. As |
| 353 // such, we do not use DeleteTreeWorkItem. | 353 // such, we do not use DeleteTreeWorkItem. |
| 354 LOG(INFO) << "Deleting temporary directory " << temp_path.value(); | 354 LOG(INFO) << "Deleting temporary directory " << temp_path.value(); |
| 355 bool cleanup_success = file_util::Delete(temp_path, true); | 355 bool cleanup_success = file_util::Delete(temp_path, true); |
| 356 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { | 356 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { |
| 357 std::wstring prefs_path = cmd_line.GetSwitchValue( | 357 std::wstring prefs_path = cmd_line.GetSwitchValueNative( |
| 358 installer_util::switches::kInstallerData); | 358 installer_util::switches::kInstallerData); |
| 359 cleanup_success = file_util::Delete(prefs_path, true) && cleanup_success; | 359 cleanup_success = file_util::Delete(prefs_path, true) && cleanup_success; |
| 360 } | 360 } |
| 361 | 361 |
| 362 // The above cleanup has been observed to fail on several users machines. | 362 // The above cleanup has been observed to fail on several users machines. |
| 363 // Specifically, it appears that the temp folder may be locked when we try | 363 // Specifically, it appears that the temp folder may be locked when we try |
| 364 // to delete it. This is Rather Bad in the case where we have failed updates | 364 // to delete it. This is Rather Bad in the case where we have failed updates |
| 365 // as we end up filling users' disks with large-ish temp files. To mitigate | 365 // as we end up filling users' disks with large-ish temp files. To mitigate |
| 366 // this, if we fail to delete the temp folders, then schedule them for | 366 // this, if we fail to delete the temp folders, then schedule them for |
| 367 // deletion at next reboot. | 367 // deletion at next reboot. |
| 368 if (!cleanup_success) { | 368 if (!cleanup_success) { |
| 369 ScheduleDirectoryForDeletion(temp_path.ToWStringHack().c_str()); | 369 ScheduleDirectoryForDeletion(temp_path.ToWStringHack().c_str()); |
| 370 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { | 370 if (cmd_line.HasSwitch(installer_util::switches::kInstallerData)) { |
| 371 std::wstring prefs_path = cmd_line.GetSwitchValue( | 371 std::wstring prefs_path = cmd_line.GetSwitchValueNative( |
| 372 installer_util::switches::kInstallerData); | 372 installer_util::switches::kInstallerData); |
| 373 ScheduleDirectoryForDeletion(prefs_path.c_str()); | 373 ScheduleDirectoryForDeletion(prefs_path.c_str()); |
| 374 } | 374 } |
| 375 } | 375 } |
| 376 | 376 |
| 377 dist->UpdateDiffInstallStatus(system_level, incremental_install, | 377 dist->UpdateDiffInstallStatus(system_level, incremental_install, |
| 378 install_status); | 378 install_status); |
| 379 return install_status; | 379 return install_status; |
| 380 } | 380 } |
| 381 | 381 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 if (cmd_line.HasSwitch(installer_util::switches::kUpdateSetupExe)) { | 439 if (cmd_line.HasSwitch(installer_util::switches::kUpdateSetupExe)) { |
| 440 installer_util::InstallStatus status = installer_util::SETUP_PATCH_FAILED; | 440 installer_util::InstallStatus status = installer_util::SETUP_PATCH_FAILED; |
| 441 // If --update-setup-exe command line option is given, we apply the given | 441 // If --update-setup-exe command line option is given, we apply the given |
| 442 // patch to current exe, and store the resulting binary in the path | 442 // patch to current exe, and store the resulting binary in the path |
| 443 // specified by --new-setup-exe. But we need to first unpack the file | 443 // specified by --new-setup-exe. But we need to first unpack the file |
| 444 // given in --update-setup-exe. | 444 // given in --update-setup-exe. |
| 445 FilePath temp_path; | 445 FilePath temp_path; |
| 446 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 446 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
| 447 LOG(ERROR) << "Could not create temporary path."; | 447 LOG(ERROR) << "Could not create temporary path."; |
| 448 } else { | 448 } else { |
| 449 std::wstring setup_patch = cmd_line.GetSwitchValue( | 449 std::wstring setup_patch = cmd_line.GetSwitchValueNative( |
| 450 installer_util::switches::kUpdateSetupExe); | 450 installer_util::switches::kUpdateSetupExe); |
| 451 LOG(INFO) << "Opening archive " << setup_patch; | 451 LOG(INFO) << "Opening archive " << setup_patch; |
| 452 std::wstring uncompressed_patch; | 452 std::wstring uncompressed_patch; |
| 453 if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(), | 453 if (LzmaUtil::UnPackArchive(setup_patch, temp_path.ToWStringHack(), |
| 454 &uncompressed_patch) == NO_ERROR) { | 454 &uncompressed_patch) == NO_ERROR) { |
| 455 std::wstring old_setup_exe = cmd_line.program(); | 455 std::wstring old_setup_exe = cmd_line.program(); |
| 456 std::wstring new_setup_exe = cmd_line.GetSwitchValue( | 456 std::wstring new_setup_exe = cmd_line.GetSwitchValueNative( |
| 457 installer_util::switches::kNewSetupExe); | 457 installer_util::switches::kNewSetupExe); |
| 458 if (!setup_util::ApplyDiffPatch(old_setup_exe, uncompressed_patch, | 458 if (!setup_util::ApplyDiffPatch(old_setup_exe, uncompressed_patch, |
| 459 new_setup_exe)) | 459 new_setup_exe)) |
| 460 status = installer_util::NEW_VERSION_UPDATED; | 460 status = installer_util::NEW_VERSION_UPDATED; |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 | 463 |
| 464 exit_code = dist->GetInstallReturnCode(status); | 464 exit_code = dist->GetInstallReturnCode(status); |
| 465 if (exit_code) { | 465 if (exit_code) { |
| 466 LOG(WARNING) << "setup.exe patching failed."; | 466 LOG(WARNING) << "setup.exe patching failed."; |
| 467 InstallUtil::WriteInstallerResult(system_install, status, | 467 InstallUtil::WriteInstallerResult(system_install, status, |
| 468 IDS_SETUP_PATCH_FAILED_BASE, NULL); | 468 IDS_SETUP_PATCH_FAILED_BASE, NULL); |
| 469 } | 469 } |
| 470 file_util::Delete(temp_path, true); | 470 file_util::Delete(temp_path, true); |
| 471 return true; | 471 return true; |
| 472 } else if (cmd_line.HasSwitch(installer_util::switches::kShowEula)) { | 472 } else if (cmd_line.HasSwitch(installer_util::switches::kShowEula)) { |
| 473 // Check if we need to show the EULA. If it is passed as a command line | 473 // Check if we need to show the EULA. If it is passed as a command line |
| 474 // then the dialog is shown and regardless of the outcome setup exits here. | 474 // then the dialog is shown and regardless of the outcome setup exits here. |
| 475 std::wstring inner_frame = | 475 std::wstring inner_frame = |
| 476 cmd_line.GetSwitchValue(installer_util::switches::kShowEula); | 476 cmd_line.GetSwitchValueNative(installer_util::switches::kShowEula); |
| 477 exit_code = ShowEULADialog(inner_frame); | 477 exit_code = ShowEULADialog(inner_frame); |
| 478 if (installer_util::EULA_REJECTED != exit_code) | 478 if (installer_util::EULA_REJECTED != exit_code) |
| 479 GoogleUpdateSettings::SetEULAConsent(true); | 479 GoogleUpdateSettings::SetEULAConsent(true); |
| 480 return true; | 480 return true; |
| 481 } else if (cmd_line.HasSwitch( | 481 } else if (cmd_line.HasSwitch( |
| 482 installer_util::switches::kRegisterChromeBrowser)) { | 482 installer_util::switches::kRegisterChromeBrowser)) { |
| 483 // If --register-chrome-browser option is specified, register all | 483 // If --register-chrome-browser option is specified, register all |
| 484 // Chrome protocol/file associations as well as register it as a valid | 484 // Chrome protocol/file associations as well as register it as a valid |
| 485 // browser for Start Menu->Internet shortcut. This option should only | 485 // browser for Start Menu->Internet shortcut. This option should only |
| 486 // be used when setup.exe is launched with admin rights. We do not | 486 // be used when setup.exe is launched with admin rights. We do not |
| 487 // make any user specific changes in this option. | 487 // make any user specific changes in this option. |
| 488 std::wstring chrome_exe(cmd_line.GetSwitchValue( | 488 std::wstring chrome_exe(cmd_line.GetSwitchValueNative( |
| 489 installer_util::switches::kRegisterChromeBrowser)); | 489 installer_util::switches::kRegisterChromeBrowser)); |
| 490 std::wstring suffix; | 490 std::wstring suffix; |
| 491 if (cmd_line.HasSwitch( | 491 if (cmd_line.HasSwitch( |
| 492 installer_util::switches::kRegisterChromeBrowserSuffix)) { | 492 installer_util::switches::kRegisterChromeBrowserSuffix)) { |
| 493 suffix = cmd_line.GetSwitchValue( | 493 suffix = cmd_line.GetSwitchValueNative( |
| 494 installer_util::switches::kRegisterChromeBrowserSuffix); | 494 installer_util::switches::kRegisterChromeBrowserSuffix); |
| 495 } | 495 } |
| 496 exit_code = ShellUtil::RegisterChromeBrowser(chrome_exe, suffix, false); | 496 exit_code = ShellUtil::RegisterChromeBrowser(chrome_exe, suffix, false); |
| 497 return true; | 497 return true; |
| 498 } else if (cmd_line.HasSwitch(installer_util::switches::kRenameChromeExe)) { | 498 } else if (cmd_line.HasSwitch(installer_util::switches::kRenameChromeExe)) { |
| 499 // If --rename-chrome-exe is specified, we want to rename the executables | 499 // If --rename-chrome-exe is specified, we want to rename the executables |
| 500 // and exit. | 500 // and exit. |
| 501 exit_code = RenameChromeExecutables(system_install); | 501 exit_code = RenameChromeExecutables(system_install); |
| 502 return true; | 502 return true; |
| 503 } else if (cmd_line.HasSwitch( | 503 } else if (cmd_line.HasSwitch( |
| 504 installer_util::switches::kRemoveChromeRegistration)) { | 504 installer_util::switches::kRemoveChromeRegistration)) { |
| 505 // This is almost reverse of --register-chrome-browser option above. | 505 // This is almost reverse of --register-chrome-browser option above. |
| 506 // Here we delete Chrome browser registration. This option should only | 506 // Here we delete Chrome browser registration. This option should only |
| 507 // be used when setup.exe is launched with admin rights. We do not | 507 // be used when setup.exe is launched with admin rights. We do not |
| 508 // make any user specific changes in this option. | 508 // make any user specific changes in this option. |
| 509 std::wstring suffix; | 509 std::wstring suffix; |
| 510 if (cmd_line.HasSwitch( | 510 if (cmd_line.HasSwitch( |
| 511 installer_util::switches::kRegisterChromeBrowserSuffix)) { | 511 installer_util::switches::kRegisterChromeBrowserSuffix)) { |
| 512 suffix = cmd_line.GetSwitchValue( | 512 suffix = cmd_line.GetSwitchValueNative( |
| 513 installer_util::switches::kRegisterChromeBrowserSuffix); | 513 installer_util::switches::kRegisterChromeBrowserSuffix); |
| 514 } | 514 } |
| 515 installer_util::InstallStatus tmp = installer_util::UNKNOWN_STATUS; | 515 installer_util::InstallStatus tmp = installer_util::UNKNOWN_STATUS; |
| 516 installer_setup::DeleteChromeRegistrationKeys(HKEY_LOCAL_MACHINE, | 516 installer_setup::DeleteChromeRegistrationKeys(HKEY_LOCAL_MACHINE, |
| 517 suffix, tmp); | 517 suffix, tmp); |
| 518 exit_code = tmp; | 518 exit_code = tmp; |
| 519 return true; | 519 return true; |
| 520 } else if (cmd_line.HasSwitch(installer_util::switches::kInactiveUserToast)) { | 520 } else if (cmd_line.HasSwitch(installer_util::switches::kInactiveUserToast)) { |
| 521 // Launch the inactive user toast experiment. | 521 // Launch the inactive user toast experiment. |
| 522 std::wstring flavor = | 522 std::string flavor = cmd_line.GetSwitchValueASCII( |
| 523 cmd_line.GetSwitchValue(installer_util::switches::kInactiveUserToast); | 523 installer_util::switches::kInactiveUserToast); |
| 524 int flavor_int; | 524 int flavor_int; |
| 525 base::StringToInt(flavor, &flavor_int); | 525 base::StringToInt(flavor, &flavor_int); |
| 526 dist->InactiveUserToastExperiment(flavor_int, | 526 dist->InactiveUserToastExperiment(flavor_int, |
| 527 cmd_line.HasSwitch(installer_util::switches::kSystemLevelToast)); | 527 cmd_line.HasSwitch(installer_util::switches::kSystemLevelToast)); |
| 528 return true; | 528 return true; |
| 529 } else if (cmd_line.HasSwitch(installer_util::switches::kSystemLevelToast)) { | 529 } else if (cmd_line.HasSwitch(installer_util::switches::kSystemLevelToast)) { |
| 530 // We started as system-level and have been re-launched as user level | 530 // We started as system-level and have been re-launched as user level |
| 531 // to continue with the toast experiment. | 531 // to continue with the toast experiment. |
| 532 scoped_ptr<installer::Version> | 532 scoped_ptr<installer::Version> |
| 533 installed_version(InstallUtil::GetChromeVersion(system_install)); | 533 installed_version(InstallUtil::GetChromeVersion(system_install)); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { | 739 parsed_command_line.HasSwitch(installer_util::switches::kUninstall))) { |
| 740 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT | 740 // Note that we allow the status installer_util::UNINSTALL_REQUIRES_REBOOT |
| 741 // to pass through, since this is only returned on uninstall which is never | 741 // to pass through, since this is only returned on uninstall which is never |
| 742 // invoked directly by Google Update. | 742 // invoked directly by Google Update. |
| 743 return_code = dist->GetInstallReturnCode(install_status); | 743 return_code = dist->GetInstallReturnCode(install_status); |
| 744 } | 744 } |
| 745 | 745 |
| 746 LOG(INFO) << "Installation complete, returning: " << return_code; | 746 LOG(INFO) << "Installation complete, returning: " << return_code; |
| 747 return return_code; | 747 return return_code; |
| 748 } | 748 } |
| OLD | NEW |