| 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 "chrome/browser/chromeos/proxy_config_service_impl.h" | 5 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 chromeos::proxy_config::RegisterPrefs(pref_service_.registry()); | 242 chromeos::proxy_config::RegisterPrefs(pref_service_.registry()); |
| 243 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry()); | 243 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry()); |
| 244 chromeos::proxy_config::RegisterProfilePrefs(profile_prefs_.registry()); | 244 chromeos::proxy_config::RegisterProfilePrefs(profile_prefs_.registry()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void SetUpProxyConfigService(PrefService* profile_prefs) { | 247 void SetUpProxyConfigService(PrefService* profile_prefs) { |
| 248 config_service_impl_.reset( | 248 config_service_impl_.reset( |
| 249 new ProxyConfigServiceImpl(profile_prefs, &pref_service_)); | 249 new ProxyConfigServiceImpl(profile_prefs, &pref_service_)); |
| 250 proxy_config_service_ = | 250 proxy_config_service_ = |
| 251 config_service_impl_->CreateTrackingProxyConfigService( | 251 config_service_impl_->CreateTrackingProxyConfigService( |
| 252 scoped_ptr<net::ProxyConfigService>()); | 252 std::unique_ptr<net::ProxyConfigService>()); |
| 253 | 253 |
| 254 // CreateTrackingProxyConfigService triggers update of initial prefs proxy | 254 // CreateTrackingProxyConfigService triggers update of initial prefs proxy |
| 255 // config by tracker to chrome proxy config service, so flush all pending | 255 // config by tracker to chrome proxy config service, so flush all pending |
| 256 // tasks so that tests start fresh. | 256 // tasks so that tests start fresh. |
| 257 loop_.RunUntilIdle(); | 257 loop_.RunUntilIdle(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 void SetUpPrivateWiFi() { | 260 void SetUpPrivateWiFi() { |
| 261 ShillProfileClient::TestInterface* profile_test = | 261 ShillProfileClient::TestInterface* profile_test = |
| 262 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); | 262 DBusThreadManager::Get()->GetShillProfileClient()->GetTestInterface(); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 config_service_impl_->DetachFromPrefService(); | 306 config_service_impl_->DetachFromPrefService(); |
| 307 loop_.RunUntilIdle(); | 307 loop_.RunUntilIdle(); |
| 308 config_service_impl_.reset(); | 308 config_service_impl_.reset(); |
| 309 proxy_config_service_.reset(); | 309 proxy_config_service_.reset(); |
| 310 NetworkHandler::Shutdown(); | 310 NetworkHandler::Shutdown(); |
| 311 DBusThreadManager::Shutdown(); | 311 DBusThreadManager::Shutdown(); |
| 312 } | 312 } |
| 313 | 313 |
| 314 void InitConfigWithTestInput(const Input& input, | 314 void InitConfigWithTestInput(const Input& input, |
| 315 base::DictionaryValue* result) { | 315 base::DictionaryValue* result) { |
| 316 scoped_ptr<base::DictionaryValue> new_config; | 316 std::unique_ptr<base::DictionaryValue> new_config; |
| 317 switch (input.mode) { | 317 switch (input.mode) { |
| 318 case MK_MODE(DIRECT): | 318 case MK_MODE(DIRECT): |
| 319 new_config.reset(ProxyConfigDictionary::CreateDirect()); | 319 new_config.reset(ProxyConfigDictionary::CreateDirect()); |
| 320 break; | 320 break; |
| 321 case MK_MODE(AUTO_DETECT): | 321 case MK_MODE(AUTO_DETECT): |
| 322 new_config.reset(ProxyConfigDictionary::CreateAutoDetect()); | 322 new_config.reset(ProxyConfigDictionary::CreateAutoDetect()); |
| 323 break; | 323 break; |
| 324 case MK_MODE(PAC_SCRIPT): | 324 case MK_MODE(PAC_SCRIPT): |
| 325 new_config.reset( | 325 new_config.reset( |
| 326 ProxyConfigDictionary::CreatePacScript(input.pac_url, false)); | 326 ProxyConfigDictionary::CreatePacScript(input.pac_url, false)); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 356 // ChromeProxyConfigService::UpdateProxyConfig, which is posted on IO from | 356 // ChromeProxyConfigService::UpdateProxyConfig, which is posted on IO from |
| 357 // PrefProxyConfigTrackerImpl::OnProxyConfigChanged. | 357 // PrefProxyConfigTrackerImpl::OnProxyConfigChanged. |
| 358 loop_.RunUntilIdle(); | 358 loop_.RunUntilIdle(); |
| 359 net::ProxyConfigService::ConfigAvailability availability = | 359 net::ProxyConfigService::ConfigAvailability availability = |
| 360 proxy_config_service_->GetLatestProxyConfig(config); | 360 proxy_config_service_->GetLatestProxyConfig(config); |
| 361 | 361 |
| 362 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, availability); | 362 EXPECT_EQ(net::ProxyConfigService::CONFIG_VALID, availability); |
| 363 } | 363 } |
| 364 | 364 |
| 365 base::MessageLoop loop_; | 365 base::MessageLoop loop_; |
| 366 scoped_ptr<net::ProxyConfigService> proxy_config_service_; | 366 std::unique_ptr<net::ProxyConfigService> proxy_config_service_; |
| 367 scoped_ptr<ProxyConfigServiceImpl> config_service_impl_; | 367 std::unique_ptr<ProxyConfigServiceImpl> config_service_impl_; |
| 368 TestingPrefServiceSimple pref_service_; | 368 TestingPrefServiceSimple pref_service_; |
| 369 user_prefs::TestingPrefServiceSyncable profile_prefs_; | 369 user_prefs::TestingPrefServiceSyncable profile_prefs_; |
| 370 | 370 |
| 371 private: | 371 private: |
| 372 ScopedTestDeviceSettingsService test_device_settings_service_; | 372 ScopedTestDeviceSettingsService test_device_settings_service_; |
| 373 ScopedTestCrosSettings test_cros_settings_; | 373 ScopedTestCrosSettings test_cros_settings_; |
| 374 content::TestBrowserThread ui_thread_; | 374 content::TestBrowserThread ui_thread_; |
| 375 content::TestBrowserThread io_thread_; | 375 content::TestBrowserThread io_thread_; |
| 376 }; | 376 }; |
| 377 | 377 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 501 } | 501 } |
| 502 } | 502 } |
| 503 | 503 |
| 504 // Tests whether the proxy settings from user policy are used for ethernet even | 504 // Tests whether the proxy settings from user policy are used for ethernet even |
| 505 // if 'UseSharedProxies' is set to false. | 505 // if 'UseSharedProxies' is set to false. |
| 506 // See https://crbug.com/454966 . | 506 // See https://crbug.com/454966 . |
| 507 TEST_F(ProxyConfigServiceImplTest, SharedEthernetAndUserPolicy) { | 507 TEST_F(ProxyConfigServiceImplTest, SharedEthernetAndUserPolicy) { |
| 508 SetUpSharedEthernet(); | 508 SetUpSharedEthernet(); |
| 509 SetUpProxyConfigService(&profile_prefs_); | 509 SetUpProxyConfigService(&profile_prefs_); |
| 510 | 510 |
| 511 scoped_ptr<base::DictionaryValue> ethernet_policy( | 511 std::unique_ptr<base::DictionaryValue> ethernet_policy( |
| 512 chromeos::onc::ReadDictionaryFromJson(kEthernetPolicy)); | 512 chromeos::onc::ReadDictionaryFromJson(kEthernetPolicy)); |
| 513 | 513 |
| 514 scoped_ptr<base::ListValue> network_configs(new base::ListValue); | 514 std::unique_ptr<base::ListValue> network_configs(new base::ListValue); |
| 515 network_configs->Append(ethernet_policy.release()); | 515 network_configs->Append(ethernet_policy.release()); |
| 516 | 516 |
| 517 profile_prefs_.SetUserPref(prefs::kUseSharedProxies, | 517 profile_prefs_.SetUserPref(prefs::kUseSharedProxies, |
| 518 new base::FundamentalValue(false)); | 518 new base::FundamentalValue(false)); |
| 519 profile_prefs_.SetManagedPref(prefs::kOpenNetworkConfiguration, | 519 profile_prefs_.SetManagedPref(prefs::kOpenNetworkConfiguration, |
| 520 network_configs.release()); | 520 network_configs.release()); |
| 521 | 521 |
| 522 net::ProxyConfig actual_config; | 522 net::ProxyConfig actual_config; |
| 523 SyncGetLatestProxyConfig(&actual_config); | 523 SyncGetLatestProxyConfig(&actual_config); |
| 524 net::ProxyConfig expected_config = | 524 net::ProxyConfig expected_config = |
| 525 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); | 525 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); |
| 526 EXPECT_TRUE(expected_config.Equals(actual_config)); | 526 EXPECT_TRUE(expected_config.Equals(actual_config)); |
| 527 } | 527 } |
| 528 | 528 |
| 529 } // namespace chromeos | 529 } // namespace chromeos |
| OLD | NEW |