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

Unified Diff: chrome/browser/policy/configuration_policy_provider_delegate_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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/configuration_policy_provider_delegate_win.cc
===================================================================
--- chrome/browser/policy/configuration_policy_provider_delegate_win.cc (revision 70414)
+++ chrome/browser/policy/configuration_policy_provider_delegate_win.cc (working copy)
@@ -19,7 +19,7 @@
DWORD key_type = 0;
scoped_array<uint8> buffer;
- if (!key->ReadValue(name.c_str(), 0, &value_size, &key_type))
+ if (key->ReadValue(name.c_str(), 0, &value_size, &key_type) != ERROR_SUCCESS)
return false;
if (key_type != REG_SZ)
return false;
@@ -89,16 +89,14 @@
bool ConfigurationPolicyProviderDelegateWin::GetRegistryPolicyString(
const string16& name, string16* result) const {
- string16 path = string16(kRegistrySubKey);
- RegKey policy_key;
+ RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
// First try the global policy.
- if (policy_key.Open(HKEY_LOCAL_MACHINE, path.c_str(), KEY_READ)) {
- if (ReadRegistryStringValue(&policy_key, name, result))
- return true;
- policy_key.Close();
- }
+ if (ReadRegistryStringValue(&policy_key, name, result))
+ return true;
+
// Fall back on user-specific policy.
- if (!policy_key.Open(HKEY_CURRENT_USER, path.c_str(), KEY_READ))
+ if (policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey,
+ KEY_READ) != ERROR_SUCCESS)
return false;
return ReadRegistryStringValue(&policy_key, name, result);
}
@@ -108,10 +106,11 @@
string16 path = string16(kRegistrySubKey);
path += ASCIIToUTF16("\\") + key;
RegKey policy_key;
- if (!policy_key.Open(HKEY_LOCAL_MACHINE, path.c_str(), KEY_READ)) {
- policy_key.Close();
+ LONG ret = policy_key.Open(HKEY_LOCAL_MACHINE, path.c_str(), KEY_READ);
+ if (ret != ERROR_SUCCESS) {
// Fall back on user-specific policy.
- if (!policy_key.Open(HKEY_CURRENT_USER, path.c_str(), KEY_READ))
+ ret = policy_key.Open(HKEY_CURRENT_USER, path.c_str(), KEY_READ);
+ if (ret != ERROR_SUCCESS)
return false;
}
string16 policy_string;
@@ -125,34 +124,27 @@
bool ConfigurationPolicyProviderDelegateWin::GetRegistryPolicyBoolean(
const string16& value_name, bool* result) const {
- DWORD value;
- RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
- if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) {
- *result = value != 0;
- return true;
- }
-
- RegKey hklm_policy_key(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ);
- if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) {
- *result = value != 0;
- return true;
- }
- return false;
+ uint32 local_result = 0;
+ bool ret = GetRegistryPolicyInteger(value_name, &local_result);
+ *result = local_result != 0;
grt (UTC plus 2) 2011/01/11 03:51:30 Only modify *result when ret != false.
+ return ret;
}
bool ConfigurationPolicyProviderDelegateWin::GetRegistryPolicyInteger(
const string16& value_name, uint32* result) const {
- DWORD value;
- RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
- if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) {
+ DWORD value = 0;
+ RegKey policy_key(HKEY_LOCAL_MACHINE, kRegistrySubKey, KEY_READ);
+ if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) {
*result = value;
return true;
}
- RegKey hklm_policy_key(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ);
- if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) {
- *result = value;
- return true;
+ LONG ret = policy_key.Open(HKEY_CURRENT_USER, kRegistrySubKey, KEY_READ);
+ if (ret == ERROR_SUCCESS) {
+ if (policy_key.ReadValueDW(value_name.c_str(), &value) == ERROR_SUCCESS) {
+ *result = value;
+ return true;
+ }
}
return false;
}
Property changes on: chrome\browser\policy\configuration_policy_provider_delegate_win.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698