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/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" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 syncable_prefs::PrefServiceMockFactory factory; |
107 factory.set_command_line_prefs(new CommandLinePrefStore(&command_line_)); | 107 factory.set_command_line_prefs( |
| 108 new ChromeCommandLinePrefStore(&command_line_)); |
108 if (with_managed_policies) { | 109 if (with_managed_policies) { |
109 factory.SetManagedPolicies(policy_service_.get(), | 110 factory.SetManagedPolicies(policy_service_.get(), |
110 g_browser_process->browser_policy_connector()); | 111 g_browser_process->browser_policy_connector()); |
111 } | 112 } |
112 | 113 |
113 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 114 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
114 new user_prefs::PrefRegistrySyncable); | 115 new user_prefs::PrefRegistrySyncable); |
115 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs = | 116 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs = |
116 factory.CreateSyncable(registry.get()); | 117 factory.CreateSyncable(registry.get()); |
117 chrome::RegisterUserProfilePrefs(registry.get()); | 118 chrome::RegisterUserProfilePrefs(registry.get()); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 // 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 |
233 // auto-detect should be overridden. The default pref store must be | 234 // auto-detect should be overridden. The default pref store must be |
234 // in place with the appropriate default value for this to work. | 235 // in place with the appropriate default value for this to work. |
235 prefs = CreatePrefService(true); | 236 prefs = CreatePrefService(true); |
236 ProxyConfigDictionary dict2( | 237 ProxyConfigDictionary dict2( |
237 prefs->GetDictionary(proxy_config::prefs::kProxy)); | 238 prefs->GetDictionary(proxy_config::prefs::kProxy)); |
238 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); | 239 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); |
239 } | 240 } |
240 | 241 |
241 } // namespace policy | 242 } // namespace policy |
OLD | NEW |