OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/policy/core/common/policy_loader_win.h" | 5 #include "components/policy/core/common/policy_loader_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <userenv.h> | 8 #include <userenv.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 ScopedGroupPolicyRegistrySandbox(); | 148 ScopedGroupPolicyRegistrySandbox(); |
149 ~ScopedGroupPolicyRegistrySandbox(); | 149 ~ScopedGroupPolicyRegistrySandbox(); |
150 | 150 |
151 private: | 151 private: |
152 void ActivateOverrides(); | 152 void ActivateOverrides(); |
153 void RemoveOverrides(); | 153 void RemoveOverrides(); |
154 | 154 |
155 // Deletes the sandbox keys. | 155 // Deletes the sandbox keys. |
156 void DeleteKeys(); | 156 void DeleteKeys(); |
157 | 157 |
158 std::wstring key_name_; | 158 base::string16 key_name_; |
159 | 159 |
160 // Keys are created for the lifetime of a test to contain | 160 // Keys are created for the lifetime of a test to contain |
161 // the sandboxed HKCU and HKLM hives, respectively. | 161 // the sandboxed HKCU and HKLM hives, respectively. |
162 RegKey temp_hkcu_hive_key_; | 162 RegKey temp_hkcu_hive_key_; |
163 RegKey temp_hklm_hive_key_; | 163 RegKey temp_hklm_hive_key_; |
164 | 164 |
165 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox); | 165 DISALLOW_COPY_AND_ASSIGN(ScopedGroupPolicyRegistrySandbox); |
166 }; | 166 }; |
167 | 167 |
168 // A test harness that feeds policy via the Chrome GPO registry subtree. | 168 // A test harness that feeds policy via the Chrome GPO registry subtree. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 base::FilePath preg_file_path_; | 289 base::FilePath preg_file_path_; |
290 GROUP_POLICY_OBJECT gpo_; | 290 GROUP_POLICY_OBJECT gpo_; |
291 | 291 |
292 DISALLOW_COPY_AND_ASSIGN(PRegTestHarness); | 292 DISALLOW_COPY_AND_ASSIGN(PRegTestHarness); |
293 }; | 293 }; |
294 | 294 |
295 ScopedGroupPolicyRegistrySandbox::ScopedGroupPolicyRegistrySandbox() { | 295 ScopedGroupPolicyRegistrySandbox::ScopedGroupPolicyRegistrySandbox() { |
296 // Generate a unique registry key for the override for each test. This | 296 // Generate a unique registry key for the override for each test. This |
297 // makes sure that tests executing in parallel won't delete each other's | 297 // makes sure that tests executing in parallel won't delete each other's |
298 // key, at DeleteKeys(). | 298 // key, at DeleteKeys(). |
299 key_name_ = base::ASCIIToWide(base::StringPrintf( | 299 key_name_ = base::ASCIIToUTF16(base::StringPrintf( |
300 "SOFTWARE\\chromium unittest %d", base::GetCurrentProcId())); | 300 "SOFTWARE\\chromium unittest %d", base::GetCurrentProcId())); |
301 std::wstring hklm_key_name = key_name_ + L"\\HKLM"; | 301 std::wstring hklm_key_name = key_name_ + L"\\HKLM"; |
302 std::wstring hkcu_key_name = key_name_ + L"\\HKCU"; | 302 std::wstring hkcu_key_name = key_name_ + L"\\HKCU"; |
303 | 303 |
304 // Create the subkeys to hold the overridden HKLM and HKCU | 304 // Create the subkeys to hold the overridden HKLM and HKCU |
305 // policy settings. | 305 // policy settings. |
306 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER, | 306 temp_hklm_hive_key_.Create(HKEY_CURRENT_USER, |
307 hklm_key_name.c_str(), | 307 hklm_key_name.c_str(), |
308 KEY_ALL_ACCESS); | 308 KEY_ALL_ACCESS); |
309 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER, | 309 temp_hkcu_hive_key_.Create(HKEY_CURRENT_USER, |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 PolicyMap& expected_policy = expected.Get(ns); | 1207 PolicyMap& expected_policy = expected.Get(ns); |
1208 expected_policy.Set("alternative_browser_path", | 1208 expected_policy.Set("alternative_browser_path", |
1209 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1209 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
1210 new base::StringValue("c:\\legacy\\browser.exe"), NULL); | 1210 new base::StringValue("c:\\legacy\\browser.exe"), NULL); |
1211 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1211 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
1212 list.DeepCopy(), NULL); | 1212 list.DeepCopy(), NULL); |
1213 EXPECT_TRUE(Matches(expected)); | 1213 EXPECT_TRUE(Matches(expected)); |
1214 } | 1214 } |
1215 | 1215 |
1216 } // namespace policy | 1216 } // namespace policy |
OLD | NEW |