summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 23:46:21 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-14 23:46:21 +0000
commitb31844be04ffac8e67d5f302c3bad5b28e1dec79 (patch)
tree87a8aec4af7897c5bc5b4c8edba29b604a5ef861
parent4c58b9cfc4a33c252b81b991949891a709f62f99 (diff)
downloadchromium_src-b31844be04ffac8e67d5f302c3bad5b28e1dec79.zip
chromium_src-b31844be04ffac8e67d5f302c3bad5b28e1dec79.tar.gz
chromium_src-b31844be04ffac8e67d5f302c3bad5b28e1dec79.tar.bz2
Do not delete default browser entries for other users when uninstalling it for one user.
BUG=19222 TEST=Install and set Chrome as default for two different users on the same machine. Uninstall for one user and make sure the default browser still works for the second user. Review URL: http://codereview.chromium.org/164454 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23496 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/shell_integration_win.cc20
-rw-r--r--chrome/installer/setup/uninstall.cc54
-rw-r--r--chrome/installer/util/shell_util.cc45
-rw-r--r--chrome/installer/util/shell_util.h6
4 files changed, 66 insertions, 59 deletions
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 6f1957a..040b03c 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -73,20 +73,20 @@ bool ShellIntegration::IsDefaultBrowser() {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
std::wstring app_name = dist->GetApplicationName();
- std::wstring app_name_with_suffix;
- ShellUtil::GetUserSpecificDefaultBrowserSuffix(&app_name_with_suffix);
- app_name_with_suffix = app_name + app_name_with_suffix;
+ // If a user specific default browser entry exists, we check for that
+ // app name being default. If not, then default browser is just called
+ // Google Chrome or Chromium so we do not append suffix to app name.
+ std::wstring suffix;
+ if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
+ app_name += suffix;
+
for (int i = 0; i < _countof(kChromeProtocols); i++) {
BOOL result = TRUE;
hr = pAAR->QueryAppIsDefault(kChromeProtocols[i].c_str(), AT_URLPROTOCOL,
- AL_EFFECTIVE, app_name_with_suffix.c_str(), &result);
+ AL_EFFECTIVE, app_name.c_str(), &result);
if (!SUCCEEDED(hr) || (result == FALSE)) {
- hr = pAAR->QueryAppIsDefault(kChromeProtocols[i].c_str(),
- AT_URLPROTOCOL, AL_EFFECTIVE, app_name.c_str(), &result);
- if (!SUCCEEDED(hr) || (result == FALSE)) {
- pAAR->Release();
- return false;
- }
+ pAAR->Release();
+ return false;
}
}
pAAR->Release();
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 7152f04..460c4a2 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -58,6 +58,29 @@ void CloseAllChromeProcesses() {
ResultCodes::HUNG, NULL);
}
+// This method tries to figure out if current user has registered Chrome.
+// It returns true iff:
+// - Software\Clients\StartMenuInternet\Chromium\"" key has a valid value.
+// - The value is same as chrome.exe path for the current installation.
+bool CurrentUserHasDefaultBrowser(bool system_uninstall) {
+ std::wstring reg_key(ShellUtil::kRegStartMenuInternet);
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ reg_key.append(L"\\" + dist->GetApplicationName() + ShellUtil::kRegShellOpen);
+ RegKey key(HKEY_LOCAL_MACHINE, reg_key.c_str());
+ std::wstring reg_exe;
+ if (key.ReadValue(L"", &reg_exe) && reg_exe.length() > 2) {
+ std::wstring chrome_exe = installer::GetChromeInstallPath(system_uninstall);
+ file_util::AppendToPath(&chrome_exe, installer_util::kChromeExe);
+ reg_exe = reg_exe.substr(1, reg_exe.length() - 2);
+ if ((reg_exe.size() == chrome_exe.size()) &&
+ (std::equal(chrome_exe.begin(), chrome_exe.end(),
+ reg_exe.begin(), CaseInsensitiveCompare<wchar_t>())))
+ 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.
@@ -250,11 +273,13 @@ bool installer_setup::DeleteChromeRegistrationKeys(HKEY root,
// Delete Software\Classes\ChromeHTML,
std::wstring html_prog_id(ShellUtil::kRegClasses);
file_util::AppendToPath(&html_prog_id, ShellUtil::kChromeHTMLProgId);
+ html_prog_id.append(browser_entry_suffix);
DeleteRegistryKey(key, html_prog_id);
// Delete Software\Classes\ChromeExt,
std::wstring ext_prog_id(ShellUtil::kRegClasses);
file_util::AppendToPath(&ext_prog_id, ShellUtil::kChromeExtProgId);
+ ext_prog_id.append(browser_entry_suffix);
DeleteRegistryKey(key, ext_prog_id);
// Delete Software\Classes\.crx,
@@ -267,6 +292,7 @@ bool installer_setup::DeleteChromeRegistrationKeys(HKEY root,
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
std::wstring set_access_key(ShellUtil::kRegStartMenuInternet);
file_util::AppendToPath(&set_access_key, dist->GetApplicationName());
+ set_access_key.append(browser_entry_suffix);
DeleteRegistryKey(key, set_access_key);
// We have renamed the StartMenuInternet\chrome.exe to
@@ -278,22 +304,7 @@ bool installer_setup::DeleteChromeRegistrationKeys(HKEY root,
// Delete Software\RegisteredApplications\Chromium
DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications,
- dist->GetApplicationName());
-
- // Delete Software\Classes\ChromeHTML.<user>
- // Delete Software\Classes\ChromeExt.<user>
- // Delete Software\Clients\StartMenuInternet\Chromium.<user>
- // Delete Software\RegisteredApplications\Chromium.<user>
- if (!browser_entry_suffix.empty()) {
- html_prog_id.append(browser_entry_suffix);
- DeleteRegistryKey(key, html_prog_id);
- ext_prog_id.append(browser_entry_suffix);
- DeleteRegistryKey(key, ext_prog_id);
- set_access_key.append(browser_entry_suffix);
- DeleteRegistryKey(key, set_access_key);
- DeleteRegistryValue(root, ShellUtil::kRegRegisteredApplications,
- dist->GetApplicationName() + browser_entry_suffix);
- }
+ dist->GetApplicationName() + browser_entry_suffix);
// Delete Software\Classes\Applications\chrome.exe
std::wstring app_key(ShellUtil::kRegClasses);
@@ -324,9 +335,11 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
const std::wstring& exe_path, bool system_uninstall,
bool remove_all, bool force_uninstall,
const CommandLine& cmd_line, const wchar_t* cmd_params) {
- std::wstring suffix;
- ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix);
installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED;
+ std::wstring suffix;
+ if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
+ suffix = L"";
+
if (force_uninstall) {
// Since --force-uninstall command line option is used, we are going to
// do silent uninstall. Try to close all running Chrome instances.
@@ -341,7 +354,7 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
// 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 &&
- ShellUtil::AdminNeededForRegistryCleanup() &&
+ (!suffix.empty() || CurrentUserHasDefaultBrowser(system_uninstall)) &&
!::IsUserAnAdmin() &&
(win_util::GetWinVersion() >= win_util::WINVERSION_VISTA) &&
!cmd_line.HasSwitch(installer_util::switches::kRunAsAdmin)) {
@@ -394,7 +407,8 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
// For user level install also we end up creating some keys in HKLM if user
// sets Chrome as default browser. So delete those as well (needs admin).
- if (remove_all && !system_uninstall)
+ if (remove_all && !system_uninstall &&
+ (!suffix.empty() || CurrentUserHasDefaultBrowser(system_uninstall)))
DeleteChromeRegistrationKeys(HKEY_LOCAL_MACHINE, suffix, ret);
// Delete shared registry keys as well (these require admin rights) if
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 10355b6..88674dc 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -347,20 +347,6 @@ bool ElevateAndRegisterChrome(const std::wstring& chrome_exe,
return false;
}
-// This method checks if user specific default browser registry entry exists.
-// (i.e. Software\Clients\StartMenuInternet\Chromium.<user>)
-bool UserSpecificDefaultBrowserEntryExists() {
- std::wstring suffix;
- if (!ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
- return false;
-
- std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet);
- BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- start_menu_entry.append(L"\\" + dist->GetApplicationName() + suffix);
- RegKey key(HKEY_LOCAL_MACHINE, start_menu_entry.c_str());
- return key.Valid();
-}
-
// This method tries to figure out if another user has already registered her
// own copy of Chrome so that we can avoid overwriting it and append current
// user's login name to default browser registry entries. This function is
@@ -451,15 +437,10 @@ const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
const wchar_t* ShellUtil::kChromeExtProgIdDesc = L"Chrome Extension Installer";
-bool ShellUtil::AdminNeededForRegistryCleanup() {
+bool ShellUtil::AdminNeededForRegistryCleanup(const std::wstring& suffix) {
bool cleanup_needed = false;
std::list<RegistryEntry*> entries;
STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries);
- RegistryEntry::GetProgIdEntries(L"chrome.exe", L"", &entries);
- RegistryEntry::GetSystemEntries(L"chrome.exe", L"", &entries);
-
- std::wstring suffix;
- GetUserSpecificDefaultBrowserSuffix(&suffix);
RegistryEntry::GetProgIdEntries(L"chrome.exe", suffix, &entries);
RegistryEntry::GetSystemEntries(L"chrome.exe", suffix, &entries);
for (std::list<RegistryEntry*>::const_iterator itr = entries.begin();
@@ -609,7 +590,12 @@ bool ShellUtil::GetUserSpecificDefaultBrowserSuffix(std::wstring* entry) {
return false;
entry->assign(L".");
entry->append(user_name);
- return true;
+
+ std::wstring start_menu_entry(ShellUtil::kRegStartMenuInternet);
+ BrowserDistribution* dist = BrowserDistribution::GetDistribution();
+ start_menu_entry.append(L"\\" + dist->GetApplicationName() + *entry);
+ RegKey key(HKEY_LOCAL_MACHINE, start_menu_entry.c_str());
+ return key.Valid();
}
bool ShellUtil::MakeChromeDefault(int shell_change,
@@ -628,7 +614,12 @@ bool ShellUtil::MakeChromeDefault(int shell_change,
(void**)&pAAR);
if (SUCCEEDED(hr)) {
BrowserDistribution* dist = BrowserDistribution::GetDistribution();
- hr = pAAR->SetAppAsDefaultAll(dist->GetApplicationName().c_str());
+ std::wstring app_name = dist->GetApplicationName();
+ std::wstring suffix;
+ if (ShellUtil::GetUserSpecificDefaultBrowserSuffix(&suffix))
+ app_name += suffix;
+
+ hr = pAAR->SetAppAsDefaultAll(app_name.c_str());
pAAR->Release();
}
if (!SUCCEEDED(hr)) {
@@ -645,8 +636,8 @@ bool ShellUtil::MakeChromeDefault(int shell_change,
std::list<RegistryEntry*> entries;
STLElementDeleter<std::list<RegistryEntry*>> entries_deleter(&entries);
std::wstring suffix;
- if (UserSpecificDefaultBrowserEntryExists())
- GetUserSpecificDefaultBrowserSuffix(&suffix);
+ if (!GetUserSpecificDefaultBrowserSuffix(&suffix))
+ suffix = L"";
RegistryEntry::GetUserEntries(chrome_exe, suffix, &entries);
// Change the default browser for current user.
if ((shell_change & ShellUtil::CURRENT_USER) &&
@@ -673,9 +664,9 @@ bool ShellUtil::RegisterChromeBrowser(const std::wstring& chrome_exe,
if (!unique_suffix.empty()) {
suffix = unique_suffix;
} else if (InstallUtil::IsPerUserInstall(chrome_exe.c_str()) &&
- (UserSpecificDefaultBrowserEntryExists() ||
- AnotherUserHasDefaultBrowser(chrome_exe))) {
- GetUserSpecificDefaultBrowserSuffix(&suffix);
+ !GetUserSpecificDefaultBrowserSuffix(&suffix) &&
+ !AnotherUserHasDefaultBrowser(chrome_exe)) {
+ suffix = L"";
}
// Check if Chromium is already registered with this suffix.
diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h
index 6eb7390..ca6eac7 100644
--- a/chrome/installer/util/shell_util.h
+++ b/chrome/installer/util/shell_util.h
@@ -78,7 +78,7 @@ class ShellUtil {
// Checks if we need Admin rights for registry cleanup by checking if any
// entry exists in HKLM.
- static bool AdminNeededForRegistryCleanup();
+ static bool AdminNeededForRegistryCleanup(const std::wstring& suffix);
// Create Chrome shortcut on Desktop
// If shell_change is CURRENT_USER, the shortcut is created in the
@@ -143,7 +143,9 @@ class ShellUtil {
// to Chromium default browser entry in the registry to create a unique name
// if there are multiple users on the machine, each with their own copy of
// Chromium that they want to set as default browser.
- // This suffix value is assigned to |entry|.
+ // This suffix value is assigned to |entry|. The function also checks for
+ // existence of Default Browser registry key with this suffix and
+ // returns true if it exists. In all other cases it returns false.
static bool GetUserSpecificDefaultBrowserSuffix(std::wstring* entry);
// Make Chrome default browser.