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 // This file defines the methods useful for uninstalling Chrome. | 5 // This file defines the methods useful for uninstalling Chrome. |
6 | 6 |
7 #include "chrome/installer/setup/uninstall.h" | 7 #include "chrome/installer/setup/uninstall.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 std::wstring ext_association(ShellUtil::kRegClasses); | 463 std::wstring ext_association(ShellUtil::kRegClasses); |
464 ext_association.append(L"\\"); | 464 ext_association.append(L"\\"); |
465 ext_association.append(chrome::kExtensionFileExtension); | 465 ext_association.append(chrome::kExtensionFileExtension); |
466 InstallUtil::DeleteRegistryKey(key, ext_association); | 466 InstallUtil::DeleteRegistryKey(key, ext_association); |
467 } | 467 } |
468 } | 468 } |
469 | 469 |
470 installer_util::InstallStatus installer_setup::UninstallChrome( | 470 installer_util::InstallStatus installer_setup::UninstallChrome( |
471 const std::wstring& exe_path, bool system_uninstall, | 471 const std::wstring& exe_path, bool system_uninstall, |
472 bool remove_all, bool force_uninstall, | 472 bool remove_all, bool force_uninstall, |
473 const CommandLine& cmd_line) { | 473 const CommandLine& cmd_line, const wchar_t* cmd_params) { |
474 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; | 474 installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED; |
475 std::wstring suffix; | 475 std::wstring suffix; |
476 if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix)) | 476 if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix)) |
477 suffix = L""; | 477 suffix = L""; |
478 | 478 |
479 if (force_uninstall) { | 479 if (force_uninstall) { |
480 // Since --force-uninstall command line option is used, we are going to | 480 // Since --force-uninstall command line option is used, we are going to |
481 // do silent uninstall. Try to close all running Chrome instances. | 481 // do silent uninstall. Try to close all running Chrome instances. |
482 if (!InstallUtil::IsChromeFrameProcess()) | 482 if (!InstallUtil::IsChromeFrameProcess()) |
483 CloseAllChromeProcesses(); | 483 CloseAllChromeProcesses(); |
484 } else if (!InstallUtil::IsChromeFrameProcess()) { | 484 } else if (!InstallUtil::IsChromeFrameProcess()) { |
485 // no --force-uninstall so lets show some UI dialog boxes. | 485 // no --force-uninstall so lets show some UI dialog boxes. |
486 status = IsChromeActiveOrUserCancelled(system_uninstall); | 486 status = IsChromeActiveOrUserCancelled(system_uninstall); |
487 if (status != installer_util::UNINSTALL_CONFIRMED && | 487 if (status != installer_util::UNINSTALL_CONFIRMED && |
488 status != installer_util::UNINSTALL_DELETE_PROFILE) | 488 status != installer_util::UNINSTALL_DELETE_PROFILE) |
489 return status; | 489 return status; |
490 | 490 |
491 // Check if we need admin rights to cleanup HKLM. If we do, try to launch | 491 // Check if we need admin rights to cleanup HKLM. If we do, try to launch |
492 // another uninstaller (silent) in elevated mode to do HKLM cleanup. | 492 // another uninstaller (silent) in elevated mode to do HKLM cleanup. |
493 // And continue uninstalling in the current process also to do HKCU cleanup. | 493 // And continue uninstalling in the current process also to do HKCU cleanup. |
494 if (remove_all && | 494 if (remove_all && |
495 (!suffix.empty() || CurrentUserHasDefaultBrowser(system_uninstall)) && | 495 (!suffix.empty() || CurrentUserHasDefaultBrowser(system_uninstall)) && |
496 !::IsUserAnAdmin() && | 496 !::IsUserAnAdmin() && |
497 (base::win::GetVersion() >= base::win::VERSION_VISTA) && | 497 (base::win::GetVersion() >= base::win::VERSION_VISTA) && |
498 !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { | 498 !cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) { |
499 CommandLine new_cmd(CommandLine::NO_PROGRAM); | 499 std::wstring exe = cmd_line.GetProgram().value(); |
500 new_cmd.AppendArguments(cmd_line, true); | 500 std::wstring params(cmd_params); |
501 // Append --run-as-admin flag to let the new instance of setup.exe know | 501 // Append --run-as-admin flag to let the new instance of setup.exe know |
502 // that we already tried to launch ourselves as admin. | 502 // that we already tried to launch ourselves as admin. |
503 new_cmd.AppendSwitch(installer_util::switches::kRunAsAdmin); | 503 params.append(L" --"); |
| 504 params.append(installer_util::switches::kRunAsAdmin); |
504 // Append --remove-chrome-registration to remove registry keys only. | 505 // Append --remove-chrome-registration to remove registry keys only. |
505 new_cmd.AppendSwitch(installer_util::switches::kRemoveChromeRegistration); | 506 params.append(L" --"); |
| 507 params.append(installer_util::switches::kRemoveChromeRegistration); |
506 if (!suffix.empty()) { | 508 if (!suffix.empty()) { |
507 new_cmd.AppendSwitchNative( | 509 params.append(L" --"); |
508 installer_util::switches::kRegisterChromeBrowserSuffix, suffix); | 510 params.append(ASCIIToWide( |
| 511 installer_util::switches::kRegisterChromeBrowserSuffix)); |
| 512 params.append(L"=\"" + suffix + L"\""); |
509 } | 513 } |
510 DWORD exit_code = installer_util::UNKNOWN_STATUS; | 514 DWORD exit_code = installer_util::UNKNOWN_STATUS; |
511 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 515 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); |
512 } | 516 } |
513 } | 517 } |
514 | 518 |
515 // Get the version of installed Chrome (if any) | 519 // Get the version of installed Chrome (if any) |
516 scoped_ptr<installer::Version> | 520 scoped_ptr<installer::Version> |
517 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); | 521 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); |
518 | 522 |
519 // Chrome is not in use so lets uninstall Chrome by deleting various files | 523 // Chrome is not in use so lets uninstall Chrome by deleting various files |
520 // and registry entries. Here we will just make best effort and keep going | 524 // and registry entries. Here we will just make best effort and keep going |
521 // in case of errors. | 525 // in case of errors. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 distribution_data); | 616 distribution_data); |
613 } | 617 } |
614 | 618 |
615 // Try and delete the preserved local state once the post-install | 619 // Try and delete the preserved local state once the post-install |
616 // operations are complete. | 620 // operations are complete. |
617 if (!local_state_path.empty()) | 621 if (!local_state_path.empty()) |
618 file_util::Delete(local_state_path, false); | 622 file_util::Delete(local_state_path, false); |
619 | 623 |
620 return ret; | 624 return ret; |
621 } | 625 } |
OLD | NEW |