| 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 "chromeos/network/proxy/proxy_config_service_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 13 #include "base/json/json_writer.h" | 13 #include "base/json/json_writer.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 17 #include "base/run_loop.h" | 17 #include "base/run_loop.h" |
| 18 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 19 #include "chrome/browser/chromeos/net/proxy_config_handler.h" | |
| 20 #include "chrome/browser/chromeos/settings/cros_settings.h" | 19 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 21 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 20 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
| 22 #include "chrome/browser/chromeos/ui_proxy_config.h" | |
| 23 #include "chrome/common/pref_names.h" | |
| 24 #include "chromeos/dbus/dbus_thread_manager.h" | 21 #include "chromeos/dbus/dbus_thread_manager.h" |
| 25 #include "chromeos/dbus/shill_profile_client.h" | 22 #include "chromeos/dbus/shill_profile_client.h" |
| 26 #include "chromeos/dbus/shill_service_client.h" | 23 #include "chromeos/dbus/shill_service_client.h" |
| 27 #include "chromeos/network/network_handler.h" | 24 #include "chromeos/network/network_handler.h" |
| 28 #include "chromeos/network/network_profile_handler.h" | 25 #include "chromeos/network/network_profile_handler.h" |
| 29 #include "chromeos/network/network_state.h" | 26 #include "chromeos/network/network_state.h" |
| 30 #include "chromeos/network/network_state_handler.h" | 27 #include "chromeos/network/network_state_handler.h" |
| 31 #include "chromeos/network/onc/onc_utils.h" | 28 #include "chromeos/network/onc/onc_utils.h" |
| 29 #include "chromeos/network/proxy/proxy_config_handler.h" |
| 30 #include "chromeos/network/proxy/ui_proxy_config.h" |
| 32 #include "components/onc/onc_pref_names.h" | 31 #include "components/onc/onc_pref_names.h" |
| 33 #include "components/pref_registry/testing_pref_service_syncable.h" | 32 #include "components/pref_registry/testing_pref_service_syncable.h" |
| 34 #include "components/prefs/testing_pref_service.h" | 33 #include "components/prefs/testing_pref_service.h" |
| 35 #include "components/proxy_config/proxy_config_pref_names.h" | 34 #include "components/proxy_config/proxy_config_pref_names.h" |
| 36 #include "content/public/test/test_browser_thread.h" | 35 #include "content/public/test/test_browser_thread.h" |
| 37 #include "net/proxy/proxy_config.h" | 36 #include "net/proxy/proxy_config.h" |
| 38 #include "net/proxy/proxy_config_service_common_unittest.h" | 37 #include "net/proxy/proxy_config_service_common_unittest.h" |
| 39 #include "testing/gtest/include/gtest/gtest.h" | 38 #include "testing/gtest/include/gtest/gtest.h" |
| 40 #include "third_party/cros_system_api/dbus/service_constants.h" | 39 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 41 | 40 |
| 41 // TODO(stevenjb): Refactor and move this to src/chromeos/network/proxy or |
| 42 // rename. This is really more of an integration test than a unit test at this |
| 43 // point and currently relies on some chrome specific components. |
| 44 |
| 42 using content::BrowserThread; | 45 using content::BrowserThread; |
| 43 | 46 |
| 44 namespace chromeos { | 47 namespace chromeos { |
| 45 | 48 |
| 46 namespace { | 49 namespace { |
| 47 | 50 |
| 48 struct Input { | 51 struct Input { |
| 49 UIProxyConfig::Mode mode; | 52 UIProxyConfig::Mode mode; |
| 50 std::string pac_url; | 53 std::string pac_url; |
| 51 std::string server; | 54 std::string server; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 DBusThreadManager::Initialize(); | 244 DBusThreadManager::Initialize(); |
| 242 NetworkHandler::Initialize(); | 245 NetworkHandler::Initialize(); |
| 243 | 246 |
| 244 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service_.registry()); | 247 PrefProxyConfigTrackerImpl::RegisterPrefs(pref_service_.registry()); |
| 245 ::onc::RegisterPrefs(pref_service_.registry()); | 248 ::onc::RegisterPrefs(pref_service_.registry()); |
| 246 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry()); | 249 PrefProxyConfigTrackerImpl::RegisterProfilePrefs(profile_prefs_.registry()); |
| 247 ::onc::RegisterProfilePrefs(profile_prefs_.registry()); | 250 ::onc::RegisterProfilePrefs(profile_prefs_.registry()); |
| 248 } | 251 } |
| 249 | 252 |
| 250 void SetUpProxyConfigService(PrefService* profile_prefs) { | 253 void SetUpProxyConfigService(PrefService* profile_prefs) { |
| 251 config_service_impl_.reset( | 254 config_service_impl_.reset(new ProxyConfigServiceImpl( |
| 252 new ProxyConfigServiceImpl(profile_prefs, &pref_service_)); | 255 profile_prefs, &pref_service_, |
| 256 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO))); |
| 253 proxy_config_service_ = | 257 proxy_config_service_ = |
| 254 config_service_impl_->CreateTrackingProxyConfigService( | 258 config_service_impl_->CreateTrackingProxyConfigService( |
| 255 std::unique_ptr<net::ProxyConfigService>()); | 259 std::unique_ptr<net::ProxyConfigService>()); |
| 256 | 260 |
| 257 // CreateTrackingProxyConfigService triggers update of initial prefs proxy | 261 // CreateTrackingProxyConfigService triggers update of initial prefs proxy |
| 258 // config by tracker to chrome proxy config service, so flush all pending | 262 // config by tracker to chrome proxy config service, so flush all pending |
| 259 // tasks so that tests start fresh. | 263 // tasks so that tests start fresh. |
| 260 base::RunLoop().RunUntilIdle(); | 264 base::RunLoop().RunUntilIdle(); |
| 261 } | 265 } |
| 262 | 266 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 523 network_configs.release()); | 527 network_configs.release()); |
| 524 | 528 |
| 525 net::ProxyConfig actual_config; | 529 net::ProxyConfig actual_config; |
| 526 SyncGetLatestProxyConfig(&actual_config); | 530 SyncGetLatestProxyConfig(&actual_config); |
| 527 net::ProxyConfig expected_config = | 531 net::ProxyConfig expected_config = |
| 528 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); | 532 net::ProxyConfig::CreateFromCustomPacURL(GURL("http://domain.com/x")); |
| 529 EXPECT_TRUE(expected_config.Equals(actual_config)); | 533 EXPECT_TRUE(expected_config.Equals(actual_config)); |
| 530 } | 534 } |
| 531 | 535 |
| 532 } // namespace chromeos | 536 } // namespace chromeos |
| OLD | NEW |