diff options
author | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 17:37:13 +0000 |
---|---|---|
committer | gab@chromium.org <gab@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-13 17:37:13 +0000 |
commit | a049b24a30811754b47b6f81dbd4e35b54617b70 (patch) | |
tree | 2bc751eaae3f58011c2431e22b556dea3f5fa74e /chrome/installer | |
parent | 9d9b996395a714500eb55da225c16bdc48786bce (diff) | |
download | chromium_src-a049b24a30811754b47b6f81dbd4e35b54617b70.zip chromium_src-a049b24a30811754b47b6f81dbd4e35b54617b70.tar.gz chromium_src-a049b24a30811754b47b6f81dbd4e35b54617b70.tar.bz2 |
Fix all hardcoded Windows registry lookups.
Some of our registry lookups were wrong based on how the "new" (Win7+) Windows operates.
BUG=None
TEST=None
Review URL: https://chromiumcodereview.appspot.com/10535057
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141903 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/util/shell_util.cc | 44 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.h | 8 |
2 files changed, 33 insertions, 19 deletions
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index 9ab3823..7222cd0 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -914,29 +914,39 @@ bool ShellUtil::GetQuickLaunchPath(bool system_level, FilePath* path) { void ShellUtil::GetRegisteredBrowsers( BrowserDistribution* dist, std::map<string16, string16>* browsers) { - const HKEY root = HKEY_LOCAL_MACHINE; + DCHECK(dist); + DCHECK(browsers); + const string16 base_key(ShellUtil::kRegStartMenuInternet); string16 client_path; RegKey key; string16 name; string16 command; - for (base::win::RegistryKeyIterator iter(root, base_key.c_str()); - iter.Valid(); ++iter) { - client_path.assign(base_key).append(1, L'\\').append(iter.Name()); - // Read the browser's name (localized according to install language). - if (key.Open(root, client_path.c_str(), KEY_QUERY_VALUE) != ERROR_SUCCESS || - key.ReadValue(NULL, &name) != ERROR_SUCCESS) { - continue; - } - // Read the browser's reinstall command. - if (key.Open(root, (client_path + L"\\InstallInfo").c_str(), - KEY_QUERY_VALUE) != ERROR_SUCCESS || - key.ReadValue(kReinstallCommand, &command) != ERROR_SUCCESS) { - continue; + + // HKCU has precedence over HKLM for these registrations: http://goo.gl/xjczJ. + // Look in HKCU second to override any identical values found in HKLM. + const HKEY roots[] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER }; + for (int i = 0; i < arraysize(roots); ++i) { + const HKEY root = roots[i]; + for (base::win::RegistryKeyIterator iter(root, base_key.c_str()); + iter.Valid(); ++iter) { + client_path.assign(base_key).append(1, L'\\').append(iter.Name()); + // Read the browser's name (localized according to install language). + if (key.Open(root, client_path.c_str(), + KEY_QUERY_VALUE) != ERROR_SUCCESS || + key.ReadValue(NULL, &name) != ERROR_SUCCESS || + name.empty() || + name.find(dist->GetApplicationName()) != string16::npos) { + continue; + } + // Read the browser's reinstall command. + if (key.Open(root, (client_path + L"\\InstallInfo").c_str(), + KEY_QUERY_VALUE) == ERROR_SUCCESS && + key.ReadValue(kReinstallCommand, &command) == ERROR_SUCCESS && + !command.empty()) { + (*browsers)[name] = command; + } } - if (!name.empty() && !command.empty() && - name.find(dist->GetApplicationName()) == string16::npos) - (*browsers)[name] = command; } } diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index 3af494b..0e567e9 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -199,8 +199,12 @@ class ShellUtil { // User's profile only affects any new user profiles (not existing ones). static bool GetQuickLaunchPath(bool system_level, FilePath* path); - // Gets a mapping of all registered browser (on local machine) names and - // their reinstall command (which usually sets browser as default). + // Gets a mapping of all registered browser names (excluding browsers in the + // |dist| distribution) and their reinstall command (which usually sets + // browser as default). + // Given browsers can be registered in HKCU (as of Win7) and/or in HKLM, this + // method looks in both and gives precedence to values in HKCU as per the msdn + // standard: http://goo.gl/xjczJ. static void GetRegisteredBrowsers(BrowserDistribution* dist, std::map<string16, string16>* browsers); |