OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <shlobj.h> | 8 #include <shlobj.h> |
9 | 9 |
10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 dist->UpdateDiffInstallStatus(system_install, incremental_install, | 451 dist->UpdateDiffInstallStatus(system_install, incremental_install, |
452 install_status); | 452 install_status); |
453 return install_status; | 453 return install_status; |
454 } | 454 } |
455 | 455 |
456 installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, | 456 installer_util::InstallStatus UninstallChrome(const CommandLine& cmd_line, |
457 const wchar_t* cmd_params, | 457 const wchar_t* cmd_params, |
458 const installer::Version* version, | 458 const installer::Version* version, |
459 bool system_install) { | 459 bool system_install) { |
460 LOG(INFO) << "Uninstalling Chome"; | 460 LOG(INFO) << "Uninstalling Chome"; |
461 if (!version) { | 461 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); |
| 462 if (!version && !force) { |
462 LOG(ERROR) << "No Chrome installation found for uninstall."; | 463 LOG(ERROR) << "No Chrome installation found for uninstall."; |
463 InstallUtil::WriteInstallerResult(system_install, | 464 InstallUtil::WriteInstallerResult(system_install, |
464 installer_util::CHROME_NOT_INSTALLED, | 465 installer_util::CHROME_NOT_INSTALLED, |
465 IDS_UNINSTALL_FAILED_BASE, NULL); | 466 IDS_UNINSTALL_FAILED_BASE, NULL); |
466 return installer_util::CHROME_NOT_INSTALLED; | 467 return installer_util::CHROME_NOT_INSTALLED; |
467 } | 468 } |
468 | 469 |
469 bool remove_all = !cmd_line.HasSwitch( | 470 bool remove_all = !cmd_line.HasSwitch( |
470 installer_util::switches::kDoNotRemoveSharedItems); | 471 installer_util::switches::kDoNotRemoveSharedItems); |
471 bool force = cmd_line.HasSwitch(installer_util::switches::kForceUninstall); | |
472 | |
473 // Check if we need admin rights to cleanup HKLM. Try to elevate - if it works | |
474 // exit from this process, if not just continue uninstalling in the current | |
475 // process itself. | |
476 if (remove_all && | |
477 ShellUtil::AdminNeededForRegistryCleanup() && | |
478 !IsUserAnAdmin() && | |
479 (win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) && | |
480 !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { | |
481 std::wstring exe = cmd_line.program(); | |
482 std::wstring params(cmd_params); | |
483 // Append --run-as-admin flag to let the new instance of setup.exe know | |
484 // that we already tried to launch ourselves as admin. | |
485 params.append(L" --"); | |
486 params.append(installer_util::switches::kRunAsAdmin); | |
487 DWORD exit_code = installer_util::UNKNOWN_STATUS; | |
488 if (InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code)) | |
489 return static_cast<installer_util::InstallStatus>(exit_code); | |
490 } | |
491 | |
492 return installer_setup::UninstallChrome(cmd_line.program(), system_install, | 472 return installer_setup::UninstallChrome(cmd_line.program(), system_install, |
493 *version, remove_all, force); | 473 remove_all, force, |
| 474 cmd_line, cmd_params); |
494 } | 475 } |
495 | 476 |
496 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { | 477 installer_util::InstallStatus ShowEULADialog(const std::wstring& inner_frame) { |
497 LOG(INFO) << "About to show EULA"; | 478 LOG(INFO) << "About to show EULA"; |
498 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); | 479 std::wstring eula_path = installer_util::GetLocalizedEulaResource(); |
499 if (eula_path.empty()) { | 480 if (eula_path.empty()) { |
500 LOG(ERROR) << "No EULA path available"; | 481 LOG(ERROR) << "No EULA path available"; |
501 return installer_util::EULA_REJECTED; | 482 return installer_util::EULA_REJECTED; |
502 } | 483 } |
503 // Newer versions of the caller pass an inner frame parameter that must | 484 // Newer versions of the caller pass an inner frame parameter that must |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 } else { | 604 } else { |
624 install_status = InstallChrome(parsed_command_line, | 605 install_status = InstallChrome(parsed_command_line, |
625 installed_version.get(), | 606 installed_version.get(), |
626 options); | 607 options); |
627 } | 608 } |
628 | 609 |
629 CoUninitialize(); | 610 CoUninitialize(); |
630 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 611 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
631 return dist->GetInstallReturnCode(install_status); | 612 return dist->GetInstallReturnCode(install_status); |
632 } | 613 } |
OLD | NEW |