OLD | NEW |
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 #include "chrome/browser/extensions/external_registry_loader_win.h" | 5 #include "chrome/browser/extensions/external_registry_loader_win.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 } | 61 } |
62 | 62 |
63 void ExternalRegistryLoader::LoadOnFileThread() { | 63 void ExternalRegistryLoader::LoadOnFileThread() { |
64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 64 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
65 base::TimeTicks start_time = base::TimeTicks::Now(); | 65 base::TimeTicks start_time = base::TimeTicks::Now(); |
66 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); | 66 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
67 | 67 |
68 // A map of IDs, to weed out duplicates between HKCU and HKLM. | 68 // A map of IDs, to weed out duplicates between HKCU and HKLM. |
69 std::set<base::string16> keys; | 69 std::set<base::string16> keys; |
70 base::win::RegistryKeyIterator iterator_machine_key( | 70 base::win::RegistryKeyIterator iterator_machine_key( |
71 HKEY_LOCAL_MACHINE, base::ASCIIToWide(kRegistryExtensions).c_str()); | 71 HKEY_LOCAL_MACHINE, |
| 72 base::ASCIIToWide(kRegistryExtensions).c_str(), |
| 73 KEY_WOW64_32KEY); |
72 for (; iterator_machine_key.Valid(); ++iterator_machine_key) | 74 for (; iterator_machine_key.Valid(); ++iterator_machine_key) |
73 keys.insert(iterator_machine_key.Name()); | 75 keys.insert(iterator_machine_key.Name()); |
74 base::win::RegistryKeyIterator iterator_user_key( | 76 base::win::RegistryKeyIterator iterator_user_key( |
75 HKEY_CURRENT_USER, base::ASCIIToWide(kRegistryExtensions).c_str()); | 77 HKEY_CURRENT_USER, base::ASCIIToWide(kRegistryExtensions).c_str()); |
76 for (; iterator_user_key.Valid(); ++iterator_user_key) | 78 for (; iterator_user_key.Valid(); ++iterator_user_key) |
77 keys.insert(iterator_user_key.Name()); | 79 keys.insert(iterator_user_key.Name()); |
78 | 80 |
79 // Iterate over the keys found, first trying HKLM, then HKCU, as per Windows | 81 // Iterate over the keys found, first trying HKLM, then HKCU, as per Windows |
80 // policy conventions. We only fall back to HKCU if the HKLM key cannot be | 82 // policy conventions. We only fall back to HKCU if the HKLM key cannot be |
81 // opened, not if the data within the key is invalid, for example. | 83 // opened, not if the data within the key is invalid, for example. |
82 for (std::set<base::string16>::const_iterator it = keys.begin(); | 84 for (std::set<base::string16>::const_iterator it = keys.begin(); |
83 it != keys.end(); ++it) { | 85 it != keys.end(); ++it) { |
84 base::win::RegKey key; | 86 base::win::RegKey key; |
85 base::string16 key_path = base::ASCIIToWide(kRegistryExtensions); | 87 base::string16 key_path = base::ASCIIToWide(kRegistryExtensions); |
86 key_path.append(L"\\"); | 88 key_path.append(L"\\"); |
87 key_path.append(*it); | 89 key_path.append(*it); |
88 if (key.Open(HKEY_LOCAL_MACHINE, | 90 if (key.Open(HKEY_LOCAL_MACHINE, |
89 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) { | 91 key_path.c_str(), |
90 if (key.Open(HKEY_CURRENT_USER, | 92 KEY_READ | KEY_WOW64_32KEY) != ERROR_SUCCESS && |
91 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) { | 93 key.Open(HKEY_CURRENT_USER, key_path.c_str(), KEY_READ) != |
92 LOG(ERROR) << "Unable to read registry key at path (HKLM & HKCU): " | 94 ERROR_SUCCESS) { |
93 << key_path << "."; | 95 LOG(ERROR) << "Unable to read registry key at path (HKLM & HKCU): " |
94 continue; | 96 << key_path << "."; |
95 } | 97 continue; |
96 } | 98 } |
97 | 99 |
98 std::string id = base::UTF16ToASCII(*it); | 100 std::string id = base::UTF16ToASCII(*it); |
99 base::StringToLowerASCII(&id); | 101 base::StringToLowerASCII(&id); |
100 if (!crx_file::id_util::IdIsValid(id)) { | 102 if (!crx_file::id_util::IdIsValid(id)) { |
101 LOG(ERROR) << "Invalid id value " << id | 103 LOG(ERROR) << "Invalid id value " << id |
102 << " for key " << key_path << "."; | 104 << " for key " << key_path << "."; |
103 continue; | 105 continue; |
104 } | 106 } |
105 | 107 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 184 |
183 prefs_.reset(prefs.release()); | 185 prefs_.reset(prefs.release()); |
184 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", | 186 LOCAL_HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", |
185 base::TimeTicks::Now() - start_time); | 187 base::TimeTicks::Now() - start_time); |
186 BrowserThread::PostTask( | 188 BrowserThread::PostTask( |
187 BrowserThread::UI, FROM_HERE, | 189 BrowserThread::UI, FROM_HERE, |
188 base::Bind(&ExternalRegistryLoader::LoadFinished, this)); | 190 base::Bind(&ExternalRegistryLoader::LoadFinished, this)); |
189 } | 191 } |
190 | 192 |
191 } // namespace extensions | 193 } // namespace extensions |
OLD | NEW |