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 // 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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
216 if (kill) { | 216 if (kill) { |
217 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; | 217 VLOG(1) << installer::kChromeFrameHelperExe << " hung. Killing."; |
218 base::CleanupProcesses(installer::kChromeFrameHelperExe, 0, | 218 base::CleanupProcesses(installer::kChromeFrameHelperExe, 0, |
219 content::RESULT_CODE_HUNG, NULL); | 219 content::RESULT_CODE_HUNG, NULL); |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 // This method tries to figure out if current user has registered Chrome. | |
224 // It returns true iff there is a registered browser that will launch the | |
225 // same chrome.exe as the current installation. | |
226 bool CurrentUserHasDefaultBrowser(const InstallerState& installer_state) { | |
227 using base::win::RegistryKeyIterator; | |
228 const HKEY root = HKEY_LOCAL_MACHINE; | |
229 ProgramCompare open_command_pred( | |
230 installer_state.target_path().Append(kChromeExe)); | |
231 string16 client_open_path; | |
232 RegKey client_open_key; | |
233 string16 reg_exe; | |
234 for (RegistryKeyIterator iter(root, ShellUtil::kRegStartMenuInternet); | |
235 iter.Valid(); ++iter) { | |
236 client_open_path.assign(ShellUtil::kRegStartMenuInternet) | |
237 .append(1, L'\\') | |
238 .append(iter.Name()) | |
239 .append(ShellUtil::kRegShellOpen); | |
240 if (client_open_key.Open(root, client_open_path.c_str(), | |
241 KEY_QUERY_VALUE) == ERROR_SUCCESS && | |
242 client_open_key.ReadValue(L"", ®_exe) == ERROR_SUCCESS && | |
243 open_command_pred.Evaluate(reg_exe)) { | |
244 return true; | |
245 } | |
246 } | |
247 return false; | |
248 } | |
249 | |
250 // This method deletes Chrome shortcut folder from Windows Start menu. It | 223 // This method deletes Chrome shortcut folder from Windows Start menu. It |
251 // checks system_uninstall to see if the shortcut is in all users start menu | 224 // checks system_uninstall to see if the shortcut is in all users start menu |
252 // or current user start menu. | 225 // or current user start menu. |
253 // We try to remove the standard desktop shortcut but if that fails we try | 226 // We try to remove the standard desktop shortcut but if that fails we try |
254 // to remove the alternate desktop shortcut. Only one of them should be | 227 // to remove the alternate desktop shortcut. Only one of them should be |
255 // present in a given install but at this point we don't know which one. | 228 // present in a given install but at this point we don't know which one. |
256 void DeleteChromeShortcuts(const InstallerState& installer_state, | 229 void DeleteChromeShortcuts(const InstallerState& installer_state, |
257 const Product& product) { | 230 const Product& product) { |
258 if (!product.is_chrome()) { | 231 if (!product.is_chrome()) { |
259 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; | 232 VLOG(1) << __FUNCTION__ " called for non-CHROME distribution"; |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 | 644 |
672 #if defined(GOOGLE_CHROME_BUILD) | 645 #if defined(GOOGLE_CHROME_BUILD) |
673 const wchar_t kChromeExtProgId[] = L"ChromeExt"; | 646 const wchar_t kChromeExtProgId[] = L"ChromeExt"; |
674 #else | 647 #else |
675 const wchar_t kChromeExtProgId[] = L"ChromiumExt"; | 648 const wchar_t kChromeExtProgId[] = L"ChromiumExt"; |
676 #endif | 649 #endif |
677 | 650 |
678 HKEY roots[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; | 651 HKEY roots[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; |
679 for (size_t i = 0; i < arraysize(roots); ++i) { | 652 for (size_t i = 0; i < arraysize(roots); ++i) { |
680 string16 suffix; | 653 string16 suffix; |
681 if (roots[i] == HKEY_LOCAL_MACHINE && | 654 if (roots[i] == HKEY_LOCAL_MACHINE) |
682 !ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix)) | 655 suffix = ShellUtil::GetCurrentInstallationSuffix(); |
683 suffix = L""; | |
684 | 656 |
685 // Delete Software\Classes\ChromeExt, | 657 // Delete Software\Classes\ChromeExt, |
686 string16 ext_prog_id(ShellUtil::kRegClasses); | 658 string16 ext_prog_id(ShellUtil::kRegClasses); |
687 ext_prog_id.push_back(FilePath::kSeparators[0]); | 659 ext_prog_id.push_back(FilePath::kSeparators[0]); |
688 ext_prog_id.append(kChromeExtProgId); | 660 ext_prog_id.append(kChromeExtProgId); |
689 ext_prog_id.append(suffix); | 661 ext_prog_id.append(suffix); |
690 InstallUtil::DeleteRegistryKey(roots[i], ext_prog_id); | 662 InstallUtil::DeleteRegistryKey(roots[i], ext_prog_id); |
691 | 663 |
692 // Delete Software\Classes\.crx, | 664 // Delete Software\Classes\.crx, |
693 string16 ext_association(ShellUtil::kRegClasses); | 665 string16 ext_association(ShellUtil::kRegClasses); |
(...skipping 29 matching lines...) Expand all Loading... |
723 } | 695 } |
724 | 696 |
725 InstallStatus UninstallProduct(const InstallationState& original_state, | 697 InstallStatus UninstallProduct(const InstallationState& original_state, |
726 const InstallerState& installer_state, | 698 const InstallerState& installer_state, |
727 const FilePath& setup_path, | 699 const FilePath& setup_path, |
728 const Product& product, | 700 const Product& product, |
729 bool remove_all, | 701 bool remove_all, |
730 bool force_uninstall, | 702 bool force_uninstall, |
731 const CommandLine& cmd_line) { | 703 const CommandLine& cmd_line) { |
732 InstallStatus status = installer::UNINSTALL_CONFIRMED; | 704 InstallStatus status = installer::UNINSTALL_CONFIRMED; |
733 string16 suffix; | 705 BrowserDistribution* browser_dist = product.distribution(); |
734 if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(product.distribution(), | 706 const string16 chrome_exe( |
735 &suffix)) | 707 installer_state.target_path().Append(installer::kChromeExe).value()); |
736 suffix = L""; | |
737 | 708 |
738 BrowserDistribution* browser_dist = product.distribution(); | 709 const string16 suffix(ShellUtil::GetCurrentInstallationSuffix()); |
| 710 |
739 bool is_chrome = product.is_chrome(); | 711 bool is_chrome = product.is_chrome(); |
740 | 712 |
741 VLOG(1) << "UninstallProduct: " << browser_dist->GetApplicationName(); | 713 VLOG(1) << "UninstallProduct: " << browser_dist->GetApplicationName(); |
742 | 714 |
743 if (force_uninstall) { | 715 if (force_uninstall) { |
744 // Since --force-uninstall command line option is used, we are going to | 716 // Since --force-uninstall command line option is used, we are going to |
745 // do silent uninstall. Try to close all running Chrome instances. | 717 // do silent uninstall. Try to close all running Chrome instances. |
746 // NOTE: We don't do this for Chrome Frame. | 718 // NOTE: We don't do this for Chrome Frame. |
747 if (is_chrome) | 719 if (is_chrome) |
748 CloseAllChromeProcesses(); | 720 CloseAllChromeProcesses(); |
749 } else if (is_chrome) { | 721 } else if (is_chrome) { |
750 // no --force-uninstall so lets show some UI dialog boxes. | 722 // no --force-uninstall so lets show some UI dialog boxes. |
751 status = IsChromeActiveOrUserCancelled(installer_state, product); | 723 status = IsChromeActiveOrUserCancelled(installer_state, product); |
752 if (status != installer::UNINSTALL_CONFIRMED && | 724 if (status != installer::UNINSTALL_CONFIRMED && |
753 status != installer::UNINSTALL_DELETE_PROFILE) | 725 status != installer::UNINSTALL_DELETE_PROFILE) |
754 return status; | 726 return status; |
755 | 727 |
756 // Check if we need admin rights to cleanup HKLM. If we do, try to launch | 728 // Check if we need admin rights to cleanup HKLM. If we do, try to launch |
757 // another uninstaller (silent) in elevated mode to do HKLM cleanup. | 729 // another uninstaller (silent) in elevated mode to do HKLM cleanup. |
758 // And continue uninstalling in the current process also to do HKCU cleanup. | 730 // And continue uninstalling in the current process also to do HKCU cleanup. |
759 if (remove_all && | 731 if (ShellUtil::IsInstallationPresentInHKLM(browser_dist, chrome_exe, |
760 (!suffix.empty() || CurrentUserHasDefaultBrowser(installer_state)) && | 732 suffix) && |
| 733 (!suffix.empty() || remove_all) && |
761 !::IsUserAnAdmin() && | 734 !::IsUserAnAdmin() && |
762 base::win::GetVersion() >= base::win::VERSION_VISTA && | 735 base::win::GetVersion() >= base::win::VERSION_VISTA && |
763 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { | 736 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { |
764 CommandLine new_cmd(CommandLine::NO_PROGRAM); | 737 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
765 new_cmd.AppendArguments(cmd_line, true); | 738 new_cmd.AppendArguments(cmd_line, true); |
766 // Append --run-as-admin flag to let the new instance of setup.exe know | 739 // Append --run-as-admin flag to let the new instance of setup.exe know |
767 // that we already tried to launch ourselves as admin. | 740 // that we already tried to launch ourselves as admin. |
768 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); | 741 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); |
769 // Append --remove-chrome-registration to remove registry keys only. | 742 // Append --remove-chrome-registration to remove registry keys only. |
770 new_cmd.AppendSwitch(installer::switches::kRemoveChromeRegistration); | 743 new_cmd.AppendSwitch(installer::switches::kRemoveChromeRegistration); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // Also try to delete the MSI value in the ClientState key (it might not be | 777 // Also try to delete the MSI value in the ClientState key (it might not be |
805 // there). This is due to a Google Update behaviour where an uninstall and a | 778 // there). This is due to a Google Update behaviour where an uninstall and a |
806 // rapid reinstall might result in stale values from the old ClientState key | 779 // rapid reinstall might result in stale values from the old ClientState key |
807 // being picked up on reinstall. | 780 // being picked up on reinstall. |
808 product.SetMsiMarker(installer_state.system_install(), false); | 781 product.SetMsiMarker(installer_state.system_install(), false); |
809 | 782 |
810 // Remove all Chrome registration keys. | 783 // Remove all Chrome registration keys. |
811 // Registration data is put in HKCU for both system level and user level | 784 // Registration data is put in HKCU for both system level and user level |
812 // installs. | 785 // installs. |
813 InstallStatus ret = installer::UNKNOWN_STATUS; | 786 InstallStatus ret = installer::UNKNOWN_STATUS; |
814 DeleteChromeRegistrationKeys(product.distribution(), HKEY_CURRENT_USER, | 787 DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, suffix, |
815 suffix, installer_state.target_path(), &ret); | 788 installer_state.target_path(), &ret); |
| 789 |
| 790 // If the user's Chrome is registered with a suffix: it is possible that old |
| 791 // unsuffixed registrations were left in HKCU (e.g. if this install was |
| 792 // previously installed with no suffix in HKCU (old suffix rules) and later |
| 793 // had to be suffixed when fully registered in HKLM). |
| 794 // Remove remaining HKCU entries with no suffix if any. |
| 795 if (!suffix.empty()) { |
| 796 DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, L"", |
| 797 installer_state.target_path(), &ret); |
| 798 } |
816 | 799 |
817 // Chrome is registered in HKLM for all system-level installs and for | 800 // Chrome is registered in HKLM for all system-level installs and for |
818 // user-level installs for which Chrome has been made the default browser. | 801 // user-level installs for which Chrome has been made the default browser. |
819 // Always remove the HKLM registration for system-level installs. For | 802 // Always remove the HKLM registration for system-level installs. For |
820 // user-level installs, only remove it if both: 1) this uninstall isn't a | 803 // user-level installs, only remove it if either: 1) The registration has a |
821 // self-destruct following the installation of system-level Chrome (because | 804 // suffix, or 2) |remove_all| is true which means this is not a self-destruct |
822 // the system-level Chrome owns the HKLM registration now), and 2) this user | 805 // following a system-level Chrome install (which would otherwise need the |
823 // had made Chrome their default browser. | 806 // same HKLM registrations). |
824 if (installer_state.system_install() || | 807 if (installer_state.system_install() || !suffix.empty() || remove_all) { |
825 (remove_all && | 808 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, |
826 (!suffix.empty() || CurrentUserHasDefaultBrowser(installer_state)))) { | 809 installer_state.target_path(), &ret); |
827 DeleteChromeRegistrationKeys(product.distribution(), HKEY_LOCAL_MACHINE, | |
828 suffix, installer_state.target_path(), &ret); | |
829 } | 810 } |
830 | 811 |
831 ProcessDelegateExecuteWorkItems(installer_state, product); | 812 ProcessDelegateExecuteWorkItems(installer_state, product); |
832 | 813 |
833 if (!is_chrome) { | 814 if (!is_chrome) { |
834 ProcessChromeFrameWorkItems(original_state, installer_state, setup_path, | 815 ProcessChromeFrameWorkItems(original_state, installer_state, setup_path, |
835 product); | 816 product); |
836 } | 817 } |
837 | 818 |
838 if (installer_state.is_multi_install()) | 819 if (installer_state.is_multi_install()) |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 | 933 |
953 // Try and delete the preserved local state once the post-install | 934 // Try and delete the preserved local state once the post-install |
954 // operations are complete. | 935 // operations are complete. |
955 if (!backup_state_file.empty()) | 936 if (!backup_state_file.empty()) |
956 file_util::Delete(backup_state_file, false); | 937 file_util::Delete(backup_state_file, false); |
957 | 938 |
958 return ret; | 939 return ret; |
959 } | 940 } |
960 | 941 |
961 } // namespace installer | 942 } // namespace installer |
OLD | NEW |