| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/prefs/browser_prefs.h" | 11 #include "chrome/browser/prefs/browser_prefs.h" |
| 12 #include "chrome/browser/prefs/command_line_pref_store.h" |
| 11 #include "chrome/browser/prefs/pref_service_mock_factory.h" | 13 #include "chrome/browser/prefs/pref_service_mock_factory.h" |
| 12 #include "chrome/browser/prefs/pref_service_syncable.h" | 14 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 13 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 14 #include "components/policy/core/common/external_data_fetcher.h" | 16 #include "components/policy/core/common/external_data_fetcher.h" |
| 15 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 17 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
| 16 #include "components/policy/core/common/policy_map.h" | 18 #include "components/policy/core/common/policy_map.h" |
| 17 #include "components/policy/core/common/policy_service_impl.h" | 19 #include "components/policy/core/common/policy_service_impl.h" |
| 18 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
| 19 #include "components/proxy_config/proxy_config_dictionary.h" | 21 #include "components/proxy_config/proxy_config_dictionary.h" |
| 20 #include "components/proxy_config/proxy_config_pref_names.h" | 22 #include "components/proxy_config/proxy_config_pref_names.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 PolicyServiceImpl::Providers providers; | 92 PolicyServiceImpl::Providers providers; |
| 91 providers.push_back(&provider_); | 93 providers.push_back(&provider_); |
| 92 policy_service_.reset(new PolicyServiceImpl(providers)); | 94 policy_service_.reset(new PolicyServiceImpl(providers)); |
| 93 provider_.Init(); | 95 provider_.Init(); |
| 94 } | 96 } |
| 95 | 97 |
| 96 void TearDown() override { provider_.Shutdown(); } | 98 void TearDown() override { provider_.Shutdown(); } |
| 97 | 99 |
| 98 scoped_ptr<PrefService> CreatePrefService(bool with_managed_policies) { | 100 scoped_ptr<PrefService> CreatePrefService(bool with_managed_policies) { |
| 99 PrefServiceMockFactory factory; | 101 PrefServiceMockFactory factory; |
| 100 factory.SetCommandLine(&command_line_); | 102 factory.set_command_line_prefs(new CommandLinePrefStore(&command_line_)); |
| 101 if (with_managed_policies) | 103 if (with_managed_policies) { |
| 102 factory.SetManagedPolicies(policy_service_.get()); | 104 factory.SetManagedPolicies(policy_service_.get(), |
| 105 g_browser_process->browser_policy_connector()); |
| 106 } |
| 107 |
| 103 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( | 108 scoped_refptr<user_prefs::PrefRegistrySyncable> registry( |
| 104 new user_prefs::PrefRegistrySyncable); | 109 new user_prefs::PrefRegistrySyncable); |
| 105 scoped_ptr<PrefServiceSyncable> prefs = | 110 scoped_ptr<PrefServiceSyncable> prefs = |
| 106 factory.CreateSyncable(registry.get()); | 111 factory.CreateSyncable(registry.get()); |
| 107 chrome::RegisterUserProfilePrefs(registry.get()); | 112 chrome::RegisterUserProfilePrefs(registry.get()); |
| 108 return prefs.Pass(); | 113 return prefs.Pass(); |
| 109 } | 114 } |
| 110 | 115 |
| 111 content::TestBrowserThreadBundle thread_bundle_; | 116 content::TestBrowserThreadBundle thread_bundle_; |
| 112 base::CommandLine command_line_; | 117 base::CommandLine command_line_; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 // Try a second time time with the managed PrefStore in place, the | 231 // Try a second time time with the managed PrefStore in place, the |
| 227 // auto-detect should be overridden. The default pref store must be | 232 // auto-detect should be overridden. The default pref store must be |
| 228 // in place with the appropriate default value for this to work. | 233 // in place with the appropriate default value for this to work. |
| 229 prefs = CreatePrefService(true); | 234 prefs = CreatePrefService(true); |
| 230 ProxyConfigDictionary dict2( | 235 ProxyConfigDictionary dict2( |
| 231 prefs->GetDictionary(proxy_config::prefs::kProxy)); | 236 prefs->GetDictionary(proxy_config::prefs::kProxy)); |
| 232 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); | 237 assertProxyModeWithoutParams(dict2, ProxyPrefs::MODE_DIRECT); |
| 233 } | 238 } |
| 234 | 239 |
| 235 } // namespace policy | 240 } // namespace policy |
| OLD | NEW |