| 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 16 matching lines...) Expand all Loading... |
| 27 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/sys_byteorder.h" | 29 #include "base/sys_byteorder.h" |
| 30 #include "base/win/registry.h" | 30 #include "base/win/registry.h" |
| 31 #include "base/win/win_util.h" | 31 #include "base/win/win_util.h" |
| 32 #include "components/policy/core/common/async_policy_provider.h" | 32 #include "components/policy/core/common/async_policy_provider.h" |
| 33 #include "components/policy/core/common/configuration_policy_provider_test.h" | 33 #include "components/policy/core/common/configuration_policy_provider_test.h" |
| 34 #include "components/policy/core/common/external_data_fetcher.h" | 34 #include "components/policy/core/common/external_data_fetcher.h" |
| 35 #include "components/policy/core/common/policy_bundle.h" | 35 #include "components/policy/core/common/policy_bundle.h" |
| 36 #include "components/policy/core/common/policy_map.h" | 36 #include "components/policy/core/common/policy_map.h" |
| 37 #include "components/policy/core/common/policy_types.h" |
| 37 #include "components/policy/core/common/preg_parser_win.h" | 38 #include "components/policy/core/common/preg_parser_win.h" |
| 38 #include "components/policy/core/common/schema_map.h" | 39 #include "components/policy/core/common/schema_map.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 40 #include "testing/gtest/include/gtest/gtest.h" |
| 40 | 41 |
| 41 using base::UTF8ToUTF16; | 42 using base::UTF8ToUTF16; |
| 42 using base::UTF16ToUTF8; | 43 using base::UTF16ToUTF8; |
| 43 using base::win::RegKey; | 44 using base::win::RegKey; |
| 44 | 45 |
| 45 namespace policy { | 46 namespace policy { |
| 46 | 47 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 ASSERT_HRESULT_SUCCEEDED(RegOverridePredefKey(HKEY_CURRENT_USER, 0)); | 327 ASSERT_HRESULT_SUCCEEDED(RegOverridePredefKey(HKEY_CURRENT_USER, 0)); |
| 327 } | 328 } |
| 328 | 329 |
| 329 void ScopedGroupPolicyRegistrySandbox::DeleteKeys() { | 330 void ScopedGroupPolicyRegistrySandbox::DeleteKeys() { |
| 330 RegKey key(HKEY_CURRENT_USER, key_name_.c_str(), KEY_ALL_ACCESS); | 331 RegKey key(HKEY_CURRENT_USER, key_name_.c_str(), KEY_ALL_ACCESS); |
| 331 ASSERT_TRUE(key.Valid()); | 332 ASSERT_TRUE(key.Valid()); |
| 332 key.DeleteKey(L""); | 333 key.DeleteKey(L""); |
| 333 } | 334 } |
| 334 | 335 |
| 335 RegistryTestHarness::RegistryTestHarness(HKEY hive, PolicyScope scope) | 336 RegistryTestHarness::RegistryTestHarness(HKEY hive, PolicyScope scope) |
| 336 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope), hive_(hive) {} | 337 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, scope, |
| 338 POLICY_SOURCE_PLATFORM), |
| 339 hive_(hive) { |
| 340 } |
| 337 | 341 |
| 338 RegistryTestHarness::~RegistryTestHarness() {} | 342 RegistryTestHarness::~RegistryTestHarness() {} |
| 339 | 343 |
| 340 void RegistryTestHarness::SetUp() {} | 344 void RegistryTestHarness::SetUp() {} |
| 341 | 345 |
| 342 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( | 346 ConfigurationPolicyProvider* RegistryTestHarness::CreateProvider( |
| 343 SchemaRegistry* registry, | 347 SchemaRegistry* registry, |
| 344 scoped_refptr<base::SequencedTaskRunner> task_runner) { | 348 scoped_refptr<base::SequencedTaskRunner> task_runner) { |
| 345 base::win::SetDomainStateForTesting(true); | 349 base::win::SetDomainStateForTesting(true); |
| 346 scoped_ptr<AsyncPolicyLoader> loader( | 350 scoped_ptr<AsyncPolicyLoader> loader( |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 PolicyProviderTestHarness* RegistryTestHarness::CreateHKCU() { | 452 PolicyProviderTestHarness* RegistryTestHarness::CreateHKCU() { |
| 449 return new RegistryTestHarness(HKEY_CURRENT_USER, POLICY_SCOPE_USER); | 453 return new RegistryTestHarness(HKEY_CURRENT_USER, POLICY_SCOPE_USER); |
| 450 } | 454 } |
| 451 | 455 |
| 452 // static | 456 // static |
| 453 PolicyProviderTestHarness* RegistryTestHarness::CreateHKLM() { | 457 PolicyProviderTestHarness* RegistryTestHarness::CreateHKLM() { |
| 454 return new RegistryTestHarness(HKEY_LOCAL_MACHINE, POLICY_SCOPE_MACHINE); | 458 return new RegistryTestHarness(HKEY_LOCAL_MACHINE, POLICY_SCOPE_MACHINE); |
| 455 } | 459 } |
| 456 | 460 |
| 457 PRegTestHarness::PRegTestHarness() | 461 PRegTestHarness::PRegTestHarness() |
| 458 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE) {} | 462 : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 463 POLICY_SOURCE_PLATFORM) { |
| 464 } |
| 459 | 465 |
| 460 PRegTestHarness::~PRegTestHarness() {} | 466 PRegTestHarness::~PRegTestHarness() {} |
| 461 | 467 |
| 462 void PRegTestHarness::SetUp() { | 468 void PRegTestHarness::SetUp() { |
| 463 base::win::SetDomainStateForTesting(false); | 469 base::win::SetDomainStateForTesting(false); |
| 464 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 470 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 465 preg_file_path_ = temp_dir_.path().Append(PolicyLoaderWin::kPRegFileName); | 471 preg_file_path_ = temp_dir_.path().Append(PolicyLoaderWin::kPRegFileName); |
| 466 ASSERT_TRUE(base::WriteFile(preg_file_path_, | 472 ASSERT_TRUE(base::WriteFile(preg_file_path_, |
| 467 preg_parser::kPRegFileHeader, | 473 preg_parser::kPRegFileHeader, |
| 468 arraysize(preg_parser::kPRegFileHeader))); | 474 arraysize(preg_parser::kPRegFileHeader))); |
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1219 PolicyMap& expected_policy = expected.Get(ns); | 1225 PolicyMap& expected_policy = expected.Get(ns); |
| 1220 expected_policy.Set("alternative_browser_path", | 1226 expected_policy.Set("alternative_browser_path", |
| 1221 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1227 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 1222 new base::StringValue("c:\\legacy\\browser.exe"), NULL); | 1228 new base::StringValue("c:\\legacy\\browser.exe"), NULL); |
| 1223 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, | 1229 expected_policy.Set("url_list", POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, |
| 1224 list.DeepCopy(), NULL); | 1230 list.DeepCopy(), NULL); |
| 1225 EXPECT_TRUE(Matches(expected)); | 1231 EXPECT_TRUE(Matches(expected)); |
| 1226 } | 1232 } |
| 1227 | 1233 |
| 1228 } // namespace policy | 1234 } // namespace policy |
| OLD | NEW |