Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(756)

Side by Side Diff: chrome/installer/setup/uninstall.cc

Issue 10946030: Remove Chrome's ProgID from filetype associations at uninstall. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: don't disrupt system-level registration Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <windows.h> 9 #include <windows.h>
10 10
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 should_delete = true; 610 should_delete = true;
611 } else { 611 } else {
612 should_delete = 612 should_delete =
613 status == installer::UNINSTALL_DELETE_PROFILE || 613 status == installer::UNINSTALL_DELETE_PROFILE ||
614 cmd_line.HasSwitch(installer::switches::kDeleteProfile); 614 cmd_line.HasSwitch(installer::switches::kDeleteProfile);
615 } 615 }
616 616
617 return should_delete; 617 return should_delete;
618 } 618 }
619 619
620 bool DeleteChromeRegistrationKeys(BrowserDistribution* dist, HKEY root, 620 bool DeleteChromeRegistrationKeys(const InstallerState& installer_state,
621 BrowserDistribution* dist, HKEY root,
gab 2012/09/19 19:58:50 nit: move "HKEY root" to its own line here too.
grt (UTC plus 2) 2012/09/19 20:04:52 Indeed! Done.
621 const string16& browser_entry_suffix, 622 const string16& browser_entry_suffix,
622 const FilePath& target_path,
623 InstallStatus* exit_code) { 623 InstallStatus* exit_code) {
624 DCHECK(exit_code); 624 DCHECK(exit_code);
625 if (!dist->CanSetAsDefault()) { 625 if (!dist->CanSetAsDefault()) {
626 // We should have never set those keys. 626 // We should have never set those keys.
627 return true; 627 return true;
628 } 628 }
629 629
630 const FilePath &target_path(installer_state.target_path());
gab 2012/09/19 19:58:50 |target_path| is only used once, consider inlining
grt (UTC plus 2) 2012/09/19 20:04:52 Done.
630 FilePath chrome_exe(target_path.Append(kChromeExe)); 631 FilePath chrome_exe(target_path.Append(kChromeExe));
631 632
632 // Delete Software\Classes\ChromeHTML. 633 // Delete Software\Classes\ChromeHTML.
633 // For user-level installs we now only write these entries in HKCU, but since 634 // For user-level installs we now only write these entries in HKCU, but since
634 // old installs did install them to HKLM we will try to remove them in HKLM as 635 // old installs did install them to HKLM we will try to remove them in HKLM as
635 // well anyways. 636 // well anyways.
636 const string16 prog_id(ShellUtil::kChromeHTMLProgId + browser_entry_suffix); 637 const string16 prog_id(ShellUtil::kChromeHTMLProgId + browser_entry_suffix);
637 string16 reg_prog_id(ShellUtil::kRegClasses); 638 string16 reg_prog_id(ShellUtil::kRegClasses);
638 reg_prog_id.push_back(FilePath::kSeparators[0]); 639 reg_prog_id.push_back(FilePath::kSeparators[0]);
639 reg_prog_id.append(prog_id); 640 reg_prog_id.append(prog_id);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 // references this Chrome. Do this explicitly here for the case where HKCU is 729 // references this Chrome. Do this explicitly here for the case where HKCU is
729 // being processed; the iteration above will have no hits since registration 730 // being processed; the iteration above will have no hits since registration
730 // lives in HKLM. 731 // lives in HKLM.
731 InstallUtil::DeleteRegistryValueIf( 732 InstallUtil::DeleteRegistryValueIf(
732 root, ShellUtil::kRegStartMenuInternet, L"", 733 root, ShellUtil::kRegStartMenuInternet, L"",
733 InstallUtil::ValueEquals(dist->GetBaseAppName() + browser_entry_suffix)); 734 InstallUtil::ValueEquals(dist->GetBaseAppName() + browser_entry_suffix));
734 735
735 // Delete each protocol association if it references this Chrome. 736 // Delete each protocol association if it references this Chrome.
736 InstallUtil::ProgramCompare open_command_pred(chrome_exe); 737 InstallUtil::ProgramCompare open_command_pred(chrome_exe);
737 string16 parent_key(ShellUtil::kRegClasses); 738 string16 parent_key(ShellUtil::kRegClasses);
739 parent_key.push_back(FilePath::kSeparators[0]);
738 const string16::size_type base_length = parent_key.size(); 740 const string16::size_type base_length = parent_key.size();
739 string16 child_key; 741 string16 child_key;
740 for (const wchar_t* const* proto = 742 for (const wchar_t* const* proto =
741 &ShellUtil::kPotentialProtocolAssociations[0]; 743 &ShellUtil::kPotentialProtocolAssociations[0];
742 *proto != NULL; 744 *proto != NULL;
743 ++proto) { 745 ++proto) {
744 parent_key.resize(base_length); 746 parent_key.resize(base_length);
745 parent_key.push_back(FilePath::kSeparators[0]);
746 parent_key.append(*proto); 747 parent_key.append(*proto);
747 child_key.assign(parent_key).append(ShellUtil::kRegShellOpen); 748 child_key.assign(parent_key).append(ShellUtil::kRegShellOpen);
748 InstallUtil::DeleteRegistryKeyIf(root, parent_key, child_key, L"", 749 InstallUtil::DeleteRegistryKeyIf(root, parent_key, child_key, L"",
749 open_command_pred); 750 open_command_pred);
750 } 751 }
751 752
753 // Delete each filetype association if it references this Chrome. Take care
754 // not to delete the association if it references a system-level install of
755 // Chrome (only a risk if the suffix is empty). Don't delete the whole key
756 // since other apps may have stored data there.
757 if (!browser_entry_suffix.empty() ||
758 (installer_state.level() == InstallerState::USER_LEVEL &&
gab 2012/09/19 19:58:50 Why not use "!installer_state.system_install()"? T
grt (UTC plus 2) 2012/09/19 20:04:52 Done.
759 !base::win::RegKey(HKEY_LOCAL_MACHINE, reg_prog_id.c_str(),
760 KEY_QUERY_VALUE).Valid())) {
761 InstallUtil::ValueEquals prog_id_pred(prog_id);
762 for (const wchar_t* const* filetype = &ShellUtil::kFileAssociations[0];
763 *filetype != NULL; ++filetype) {
764 parent_key.resize(base_length);
765 parent_key.append(*filetype);
766 InstallUtil::DeleteRegistryValueIf(root, parent_key.c_str(), L"",
767 prog_id_pred);
768 }
769 }
770
752 // Note that we do not attempt to delete filetype associations since MSDN 771 // Note that we do not attempt to delete filetype associations since MSDN
753 // says "Windows respects the Default value only if the ProgID found there is 772 // says "Windows respects the Default value only if the ProgID found there is
754 // a registered ProgID. If the ProgID is unregistered, it is ignored." 773 // a registered ProgID. If the ProgID is unregistered, it is ignored."
755 774
756 *exit_code = installer::UNINSTALL_SUCCESSFUL; 775 *exit_code = installer::UNINSTALL_SUCCESSFUL;
757 return true; 776 return true;
758 } 777 }
759 778
760 void RemoveChromeLegacyRegistryKeys(BrowserDistribution* dist, 779 void RemoveChromeLegacyRegistryKeys(BrowserDistribution* dist,
761 const string16& chrome_exe) { 780 const string16& chrome_exe) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 // rapid reinstall might result in stale values from the old ClientState key 1050 // rapid reinstall might result in stale values from the old ClientState key
1032 // being picked up on reinstall. 1051 // being picked up on reinstall.
1033 product.SetMsiMarker(installer_state.system_install(), false); 1052 product.SetMsiMarker(installer_state.system_install(), false);
1034 1053
1035 InstallStatus ret = installer::UNKNOWN_STATUS; 1054 InstallStatus ret = installer::UNKNOWN_STATUS;
1036 1055
1037 if (is_chrome) { 1056 if (is_chrome) {
1038 // Remove all Chrome registration keys. 1057 // Remove all Chrome registration keys.
1039 // Registration data is put in HKCU for both system level and user level 1058 // Registration data is put in HKCU for both system level and user level
1040 // installs. 1059 // installs.
1041 DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, suffix, 1060 DeleteChromeRegistrationKeys(installer_state, browser_dist,
1042 installer_state.target_path(), &ret); 1061 HKEY_CURRENT_USER, suffix, &ret);
1043 1062
1044 // If the user's Chrome is registered with a suffix: it is possible that old 1063 // If the user's Chrome is registered with a suffix: it is possible that old
1045 // unsuffixed registrations were left in HKCU (e.g. if this install was 1064 // unsuffixed registrations were left in HKCU (e.g. if this install was
1046 // previously installed with no suffix in HKCU (old suffix rules if the user 1065 // previously installed with no suffix in HKCU (old suffix rules if the user
1047 // is not an admin (or declined UAC at first run)) and later had to be 1066 // is not an admin (or declined UAC at first run)) and later had to be
1048 // suffixed when fully registered in HKLM (e.g. when later making Chrome 1067 // suffixed when fully registered in HKLM (e.g. when later making Chrome
1049 // default through the UI)). 1068 // default through the UI)).
1050 // Remove remaining HKCU entries with no suffix if any. 1069 // Remove remaining HKCU entries with no suffix if any.
1051 if (!suffix.empty()) { 1070 if (!suffix.empty()) {
1052 DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, string16(), 1071 DeleteChromeRegistrationKeys(installer_state, browser_dist,
1053 installer_state.target_path(), &ret); 1072 HKEY_CURRENT_USER, string16(), &ret);
1054 1073
1055 // For similar reasons it is possible in very few installs (from 1074 // For similar reasons it is possible in very few installs (from
1056 // 21.0.1180.0 and fixed shortly after) to be installed with the new-style 1075 // 21.0.1180.0 and fixed shortly after) to be installed with the new-style
1057 // suffix, but have some old-style suffix registrations left behind. 1076 // suffix, but have some old-style suffix registrations left behind.
1058 string16 old_style_suffix; 1077 string16 old_style_suffix;
1059 if (ShellUtil::GetOldUserSpecificRegistrySuffix(&old_style_suffix) && 1078 if (ShellUtil::GetOldUserSpecificRegistrySuffix(&old_style_suffix) &&
1060 suffix != old_style_suffix) { 1079 suffix != old_style_suffix) {
1061 DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, 1080 DeleteChromeRegistrationKeys(installer_state, browser_dist,
1062 old_style_suffix, 1081 HKEY_CURRENT_USER, old_style_suffix, &ret);
1063 installer_state.target_path(), &ret);
1064 } 1082 }
1065 } 1083 }
1066 1084
1067 // Chrome is registered in HKLM for all system-level installs and for 1085 // Chrome is registered in HKLM for all system-level installs and for
1068 // user-level installs for which Chrome has been made the default browser. 1086 // user-level installs for which Chrome has been made the default browser.
1069 // Always remove the HKLM registration for system-level installs. For 1087 // Always remove the HKLM registration for system-level installs. For
1070 // user-level installs, only remove it if both: 1) this uninstall isn't a 1088 // user-level installs, only remove it if both: 1) this uninstall isn't a
1071 // self destruct following the installation of a system-level Chrome 1089 // self destruct following the installation of a system-level Chrome
1072 // (because the system-level Chrome owns the HKLM registration now), and 2) 1090 // (because the system-level Chrome owns the HKLM registration now), and 2)
1073 // this user has made Chrome their default browser (i.e. has shell 1091 // this user has made Chrome their default browser (i.e. has shell
1074 // integration entries registered with |suffix| (note: |suffix| will be the 1092 // integration entries registered with |suffix| (note: |suffix| will be the
1075 // empty string if required as it is obtained by 1093 // empty string if required as it is obtained by
1076 // GetCurrentInstallationSuffix() above)). 1094 // GetCurrentInstallationSuffix() above)).
1077 // TODO(gab): This can still leave parts of a suffixed install behind. To be 1095 // TODO(gab): This can still leave parts of a suffixed install behind. To be
1078 // able to remove them we would need to be able to remove only suffixed 1096 // able to remove them we would need to be able to remove only suffixed
1079 // entries (as it is now some of the registry entries (e.g. App Paths) are 1097 // entries (as it is now some of the registry entries (e.g. App Paths) are
1080 // unsuffixed; thus removing suffixed installs is prohibited in HKLM if 1098 // unsuffixed; thus removing suffixed installs is prohibited in HKLM if
1081 // !|remove_all| for now). 1099 // !|remove_all| for now).
1082 if (installer_state.system_install() || 1100 if (installer_state.system_install() ||
1083 (remove_all && 1101 (remove_all &&
1084 ShellUtil::QuickIsChromeRegisteredInHKLM( 1102 ShellUtil::QuickIsChromeRegisteredInHKLM(
1085 browser_dist, chrome_exe, suffix))) { 1103 browser_dist, chrome_exe, suffix))) {
1086 DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix, 1104 DeleteChromeRegistrationKeys(installer_state, browser_dist,
1087 installer_state.target_path(), &ret); 1105 HKEY_LOCAL_MACHINE, suffix, &ret);
1088 } 1106 }
1089 1107
1090 ProcessDelegateExecuteWorkItems(installer_state, product); 1108 ProcessDelegateExecuteWorkItems(installer_state, product);
1091 1109
1092 ProcessOnOsUpgradeWorkItems(installer_state, product); 1110 ProcessOnOsUpgradeWorkItems(installer_state, product);
1093 1111
1094 // TODO(gab): This is only disabled for M22 as the shortcut CL using Active 1112 // TODO(gab): This is only disabled for M22 as the shortcut CL using Active
1095 // Setup will not make it in M22. 1113 // Setup will not make it in M22.
1096 #if 0 1114 #if 0
1097 UninstallActiveSetupEntries(installer_state, product); 1115 UninstallActiveSetupEntries(installer_state, product);
1098 #endif 1116 #endif
1117
1118 // Notify the shell that associations have changed since Chrome was likely
1119 // unregistered.
1120 SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL);
1099 } 1121 }
1100 1122
1101 if (product.is_chrome_frame()) { 1123 if (product.is_chrome_frame()) {
1102 ProcessChromeFrameWorkItems(original_state, installer_state, setup_path, 1124 ProcessChromeFrameWorkItems(original_state, installer_state, setup_path,
1103 product); 1125 product);
1104 } 1126 }
1105 1127
1106 if (installer_state.is_multi_install()) 1128 if (installer_state.is_multi_install())
1107 ProcessGoogleUpdateItems(original_state, installer_state, product); 1129 ProcessGoogleUpdateItems(original_state, installer_state, product);
1108 1130
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 1227
1206 // Try and delete the preserved local state once the post-install 1228 // Try and delete the preserved local state once the post-install
1207 // operations are complete. 1229 // operations are complete.
1208 if (!backup_state_file.empty()) 1230 if (!backup_state_file.empty())
1209 file_util::Delete(backup_state_file, false); 1231 file_util::Delete(backup_state_file, false);
1210 1232
1211 return ret; 1233 return ret;
1212 } 1234 }
1213 1235
1214 } // namespace installer 1236 } // namespace installer
OLDNEW
« chrome/installer/setup/uninstall.h ('K') | « chrome/installer/setup/uninstall.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698