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

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

Issue 6090006: Regkey functions return error code instead of bool (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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) 2010 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/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/version.h" 10 #include "base/version.h"
(...skipping 11 matching lines...) Expand all
22 const wchar_t kRegistryExtensionPath[] = L"path"; 22 const wchar_t kRegistryExtensionPath[] = L"path";
23 23
24 // Registry value of that key that defines the current version of the .crx file. 24 // Registry value of that key that defines the current version of the .crx file.
25 const wchar_t kRegistryExtensionVersion[] = L"version"; 25 const wchar_t kRegistryExtensionVersion[] = L"version";
26 26
27 bool OpenKeyById(const std::string& id, base::win::RegKey *key) { 27 bool OpenKeyById(const std::string& id, base::win::RegKey *key) {
28 std::wstring key_path = ASCIIToWide(kRegistryExtensions); 28 std::wstring key_path = ASCIIToWide(kRegistryExtensions);
29 key_path.append(L"\\"); 29 key_path.append(L"\\");
30 key_path.append(ASCIIToWide(id)); 30 key_path.append(ASCIIToWide(id));
31 31
32 return key->Open(kRegRoot, key_path.c_str(), KEY_READ); 32 LONG result = key->Open(kRegRoot, key_path.c_str(), KEY_READ);
33 return (ERROR_SUCCESS == result);
33 } 34 }
34 35
35 } // namespace 36 } // namespace
36 37
37 ExternalRegistryExtensionProvider::ExternalRegistryExtensionProvider() { 38 ExternalRegistryExtensionProvider::ExternalRegistryExtensionProvider() {
38 } 39 }
39 40
40 ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() { 41 ExternalRegistryExtensionProvider::~ExternalRegistryExtensionProvider() {
41 } 42 }
42 43
43 void ExternalRegistryExtensionProvider::VisitRegisteredExtension( 44 void ExternalRegistryExtensionProvider::VisitRegisteredExtension(
44 Visitor* visitor) const { 45 Visitor* visitor) const {
45 base::win::RegistryKeyIterator iterator( 46 base::win::RegistryKeyIterator iterator(
46 kRegRoot, ASCIIToWide(kRegistryExtensions).c_str()); 47 kRegRoot, ASCIIToWide(kRegistryExtensions).c_str());
47 while (iterator.Valid()) { 48 while (iterator.Valid()) {
48 base::win::RegKey key; 49 base::win::RegKey key;
49 std::wstring key_path = ASCIIToWide(kRegistryExtensions); 50 std::wstring key_path = ASCIIToWide(kRegistryExtensions);
50 key_path.append(L"\\"); 51 key_path.append(L"\\");
51 key_path.append(iterator.Name()); 52 key_path.append(iterator.Name());
52 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ)) { 53 if (key.Open(kRegRoot, key_path.c_str(), KEY_READ) == ERROR_SUCCESS) {
53 std::wstring extension_path; 54 std::wstring extension_path;
54 if (key.ReadValue(kRegistryExtensionPath, &extension_path)) { 55 if (key.ReadValue(kRegistryExtensionPath,
56 &extension_path) == ERROR_SUCCESS) {
55 std::wstring extension_version; 57 std::wstring extension_version;
56 if (key.ReadValue(kRegistryExtensionVersion, &extension_version)) { 58 if (key.ReadValue(kRegistryExtensionVersion,
59 &extension_version) == ERROR_SUCCESS) {
57 std::string id = WideToASCII(iterator.Name()); 60 std::string id = WideToASCII(iterator.Name());
58 StringToLowerASCII(&id); 61 StringToLowerASCII(&id);
59 62
60 scoped_ptr<Version> version; 63 scoped_ptr<Version> version;
61 version.reset(Version::GetVersionFromString( 64 version.reset(Version::GetVersionFromString(
62 WideToASCII(extension_version))); 65 WideToASCII(extension_version)));
63 if (!version.get()) { 66 if (!version.get()) {
64 LOG(ERROR) << "Invalid version value " << extension_version 67 LOG(ERROR) << "Invalid version value " << extension_version
65 << " for key " << key_path; 68 << " for key " << key_path;
66 ++iterator; 69 ++iterator;
(...skipping 27 matching lines...) Expand all
94 97
95 bool ExternalRegistryExtensionProvider::GetExtensionDetails( 98 bool ExternalRegistryExtensionProvider::GetExtensionDetails(
96 const std::string& id, 99 const std::string& id,
97 Extension::Location* location, 100 Extension::Location* location,
98 scoped_ptr<Version>* version) const { 101 scoped_ptr<Version>* version) const {
99 base::win::RegKey key; 102 base::win::RegKey key;
100 if (!OpenKeyById(id, &key)) 103 if (!OpenKeyById(id, &key))
101 return false; 104 return false;
102 105
103 std::wstring extension_version; 106 std::wstring extension_version;
104 if (!key.ReadValue(kRegistryExtensionVersion, &extension_version)) 107 if (key.ReadValue(kRegistryExtensionVersion,
108 &extension_version) != ERROR_SUCCESS)
105 return false; 109 return false;
106 110
107 if (version) { 111 if (version) {
108 version->reset(Version::GetVersionFromString( 112 version->reset(Version::GetVersionFromString(
109 WideToASCII(extension_version))); 113 WideToASCII(extension_version)));
110 } 114 }
111 115
112 if (location) 116 if (location)
113 *location = Extension::EXTERNAL_REGISTRY; 117 *location = Extension::EXTERNAL_REGISTRY;
114 return true; 118 return true;
115 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698