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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/prefs/browser_prefs.h" | 15 #include "chrome/browser/prefs/browser_prefs.h" |
16 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" | 16 #include "chrome/browser/prefs/chrome_command_line_pref_store.h" |
17 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
18 #include "components/policy/core/common/external_data_fetcher.h" | 18 #include "components/policy/core/common/external_data_fetcher.h" |
19 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 19 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
20 #include "components/policy/core/common/policy_map.h" | 20 #include "components/policy/core/common/policy_map.h" |
21 #include "components/policy/core/common/policy_service_impl.h" | 21 #include "components/policy/core/common/policy_service_impl.h" |
22 #include "components/policy/core/common/policy_types.h" | 22 #include "components/policy/core/common/policy_types.h" |
23 #include "components/policy/policy_constants.h" | 23 #include "components/policy/policy_constants.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "components/proxy_config/proxy_config_dictionary.h" | 25 #include "components/proxy_config/proxy_config_dictionary.h" |
26 #include "components/proxy_config/proxy_config_pref_names.h" | 26 #include "components/proxy_config/proxy_config_pref_names.h" |
27 #include "components/syncable_prefs/pref_service_mock_factory.h" | 27 #include "components/sync_preferences/pref_service_mock_factory.h" |
28 #include "components/syncable_prefs/pref_service_syncable.h" | 28 #include "components/sync_preferences/pref_service_syncable.h" |
29 #include "content/public/test/test_browser_thread_bundle.h" | 29 #include "content/public/test/test_browser_thread_bundle.h" |
30 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
31 | 31 |
32 using ::testing::Return; | 32 using ::testing::Return; |
33 using ::testing::_; | 33 using ::testing::_; |
34 | 34 |
35 namespace policy { | 35 namespace policy { |
36 | 36 |
37 namespace { | 37 namespace { |
38 | 38 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 | 96 |
97 PolicyServiceImpl::Providers providers; | 97 PolicyServiceImpl::Providers providers; |
98 providers.push_back(&provider_); | 98 providers.push_back(&provider_); |
99 policy_service_.reset(new PolicyServiceImpl(providers)); | 99 policy_service_.reset(new PolicyServiceImpl(providers)); |
100 provider_.Init(); | 100 provider_.Init(); |
101 } | 101 } |
102 | 102 |
103 void TearDown() override { provider_.Shutdown(); } | 103 void TearDown() override { provider_.Shutdown(); } |
104 | 104 |
105 std::unique_ptr<PrefService> CreatePrefService(bool with_managed_policies) { | 105 std::unique_ptr<PrefService> CreatePrefService(bool with_managed_policies) { |
106 syncable_prefs::PrefServiceMockFactory factory; | 106 sync_preferences::PrefServiceMockFactory factory; |
107 factory.set_command_line_prefs( | 107 factory.set_command_line_prefs( |
108 new ChromeCommandLinePrefStore(&command_line_)); | 108 new ChromeCommandLinePrefStore(&command_line_)); |
109 if (with_managed_policies) { | 109 if (with_managed_policies) { |
110 factory.SetManagedPolicies(policy_service_.get(), | 110 factory.SetManagedPolicies(policy_service_.get(), |
111 g_browser_process->browser_policy_connector()); | 111 g_browser_process->browser_policy_connector()); |
112 } | 112 } |
113 | 113 |
114 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 114 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
115 new user_prefs::PrefRegistrySyncable); | 115 new user_prefs::PrefRegistrySyncable); |
116 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs = | 116 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs = |
117 factory.CreateSyncable(registry.get()); | 117 factory.CreateSyncable(registry.get()); |
118 chrome::RegisterUserProfilePrefs(registry.get()); | 118 chrome::RegisterUserProfilePrefs(registry.get()); |
119 return std::move(prefs); | 119 return std::move(prefs); |
120 } | 120 } |
121 | 121 |
122 content::TestBrowserThreadBundle thread_bundle_; | 122 content::TestBrowserThreadBundle thread_bundle_; |
123 base::CommandLine command_line_; | 123 base::CommandLine command_line_; |
124 MockConfigurationPolicyProvider provider_; | 124 MockConfigurationPolicyProvider provider_; |
125 std::unique_ptr<PolicyServiceImpl> policy_service_; | 125 std::unique_ptr<PolicyServiceImpl> policy_service_; |
126 }; | 126 }; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Try a second time time with the managed PrefStore in place, the | 233 // Try a second time time with the managed PrefStore in place, the |
234 // auto-detect should be overridden. The default pref store must be | 234 // auto-detect should be overridden. The default pref store must be |
235 // in place with the appropriate default value for this to work. | 235 // in place with the appropriate default value for this to work. |
236 prefs = CreatePrefService(true); | 236 prefs = CreatePrefService(true); |
237 ProxyConfigDictionary dict2( | 237 ProxyConfigDictionary dict2( |
238 prefs->GetDictionary(proxy_config::prefs::kProxy)); | 238 prefs->GetDictionary(proxy_config::prefs::kProxy)); |
239 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); | 239 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); |
240 } | 240 } |
241 | 241 |
242 } // namespace policy | 242 } // namespace policy |
OLD | NEW |