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

Side by Side Diff: chrome/browser/policy/configuration_policy_provider_win.cc

Issue 3172009: Cleanup Registry API: part 3. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: chrome fixes Created 10 years, 4 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
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/policy/configuration_policy_provider_win.h" 5 #include "chrome/browser/policy/configuration_policy_provider_win.h"
6 6
7 #include <userenv.h> 7 #include <userenv.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 int index = 0; 103 int index = 0;
104 string16 policy_string; 104 string16 policy_string;
105 while (GetRegistryPolicyString(key, ++index, &policy_string)) 105 while (GetRegistryPolicyString(key, ++index, &policy_string))
106 result->Append(Value::CreateStringValue(policy_string)); 106 result->Append(Value::CreateStringValue(policy_string));
107 return true; 107 return true;
108 } 108 }
109 109
110 bool ConfigurationPolicyProviderWin::GetRegistryPolicyBoolean( 110 bool ConfigurationPolicyProviderWin::GetRegistryPolicyBoolean(
111 const string16& value_name, bool* result) { 111 const string16& value_name, bool* result) {
112 DWORD value; 112 DWORD value;
113 RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey); 113 RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey, KEY_READ);
114 if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) { 114 if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) {
115 *result = value != 0; 115 *result = value != 0;
116 return true; 116 return true;
117 } 117 }
118 118
119 RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey); 119 RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey, KEY_READ);
120 if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) { 120 if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) {
121 *result = value != 0; 121 *result = value != 0;
122 return true; 122 return true;
123 } 123 }
124 return false; 124 return false;
125 } 125 }
126 126
127 bool ConfigurationPolicyProviderWin::GetRegistryPolicyInteger( 127 bool ConfigurationPolicyProviderWin::GetRegistryPolicyInteger(
128 const string16& value_name, uint32* result) { 128 const string16& value_name, uint32* result) {
129 DWORD value; 129 DWORD value;
130 RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey); 130 RegKey hkcu_policy_key(HKEY_LOCAL_MACHINE, policy::kRegistrySubKey, KEY_READ);
131 if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) { 131 if (hkcu_policy_key.ReadValueDW(value_name.c_str(), &value)) {
132 *result = value; 132 *result = value;
133 return true; 133 return true;
134 } 134 }
135 135
136 RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey); 136 RegKey hklm_policy_key(HKEY_CURRENT_USER, policy::kRegistrySubKey, KEY_READ);
137 if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) { 137 if (hklm_policy_key.ReadValueDW(value_name.c_str(), &value)) {
138 *result = value; 138 *result = value;
139 return true; 139 return true;
140 } 140 }
141 return false; 141 return false;
142 } 142 }
143 143
144 bool ConfigurationPolicyProviderWin::Provide( 144 bool ConfigurationPolicyProviderWin::Provide(
145 ConfigurationPolicyStore* store) { 145 ConfigurationPolicyStore* store) {
146 const PolicyValueMap* mapping = PolicyValueMapping(); 146 const PolicyValueMap* mapping = PolicyValueMapping();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 break; 180 break;
181 } 181 }
182 default: 182 default:
183 NOTREACHED(); 183 NOTREACHED();
184 return false; 184 return false;
185 } 185 }
186 } 186 }
187 187
188 return true; 188 return true;
189 } 189 }
OLDNEW
« no previous file with comments | « chrome/browser/importer/ie_importer.cc ('k') | chrome/browser/policy/configuration_policy_provider_win_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698