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

Unified Diff: chrome/installer/setup/uninstall.cc

Issue 10451074: Always suffix ChromeHTML entries on Windows for user-level installs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 8 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/uninstall.cc
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 8a56753df03ec07fe1b2f9ee2b29da593cfa85bb..e7f55523849e347a159bdabac7e1376880d371fb 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -220,33 +220,6 @@ void CloseChromeFrameHelperProcess() {
}
}
-// This method tries to figure out if current user has registered Chrome.
-// It returns true iff there is a registered browser that will launch the
-// same chrome.exe as the current installation.
-bool CurrentUserHasDefaultBrowser(const InstallerState& installer_state) {
- using base::win::RegistryKeyIterator;
- const HKEY root = HKEY_LOCAL_MACHINE;
- InstallUtil::ProgramCompare open_command_pred(
- installer_state.target_path().Append(kChromeExe));
- string16 client_open_path;
- RegKey client_open_key;
- string16 reg_exe;
- for (RegistryKeyIterator iter(root, ShellUtil::kRegStartMenuInternet);
- iter.Valid(); ++iter) {
- client_open_path.assign(ShellUtil::kRegStartMenuInternet)
- .append(1, L'\\')
- .append(iter.Name())
- .append(ShellUtil::kRegShellOpen);
- if (client_open_key.Open(root, client_open_path.c_str(),
- KEY_QUERY_VALUE) == ERROR_SUCCESS &&
- client_open_key.ReadValue(L"", &reg_exe) == ERROR_SUCCESS &&
- open_command_pred.Evaluate(reg_exe)) {
- return true;
- }
- }
- return false;
-}
-
// This method deletes Chrome shortcut folder from Windows Start menu. It
// checks system_uninstall to see if the shortcut is in all users start menu
// or current user start menu.
@@ -678,9 +651,8 @@ const wchar_t kChromeExtProgId[] = L"ChromiumExt";
HKEY roots[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
for (size_t i = 0; i < arraysize(roots); ++i) {
string16 suffix;
- if (roots[i] == HKEY_LOCAL_MACHINE &&
- !ShellUtil::GetUserSpecificDefaultBrowserSuffix(dist, &suffix))
- suffix = L"";
+ if (roots[i] == HKEY_LOCAL_MACHINE)
+ suffix = ShellUtil::GetCurrentInstallationSuffix();
// Delete Software\Classes\ChromeExt,
string16 ext_prog_id(ShellUtil::kRegClasses);
@@ -730,12 +702,12 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
bool force_uninstall,
const CommandLine& cmd_line) {
InstallStatus status = installer::UNINSTALL_CONFIRMED;
- string16 suffix;
- if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(product.distribution(),
- &suffix))
- suffix = L"";
-
BrowserDistribution* browser_dist = product.distribution();
+ const string16 chrome_exe(
+ installer_state.target_path().Append(installer::kChromeExe).value());
+
+ const string16 suffix(ShellUtil::GetCurrentInstallationSuffix());
+
bool is_chrome = product.is_chrome();
VLOG(1) << "UninstallProduct: " << browser_dist->GetApplicationName();
@@ -756,8 +728,9 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
// Check if we need admin rights to cleanup HKLM. If we do, try to launch
// another uninstaller (silent) in elevated mode to do HKLM cleanup.
// And continue uninstalling in the current process also to do HKCU cleanup.
- if (remove_all &&
- (!suffix.empty() || CurrentUserHasDefaultBrowser(installer_state)) &&
+ if (ShellUtil::IsInstallationPresentInHKLM(browser_dist, chrome_exe,
grt (UTC plus 2) 2012/06/04 02:18:26 See comment on line 808 below.
gab 2012/06/05 19:50:02 Done.
+ suffix) &&
+ (!suffix.empty() || remove_all) &&
!::IsUserAnAdmin() &&
base::win::GetVersion() >= base::win::VERSION_VISTA &&
!cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) {
@@ -811,21 +784,33 @@ InstallStatus UninstallProduct(const InstallationState& original_state,
// Registration data is put in HKCU for both system level and user level
// installs.
InstallStatus ret = installer::UNKNOWN_STATUS;
- DeleteChromeRegistrationKeys(product.distribution(), HKEY_CURRENT_USER,
- suffix, installer_state.target_path(), &ret);
+ DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, suffix,
+ installer_state.target_path(), &ret);
+
+ // If the user's Chrome is registered with a suffix: it is possible that old
+ // unsuffixed registrations were left in HKCU (e.g. if this install was
+ // previously installed with no suffix in HKCU (old suffix rules) and later
+ // had to be suffixed when fully registered in HKLM).
+ // Remove remaining HKCU entries with no suffix if any.
+ if (!suffix.empty()) {
+ DeleteChromeRegistrationKeys(browser_dist, HKEY_CURRENT_USER, L"",
+ installer_state.target_path(), &ret);
+ }
// Chrome is registered in HKLM for all system-level installs and for
// user-level installs for which Chrome has been made the default browser.
// Always remove the HKLM registration for system-level installs. For
- // user-level installs, only remove it if both: 1) this uninstall isn't a
- // self-destruct following the installation of system-level Chrome (because
- // the system-level Chrome owns the HKLM registration now), and 2) this user
- // had made Chrome their default browser.
- if (installer_state.system_install() ||
+ // user-level installs, only remove it if either: 1) The registration has a
+ // suffix, or 2) |remove_all| is true which means this is not a self-destruct
+ // following a system-level Chrome install (which would otherwise need the
+ // same HKLM registrations) and the current user is in fact the owner of the
+ // unsuffixed system install.
+ if (installer_state.system_install() || !suffix.empty() ||
grt (UTC plus 2) 2012/06/04 02:18:26 I think you should revert the logic here. If I'm
gab 2012/06/05 19:50:02 Done, I made QuickIsChromeRegistered() work for th
(remove_all &&
- (!suffix.empty() || CurrentUserHasDefaultBrowser(installer_state)))) {
gab 2012/06/05 19:50:02 This line of logic is essentially saying IsUserReg
- DeleteChromeRegistrationKeys(product.distribution(), HKEY_LOCAL_MACHINE,
- suffix, installer_state.target_path(), &ret);
+ ShellUtil::CurrentUserIsRegisteredWithNoSuffix(
+ browser_dist, chrome_exe))) {
+ DeleteChromeRegistrationKeys(browser_dist, HKEY_LOCAL_MACHINE, suffix,
+ installer_state.target_path(), &ret);
}
ProcessDelegateExecuteWorkItems(installer_state, product);

Powered by Google App Engine
This is Rietveld 408576698