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

Side by Side Diff: chrome/browser/extensions/external_registry_loader_win.cc

Issue 12314090: Add utf_string_conversions to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/memory/scoped_handle.h" 10 #include "base/memory/scoped_handle.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 void ExternalRegistryLoader::LoadOnFileThread() { 51 void ExternalRegistryLoader::LoadOnFileThread() {
52 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 52 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
53 base::TimeTicks start_time = base::TimeTicks::Now(); 53 base::TimeTicks start_time = base::TimeTicks::Now();
54 scoped_ptr<DictionaryValue> prefs(new DictionaryValue); 54 scoped_ptr<DictionaryValue> prefs(new DictionaryValue);
55 55
56 // A map of IDs, to weed out duplicates between HKCU and HKLM. 56 // A map of IDs, to weed out duplicates between HKCU and HKLM.
57 std::set<string16> keys; 57 std::set<string16> keys;
58 base::win::RegistryKeyIterator iterator_machine_key( 58 base::win::RegistryKeyIterator iterator_machine_key(
59 HKEY_LOCAL_MACHINE, ASCIIToWide(kRegistryExtensions).c_str()); 59 HKEY_LOCAL_MACHINE, base::ASCIIToWide(kRegistryExtensions).c_str());
60 for (; iterator_machine_key.Valid(); ++iterator_machine_key) 60 for (; iterator_machine_key.Valid(); ++iterator_machine_key)
61 keys.insert(iterator_machine_key.Name()); 61 keys.insert(iterator_machine_key.Name());
62 base::win::RegistryKeyIterator iterator_user_key( 62 base::win::RegistryKeyIterator iterator_user_key(
63 HKEY_CURRENT_USER, ASCIIToWide(kRegistryExtensions).c_str()); 63 HKEY_CURRENT_USER, base::ASCIIToWide(kRegistryExtensions).c_str());
64 for (; iterator_user_key.Valid(); ++iterator_user_key) 64 for (; iterator_user_key.Valid(); ++iterator_user_key)
65 keys.insert(iterator_user_key.Name()); 65 keys.insert(iterator_user_key.Name());
66 66
67 // Iterate over the keys found, first trying HKLM, then HKCU, as per Windows 67 // Iterate over the keys found, first trying HKLM, then HKCU, as per Windows
68 // policy conventions. We only fall back to HKCU if the HKLM key cannot be 68 // policy conventions. We only fall back to HKCU if the HKLM key cannot be
69 // opened, not if the data within the key is invalid, for example. 69 // opened, not if the data within the key is invalid, for example.
70 for (std::set<string16>::const_iterator it = keys.begin(); 70 for (std::set<string16>::const_iterator it = keys.begin();
71 it != keys.end(); ++it) { 71 it != keys.end(); ++it) {
72 base::win::RegKey key; 72 base::win::RegKey key;
73 string16 key_path = ASCIIToWide(kRegistryExtensions); 73 string16 key_path = base::ASCIIToWide(kRegistryExtensions);
74 key_path.append(L"\\"); 74 key_path.append(L"\\");
75 key_path.append(*it); 75 key_path.append(*it);
76 if (key.Open(HKEY_LOCAL_MACHINE, 76 if (key.Open(HKEY_LOCAL_MACHINE,
77 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) { 77 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) {
78 if (key.Open(HKEY_CURRENT_USER, 78 if (key.Open(HKEY_CURRENT_USER,
79 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) { 79 key_path.c_str(), KEY_READ) != ERROR_SUCCESS) {
80 LOG(ERROR) << "Unable to read registry key at path (HKLM & HKCU): " 80 LOG(ERROR) << "Unable to read registry key at path (HKLM & HKCU): "
81 << key_path << "."; 81 << key_path << ".";
82 continue; 82 continue;
83 } 83 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 117
118 string16 extension_version; 118 string16 extension_version;
119 if (key.ReadValue(kRegistryExtensionVersion, &extension_version) 119 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)
120 != ERROR_SUCCESS) { 120 != ERROR_SUCCESS) {
121 // TODO(erikkay): find a way to get this into about:extensions 121 // TODO(erikkay): find a way to get this into about:extensions
122 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion 122 LOG(ERROR) << "Missing value " << kRegistryExtensionVersion
123 << " for key " << key_path << "."; 123 << " for key " << key_path << ".";
124 continue; 124 continue;
125 } 125 }
126 126
127 std::string id = WideToASCII(*it); 127 std::string id = base::WideToASCII(*it);
128 StringToLowerASCII(&id); 128 StringToLowerASCII(&id);
129 if (!Extension::IdIsValid(id)) { 129 if (!Extension::IdIsValid(id)) {
130 LOG(ERROR) << "Invalid id value " << id 130 LOG(ERROR) << "Invalid id value " << id
131 << " for key " << key_path << "."; 131 << " for key " << key_path << ".";
132 continue; 132 continue;
133 } 133 }
134 134
135 Version version(WideToASCII(extension_version)); 135 Version version(base::WideToASCII(extension_version));
136 if (!version.IsValid()) { 136 if (!version.IsValid()) {
137 LOG(ERROR) << "Invalid version value " << extension_version 137 LOG(ERROR) << "Invalid version value " << extension_version
138 << " for key " << key_path << "."; 138 << " for key " << key_path << ".";
139 continue; 139 continue;
140 } 140 }
141 141
142 prefs->SetString( 142 prefs->SetString(
143 id + "." + ExternalProviderImpl::kExternalVersion, 143 id + "." + ExternalProviderImpl::kExternalVersion,
144 WideToASCII(extension_version)); 144 base::WideToASCII(extension_version));
145 prefs->SetString( 145 prefs->SetString(
146 id + "." + ExternalProviderImpl::kExternalCrx, 146 id + "." + ExternalProviderImpl::kExternalCrx,
147 extension_path_str); 147 extension_path_str);
148 } 148 }
149 149
150 prefs_.reset(prefs.release()); 150 prefs_.reset(prefs.release());
151 HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin", 151 HISTOGRAM_TIMES("Extensions.ExternalRegistryLoaderWin",
152 base::TimeTicks::Now() - start_time); 152 base::TimeTicks::Now() - start_time);
153 BrowserThread::PostTask( 153 BrowserThread::PostTask(
154 BrowserThread::UI, FROM_HERE, 154 BrowserThread::UI, FROM_HERE,
155 base::Bind(&ExternalRegistryLoader::LoadFinished, this)); 155 base::Bind(&ExternalRegistryLoader::LoadFinished, this));
156 } 156 }
157 157
158 } // namespace extensions 158 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_pref_loader.cc ('k') | chrome/browser/extensions/page_action_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698