summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 12:58:46 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-15 12:58:46 +0000
commit699c0174dbf67ac79d38324a3db8eb5f73b0f697 (patch)
treed20ec84ef924020e862ff5b5837b1f5b33fc9e50 /chrome/browser
parenteeb08b57983b2050ee13d5173e2603cdcd9c2456 (diff)
downloadchromium_src-699c0174dbf67ac79d38324a3db8eb5f73b0f697.zip
chromium_src-699c0174dbf67ac79d38324a3db8eb5f73b0f697.tar.gz
chromium_src-699c0174dbf67ac79d38324a3db8eb5f73b0f697.tar.bz2
Allow External Extensions to be installed from HKCU, not just HKLM.
HKLM has priority over HKCU. BUG=40533 TEST=External Extensions work as before, except now you can also use HKCU now, not just HKLM. Review URL: http://codereview.chromium.org/7833041 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101283 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/external_registry_extension_loader_win.cc43
1 files changed, 29 insertions, 14 deletions
diff --git a/chrome/browser/extensions/external_registry_extension_loader_win.cc b/chrome/browser/extensions/external_registry_extension_loader_win.cc
index 86cf311..12f8b76 100644
--- a/chrome/browser/extensions/external_registry_extension_loader_win.cc
+++ b/chrome/browser/extensions/external_registry_extension_loader_win.cc
@@ -17,9 +17,6 @@
namespace {
-// The Registry hive where to look for external extensions.
-const HKEY kRegRoot = HKEY_LOCAL_MACHINE;
-
// The Registry subkey that contains information about external extensions.
const char kRegistryExtensions[] = "Software\\Google\\Chrome\\Extensions";
@@ -49,19 +46,37 @@ void ExternalRegistryExtensionLoader::LoadOnFileThread() {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
scoped_ptr<DictionaryValue> prefs(new DictionaryValue);
- base::win::RegistryKeyIterator iterator(
- kRegRoot, ASCIIToWide(kRegistryExtensions).c_str());
- for (; iterator.Valid(); ++iterator) {
+ // A map of IDs, to weed out duplicates between HKCU and HKLM.
+ std::set<string16> keys;
+ base::win::RegistryKeyIterator iterator_machine_key(
+ HKEY_LOCAL_MACHINE, ASCIIToWide(kRegistryExtensions).c_str());
+ for (; iterator_machine_key.Valid(); ++iterator_machine_key)
+ keys.insert(iterator_machine_key.Name());
+ base::win::RegistryKeyIterator iterator_user_key(
+ HKEY_CURRENT_USER, ASCIIToWide(kRegistryExtensions).c_str());
+ for (; iterator_user_key.Valid(); ++iterator_user_key)
+ keys.insert(iterator_user_key.Name());
+
+ // Iterate over the keys found, first trying HKLM, then HKCU, as per Windows
+ // policy conventions. We only fall back to HKCU if the HKLM key cannot be
+ // opened, not if the data within the key is invalid, for example.
+ for (std::set<string16>::const_iterator it = keys.begin();
+ it != keys.end(); ++it) {
base::win::RegKey key;
- std::wstring key_path = ASCIIToWide(kRegistryExtensions);
+ string16 key_path = ASCIIToWide(kRegistryExtensions);
key_path.append(L"\\");
- key_path.append(iterator.Name());
- if (key.Open(kRegRoot, key_path.c_str(), KEY_READ) != ERROR_SUCCESS) {
- LOG(ERROR) << "Unable to read registry key at path: " << key_path << ".";
- continue;
+ key_path.append(*it);
+ if (key.Open(HKEY_LOCAL_MACHINE,
+ key_path.c_str(), KEY_READ) != ERROR_SUCCESS) {
+ if (key.Open(HKEY_CURRENT_USER,
+ key_path.c_str(), KEY_READ) != ERROR_SUCCESS) {
+ LOG(ERROR) << "Unable to read registry key at path (HKLM & HKCU): "
+ << key_path << ".";
+ continue;
+ }
}
- std::wstring extension_path_str;
+ string16 extension_path_str;
if (key.ReadValue(kRegistryExtensionPath, &extension_path_str)
!= ERROR_SUCCESS) {
// TODO(erikkay): find a way to get this into about:extensions
@@ -93,7 +108,7 @@ void ExternalRegistryExtensionLoader::LoadOnFileThread() {
continue;
}
- std::wstring extension_version;
+ string16 extension_version;
if (key.ReadValue(kRegistryExtensionVersion, &extension_version)
!= ERROR_SUCCESS) {
// TODO(erikkay): find a way to get this into about:extensions
@@ -102,7 +117,7 @@ void ExternalRegistryExtensionLoader::LoadOnFileThread() {
continue;
}
- std::string id = WideToASCII(iterator.Name());
+ std::string id = WideToASCII(*it);
StringToLowerASCII(&id);
if (!Extension::IdIsValid(id)) {
LOG(ERROR) << "Invalid id value " << id