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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <userenv.h> | 10 #include <userenv.h> |
11 | 11 |
12 #include <algorithm> | 12 #include <algorithm> |
13 #include <cstring> | 13 #include <cstring> |
14 #include <functional> | 14 #include <functional> |
15 #include <iterator> | 15 #include <iterator> |
| 16 #include <utility> |
16 #include <vector> | 17 #include <vector> |
17 | 18 |
18 #include "base/base_paths.h" | 19 #include "base/base_paths.h" |
19 #include "base/callback.h" | 20 #include "base/callback.h" |
20 #include "base/files/file_path.h" | 21 #include "base/files/file_path.h" |
21 #include "base/files/file_util.h" | 22 #include "base/files/file_util.h" |
22 #include "base/files/scoped_temp_dir.h" | 23 #include "base/files/scoped_temp_dir.h" |
23 #include "base/json/json_writer.h" | 24 #include "base/json/json_writer.h" |
24 #include "base/macros.h" | 25 #include "base/macros.h" |
25 #include "base/path_service.h" | 26 #include "base/path_service.h" |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 RegistryTestHarness::~RegistryTestHarness() {} | 346 RegistryTestHarness::~RegistryTestHarness() {} |
346 | 347 |
347 void RegistryTestHarness::SetUp() {} | 348 void RegistryTestHarness::SetUp() {} |
348 | 349 |
349 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( | 350 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( |
350 SchemaRegistry* registry, | 351 SchemaRegistry* registry, |
351 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 352 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
352 base::win::SetDomainStateForTesting(true); | 353 base::win::SetDomainStateForTesting(true); |
353 scoped_ptr<AsyncPolicyLoader> loader( | 354 scoped_ptr<AsyncPolicyLoader> loader( |
354 new PolicyLoaderWin(task_runner, kTestPolicyKey, this)); | 355 new PolicyLoaderWin(task_runner, kTestPolicyKey, this)); |
355 return new AsyncPolicyProvider(registry, loader.Pass()); | 356 return new AsyncPolicyProvider(registry, std::move(loader)); |
356 } | 357 } |
357 | 358 |
358 void RegistryTestHarness::InstallEmptyPolicy() {} | 359 void RegistryTestHarness::InstallEmptyPolicy() {} |
359 | 360 |
360 void RegistryTestHarness::InstallStringPolicy( | 361 void RegistryTestHarness::InstallStringPolicy( |
361 const std::string& policy_name, | 362 const std::string& policy_name, |
362 const std::string& policy_value) { | 363 const std::string& policy_value) { |
363 RegKey key(hive_, kTestPolicyKey, KEY_ALL_ACCESS); | 364 RegKey key(hive_, kTestPolicyKey, KEY_ALL_ACCESS); |
364 ASSERT_TRUE(key.Valid()); | 365 ASSERT_TRUE(key.Valid()); |
365 ASSERT_HRESULT_SUCCEEDED(key.WriteValue(UTF8ToUTF16(policy_name).c_str(), | 366 ASSERT_HRESULT_SUCCEEDED(key.WriteValue(UTF8ToUTF16(policy_name).c_str(), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 | 479 |
479 memset(&gpo_, 0, sizeof(GROUP_POLICY_OBJECT)); | 480 memset(&gpo_, 0, sizeof(GROUP_POLICY_OBJECT)); |
480 gpo_.lpFileSysPath = const_cast<wchar_t*>(temp_dir_.path().value().c_str()); | 481 gpo_.lpFileSysPath = const_cast<wchar_t*>(temp_dir_.path().value().c_str()); |
481 } | 482 } |
482 | 483 |
483 ConfigurationPolicyProvider* PRegTestHarness::CreateProvider( | 484 ConfigurationPolicyProvider* PRegTestHarness::CreateProvider( |
484 SchemaRegistry* registry, | 485 SchemaRegistry* registry, |
485 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 486 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
486 scoped_ptr<AsyncPolicyLoader> loader( | 487 scoped_ptr<AsyncPolicyLoader> loader( |
487 new PolicyLoaderWin(task_runner, kTestPolicyKey, this)); | 488 new PolicyLoaderWin(task_runner, kTestPolicyKey, this)); |
488 return new AsyncPolicyProvider(registry, loader.Pass()); | 489 return new AsyncPolicyProvider(registry, std::move(loader)); |
489 } | 490 } |
490 | 491 |
491 void PRegTestHarness::InstallEmptyPolicy() {} | 492 void PRegTestHarness::InstallEmptyPolicy() {} |
492 | 493 |
493 void PRegTestHarness::InstallStringPolicy(const std::string& policy_name, | 494 void PRegTestHarness::InstallStringPolicy(const std::string& policy_name, |
494 const std::string& policy_value) { | 495 const std::string& policy_value) { |
495 AppendStringToPRegFile(kTestPolicyKey, policy_name, policy_value); | 496 AppendStringToPRegFile(kTestPolicyKey, policy_name, policy_value); |
496 } | 497 } |
497 | 498 |
498 void PRegTestHarness::InstallIntegerPolicy(const std::string& policy_name, | 499 void PRegTestHarness::InstallIntegerPolicy(const std::string& policy_name, |
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1236 expected_policy.Set("alternative_browser_path", | 1237 expected_policy.Set("alternative_browser_path", |
1237 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1238 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
1238 POLICY_SOURCE_PLATFORM, | 1239 POLICY_SOURCE_PLATFORM, |
1239 new base::StringValue("c:\\legacy\\browser.exe"), NULL); | 1240 new base::StringValue("c:\\legacy\\browser.exe"), NULL); |
1240 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1241 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
1241 POLICY_SOURCE_PLATFORM, list.DeepCopy(), nullptr); | 1242 POLICY_SOURCE_PLATFORM, list.DeepCopy(), nullptr); |
1242 EXPECT_TRUE(Matches(expected)); | 1243 EXPECT_TRUE(Matches(expected)); |
1243 } | 1244 } |
1244 | 1245 |
1245 } // namespace policy | 1246 } // namespace policy |
OLD | NEW |