| 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, const wchar_t* cmd_params) { | 473 const CommandLine& cmd_line) { |
| 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 std::wstring exe = cmd_line.GetProgram().value(); | 499 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
| 500 std::wstring params(cmd_params); | 500 new_cmd.AppendArguments(cmd_line, true); |
| 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 params.append(L" --"); | 503 new_cmd.AppendSwitch(installer_util::switches::kRunAsAdmin); |
| 504 params.append(installer_util::switches::kRunAsAdmin); | |
| 505 // Append --remove-chrome-registration to remove registry keys only. | 504 // Append --remove-chrome-registration to remove registry keys only. |
| 506 params.append(L" --"); | 505 new_cmd.AppendSwitch(installer_util::switches::kRemoveChromeRegistration); |
| 507 params.append(installer_util::switches::kRemoveChromeRegistration); | |
| 508 if (!suffix.empty()) { | 506 if (!suffix.empty()) { |
| 509 params.append(L" --"); | 507 new_cmd.AppendSwitchNative( |
| 510 params.append(ASCIIToWide( | 508 installer_util::switches::kRegisterChromeBrowserSuffix, suffix); |
| 511 installer_util::switches::kRegisterChromeBrowserSuffix)); | |
| 512 params.append(L"=\"" + suffix + L"\""); | |
| 513 } | 509 } |
| 514 DWORD exit_code = installer_util::UNKNOWN_STATUS; | 510 DWORD exit_code = installer_util::UNKNOWN_STATUS; |
| 515 InstallUtil::ExecuteExeAsAdmin(exe, params, &exit_code); | 511 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
| 516 } | 512 } |
| 517 } | 513 } |
| 518 | 514 |
| 519 // Get the version of installed Chrome (if any) | 515 // Get the version of installed Chrome (if any) |
| 520 scoped_ptr<installer::Version> | 516 scoped_ptr<installer::Version> |
| 521 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); | 517 installed_version(InstallUtil::GetChromeVersion(system_uninstall)); |
| 522 | 518 |
| 523 // Chrome is not in use so lets uninstall Chrome by deleting various files | 519 // Chrome is not in use so lets uninstall Chrome by deleting various files |
| 524 // and registry entries. Here we will just make best effort and keep going | 520 // and registry entries. Here we will just make best effort and keep going |
| 525 // in case of errors. | 521 // in case of errors. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 distribution_data); | 612 distribution_data); |
| 617 } | 613 } |
| 618 | 614 |
| 619 // Try and delete the preserved local state once the post-install | 615 // Try and delete the preserved local state once the post-install |
| 620 // operations are complete. | 616 // operations are complete. |
| 621 if (!local_state_path.empty()) | 617 if (!local_state_path.empty()) |
| 622 file_util::Delete(local_state_path, false); | 618 file_util::Delete(local_state_path, false); |
| 623 | 619 |
| 624 return ret; | 620 return ret; |
| 625 } | 621 } |
| OLD | NEW |