OLD | NEW |
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 string16 location = string16(policy::kRegistrySubKey); | 66 string16 location = string16(policy::kRegistrySubKey); |
67 string16 value_name = name; | 67 string16 value_name = name; |
68 | 68 |
69 if (index > 0) { | 69 if (index > 0) { |
70 // This is a list value, treat |name| as a subkey. | 70 // This is a list value, treat |name| as a subkey. |
71 location += ASCIIToUTF16("\\") + name; | 71 location += ASCIIToUTF16("\\") + name; |
72 value_name = base::IntToString16(index); | 72 value_name = base::IntToString16(index); |
73 } | 73 } |
74 | 74 |
75 // First try the global policy. | 75 // First try the global policy. |
76 if (!policy_key.Open(HKEY_LOCAL_MACHINE, location.c_str()) || | 76 if (!policy_key.Open(HKEY_LOCAL_MACHINE, location.c_str(), KEY_READ) || |
77 !policy_key.ReadValue(value_name.c_str(), 0, &value_size, &key_type)) { | 77 !policy_key.ReadValue(value_name.c_str(), 0, &value_size, &key_type)) { |
78 policy_key.Close(); | 78 policy_key.Close(); |
79 // Fall back on user-specific policy. | 79 // Fall back on user-specific policy. |
80 if (!policy_key.Open(HKEY_CURRENT_USER, location.c_str()) || | 80 if (!policy_key.Open(HKEY_CURRENT_USER, location.c_str(), KEY_READ) || |
81 !policy_key.ReadValue(value_name.c_str(), 0, &value_size, &key_type)) { | 81 !policy_key.ReadValue(value_name.c_str(), 0, &value_size, &key_type)) { |
82 return false; | 82 return false; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 if (key_type != REG_SZ) | 86 if (key_type != REG_SZ) |
87 return false; | 87 return false; |
88 | 88 |
89 // According to the Microsoft documentation, the string | 89 // According to the Microsoft documentation, the string |
90 // buffer may not be explicitly 0-terminated. Allocate a | 90 // buffer may not be explicitly 0-terminated. Allocate a |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 } |
OLD | NEW |