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

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

Issue 3836005: Move pe_image and registry from base to base/win and use the namespace. It re... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_extension_provider_win.h" 5 #include "chrome/browser/extensions/external_registry_extension_provider_win.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/registry.h"
9 #include "base/string_util.h" 8 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
11 #include "base/version.h" 10 #include "base/version.h"
11 #include "base/win/registry.h"
12 12
13 // The Registry hive where to look for external extensions. 13 // The Registry hive where to look for external extensions.
14 const HKEY kRegRoot = HKEY_LOCAL_MACHINE; 14 const HKEY kRegRoot = HKEY_LOCAL_MACHINE;
15 15
16 // The Registry subkey that contains information about external extensions. 16 // The Registry subkey that contains information about external extensions.
17 const char kRegistryExtensions[] = "Software\\Google\\Chrome\\Extensions"; 17 const char kRegistryExtensions[] = "Software\\Google\\Chrome\\Extensions";
18 18
19 // Registry value of of that key that defines the path to the .crx file. 19 // Registry value of of that key that defines the path to the .crx file.
20 const wchar_t kRegistryExtensionPath[] = L"path"; 20 const wchar_t kRegistryExtensionPath[] = L"path";
21 21
22 // Registry value of that key that defines the current version of the .crx file. 22 // Registry value of that key that defines the current version of the .crx file.
23 const wchar_t kRegistryExtensionVersion[] = L"version"; 23 const wchar_t kRegistryExtensionVersion[] = L"version";
24 24
25 ExternalRegistryExtensionProvider::ExternalRegistryExtensionProvider() { 25 ExternalRegistryExtensionProvider::ExternalRegistryExtensionProvider() {
26 } 26 }
27 27
28 ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() { 28 ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() {
29 } 29 }
30 30
31 void ExternalRegistryExtensionProvider::VisitRegisteredExtension( 31 void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
32 Visitor* visitor, const std::set<std::string>& ids_to_ignore) const { 32 Visitor* visitor, const std::set<std::string>& ids_to_ignore) const {
33 RegistryKeyIterator iterator(kRegRoot, 33 base::win::RegistryKeyIterator iterator(
34 ASCIIToWide(kRegistryExtensions).c_str()); 34 kRegRoot, ASCIIToWide(kRegistryExtensions).c_str());
35 while (iterator.Valid()) { 35 while (iterator.Valid()) {
36 RegKey key; 36 base::win::RegKey key;
37 std::wstring key_path = ASCIIToWide(kRegistryExtensions); 37 std::wstring key_path = ASCIIToWide(kRegistryExtensions);
38 key_path.append(L"\\"); 38 key_path.append(L"\\");
39 key_path.append(iterator.Name()); 39 key_path.append(iterator.Name());
40 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ)) { 40 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ)) {
41 std::wstring extension_path; 41 std::wstring extension_path;
42 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) { 42 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) {
43 std::wstring extension_version; 43 std::wstring extension_version;
44 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { 44 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) {
45 std::string id = WideToASCII(iterator.Name()); 45 std::string id = WideToASCII(iterator.Name());
46 StringToLowerASCII(&id); 46 StringToLowerASCII(&id);
(...skipping 24 matching lines...) Expand all
71 << " for key " << key_path; 71 << " for key " << key_path;
72 } 72 }
73 } 73 }
74 ++iterator; 74 ++iterator;
75 } 75 }
76 } 76 }
77 77
78 Version* ExternalRegistryExtensionProvider::RegisteredVersion( 78 Version* ExternalRegistryExtensionProvider::RegisteredVersion(
79 const std::string& id, 79 const std::string& id,
80 Extension::Location* location) const { 80 Extension::Location* location) const {
81 RegKey key; 81 base::win::RegKey key;
82 std::wstring key_path = ASCIIToWide(kRegistryExtensions); 82 std::wstring key_path = ASCIIToWide(kRegistryExtensions);
83 key_path.append(L"\\"); 83 key_path.append(L"\\");
84 key_path.append(ASCIIToWide(id)); 84 key_path.append(ASCIIToWide(id));
85 85
86 if (!key.Open(kRegRoot, key_path.c_str(), KEY_READ)) 86 if (!key.Open(kRegRoot, key_path.c_str(), KEY_READ))
87 return NULL; 87 return NULL;
88 88
89 std::wstring extension_version; 89 std::wstring extension_version;
90 if (!key.ReadValue(kRegistryExtensionVersion, &extension_version)) 90 if (!key.ReadValue(kRegistryExtensionVersion, &extension_version))
91 return NULL; 91 return NULL;
92 92
93 if (location) 93 if (location)
94 *location = Extension::EXTERNAL_REGISTRY; 94 *location = Extension::EXTERNAL_REGISTRY;
95 return Version::GetVersionFromString(extension_version); 95 return Version::GetVersionFromString(extension_version);
96 } 96 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_rlz_apitest.cc ('k') | chrome/browser/first_run/first_run_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698