| 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/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 : net_log_(net_log), | 451 : net_log_(net_log), |
| 452 #if defined(ENABLE_EXTENSIONS) | 452 #if defined(ENABLE_EXTENSIONS) |
| 453 extension_event_router_forwarder_(extension_event_router_forwarder), | 453 extension_event_router_forwarder_(extension_event_router_forwarder), |
| 454 #endif | 454 #endif |
| 455 globals_(NULL), | 455 globals_(NULL), |
| 456 is_spdy_disabled_by_policy_(false), | 456 is_spdy_disabled_by_policy_(false), |
| 457 is_quic_allowed_by_policy_(true), | 457 is_quic_allowed_by_policy_(true), |
| 458 creation_time_(base::TimeTicks::Now()), | 458 creation_time_(base::TimeTicks::Now()), |
| 459 weak_factory_(this) { | 459 weak_factory_(this) { |
| 460 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 460 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 461 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 461 negotiate_disable_cname_lookup_.Init( |
| 462 prefs::kDisableAuthNegotiateCnameLookup); | 462 prefs::kDisableAuthNegotiateCnameLookup, local_state, |
| 463 negotiate_enable_port_ = local_state->GetBoolean( | 463 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, |
| 464 prefs::kEnableAuthNegotiatePort); | 464 weak_factory_.GetWeakPtr())); |
| 465 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 465 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = |
| 466 auth_delegate_whitelist_ = local_state->GetString( | 466 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 467 prefs::kAuthNegotiateDelegateWhitelist); | 467 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); |
| 468 negotiate_enable_port_.Init(prefs::kEnableAuthNegotiatePort, local_state, |
| 469 base::Bind(&IOThread::UpdateNegotiateEnablePort, |
| 470 weak_factory_.GetWeakPtr())); |
| 471 negotiate_enable_port_.MoveToThread(io_thread_proxy); |
| 472 auth_server_whitelist_.Init( |
| 473 prefs::kAuthServerWhitelist, local_state, |
| 474 base::Bind(&IOThread::UpdateSecurityManager, weak_factory_.GetWeakPtr())); |
| 475 auth_server_whitelist_.MoveToThread(io_thread_proxy); |
| 476 auth_delegate_whitelist_.Init( |
| 477 prefs::kAuthNegotiateDelegateWhitelist, local_state, |
| 478 base::Bind(&IOThread::UpdateSecurityManager, weak_factory_.GetWeakPtr())); |
| 479 auth_delegate_whitelist_.MoveToThread(io_thread_proxy); |
| 468 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 480 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 469 auth_android_negotiate_account_type_ = | 481 auth_android_negotiate_account_type_.Init( |
| 470 local_state->GetString(prefs::kAuthAndroidNegotiateAccountType); | 482 prefs::kAuthAndroidNegotiateAccountType, local_state, |
| 483 base::Bind(&IOThread::UpdateAndroidAuthNegotiateAccount, |
| 484 weak_factory_.GetWeakPtr())); |
| 485 auth_android_negotiate_account_type_.MoveToThread(io_thread_proxy); |
| 471 pref_proxy_config_tracker_.reset( | 486 pref_proxy_config_tracker_.reset( |
| 472 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 487 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 473 local_state)); | 488 local_state)); |
| 474 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 489 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 475 &system_enable_referrers_, | 490 &system_enable_referrers_, |
| 476 NULL, | 491 NULL, |
| 477 NULL, | 492 NULL, |
| 478 NULL, | 493 NULL, |
| 479 local_state); | 494 local_state); |
| 480 ssl_config_service_manager_.reset( | 495 ssl_config_service_manager_.reset( |
| 481 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 496 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
| 482 | 497 |
| 483 base::Value* dns_client_enabled_default = new base::FundamentalValue( | 498 base::Value* dns_client_enabled_default = new base::FundamentalValue( |
| 484 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); | 499 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
| 485 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, | 500 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, |
| 486 dns_client_enabled_default); | 501 dns_client_enabled_default); |
| 487 chrome_browser_net::LogAsyncDnsPrefSource( | 502 chrome_browser_net::LogAsyncDnsPrefSource( |
| 488 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); | 503 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); |
| 489 | 504 |
| 490 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, | 505 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, |
| 491 local_state, | 506 local_state, |
| 492 base::Bind(&IOThread::UpdateDnsClientEnabled, | 507 base::Bind(&IOThread::UpdateDnsClientEnabled, |
| 493 base::Unretained(this))); | 508 base::Unretained(this))); |
| 494 dns_client_enabled_.MoveToThread( | 509 dns_client_enabled_.MoveToThread(io_thread_proxy); |
| 495 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 496 | 510 |
| 497 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 511 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
| 498 local_state); | 512 local_state); |
| 499 quick_check_enabled_.MoveToThread( | 513 quick_check_enabled_.MoveToThread(io_thread_proxy); |
| 500 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 501 | 514 |
| 502 #if defined(ENABLE_CONFIGURATION_POLICY) | 515 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 503 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 516 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
| 504 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 517 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
| 505 policy::key::kDisableSpdy) != NULL; | 518 policy::key::kDisableSpdy) != NULL; |
| 506 | 519 |
| 507 const base::Value* value = policy_service->GetPolicies( | 520 const base::Value* value = policy_service->GetPolicies( |
| 508 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 521 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 509 std::string())).GetValue(policy::key::kQuicAllowed); | 522 std::string())).GetValue(policy::key::kQuicAllowed); |
| 510 if (value) | 523 if (value) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 724 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 712 // is fixed. | 725 // is fixed. |
| 713 tracked_objects::ScopedTracker tracking_profile10( | 726 tracked_objects::ScopedTracker tracking_profile10( |
| 714 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 727 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 715 "466432 IOThread::InitAsync::CertPolicyEnforcer")); | 728 "466432 IOThread::InitAsync::CertPolicyEnforcer")); |
| 716 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; | 729 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; |
| 717 globals_->cert_policy_enforcer.reset(policy_enforcer); | 730 globals_->cert_policy_enforcer.reset(policy_enforcer); |
| 718 | 731 |
| 719 globals_->ssl_config_service = GetSSLConfigService(); | 732 globals_->ssl_config_service = GetSSLConfigService(); |
| 720 | 733 |
| 721 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 734 CreateDefaultAuthHandlerFactory(); |
| 722 globals_->host_resolver.get())); | |
| 723 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 735 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 724 // For the ProxyScriptFetcher, we use a direct ProxyService. | 736 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 725 globals_->proxy_script_fetcher_proxy_service = | 737 globals_->proxy_script_fetcher_proxy_service = |
| 726 net::ProxyService::CreateDirectWithNetLog(net_log_); | 738 net::ProxyService::CreateDirectWithNetLog(net_log_); |
| 727 // In-memory cookie store. | 739 // In-memory cookie store. |
| 728 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 740 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 729 // is fixed. | 741 // is fixed. |
| 730 tracked_objects::ScopedTracker tracking_profile11( | 742 tracked_objects::ScopedTracker tracking_profile11( |
| 731 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 743 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 732 "466432 IOThread::InitAsync::CreateCookieStore::Start")); | 744 "466432 IOThread::InitAsync::CreateCookieStore::Start")); |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 986 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 975 std::string()); | 987 std::string()); |
| 976 registry->RegisterStringPref( | 988 registry->RegisterStringPref( |
| 977 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); | 989 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); |
| 978 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); | 990 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 979 data_reduction_proxy::RegisterPrefs(registry); | 991 data_reduction_proxy::RegisterPrefs(registry); |
| 980 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); | 992 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); |
| 981 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); | 993 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); |
| 982 } | 994 } |
| 983 | 995 |
| 984 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 996 void IOThread::UpdateSecurityManager() { |
| 985 net::HostResolver* resolver) { | |
| 986 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 997 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; |
| 987 if (!auth_server_whitelist_.empty()) { | 998 std::string server_whitelist = auth_server_whitelist_.GetValue(); |
| 999 if (!server_whitelist.empty()) { |
| 988 auth_filter_default_credentials = | 1000 auth_filter_default_credentials = |
| 989 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | 1001 new net::HttpAuthFilterWhitelist(server_whitelist); |
| 990 } | 1002 } |
| 991 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | 1003 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; |
| 992 if (!auth_delegate_whitelist_.empty()) { | 1004 std::string delegate_whitelist = auth_delegate_whitelist_.GetValue(); |
| 993 auth_filter_delegate = | 1005 if (!delegate_whitelist.empty()) |
| 994 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | 1006 auth_filter_delegate = new net::HttpAuthFilterWhitelist(delegate_whitelist); |
| 995 } | |
| 996 globals_->url_security_manager.reset( | 1007 globals_->url_security_manager.reset( |
| 997 net::URLSecurityManager::Create(auth_filter_default_credentials, | 1008 net::URLSecurityManager::Create(auth_filter_default_credentials, |
| 998 auth_filter_delegate)); | 1009 auth_filter_delegate)); |
| 1010 globals_->http_auth_handler_factory->SetSecurityManager( |
| 1011 globals_->url_security_manager.get()); |
| 1012 } |
| 1013 |
| 1014 void IOThread::UpdateAndroidAuthNegotiateAccount() { |
| 1015 globals_->http_auth_handler_factory->SetAndroidAuthNegotiateAccountType( |
| 1016 auth_android_negotiate_account_type_.GetValue()); |
| 1017 } |
| 1018 |
| 1019 void IOThread::UpdateNegotiateDisableCnameLookup() { |
| 1020 globals_->http_auth_handler_factory->SetNegotiateDisableCnameLookup( |
| 1021 negotiate_disable_cname_lookup_.GetValue()); |
| 1022 } |
| 1023 |
| 1024 void IOThread::UpdateNegotiateEnablePort() { |
| 1025 globals_->http_auth_handler_factory->SetNegotiateEnablePort( |
| 1026 negotiate_enable_port_.GetValue()); |
| 1027 } |
| 1028 |
| 1029 void IOThread::CreateDefaultAuthHandlerFactory() { |
| 999 std::vector<std::string> supported_schemes = base::SplitString( | 1030 std::vector<std::string> supported_schemes = base::SplitString( |
| 1000 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1031 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 1001 | 1032 globals_->http_auth_handler_factory.reset( |
| 1002 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( | 1033 net::HttpAuthHandlerRegistryFactory::Create(supported_schemes, |
| 1003 net::HttpAuthHandlerRegistryFactory::Create( | 1034 globals_->host_resolver.get(), |
| 1004 supported_schemes, globals_->url_security_manager.get(), resolver, | 1035 gssapi_library_name_)); |
| 1005 gssapi_library_name_, auth_android_negotiate_account_type_, | 1036 UpdateSecurityManager(); |
| 1006 negotiate_disable_cname_lookup_, negotiate_enable_port_)); | 1037 UpdateAndroidAuthNegotiateAccount(); |
| 1007 return registry_factory.release(); | 1038 UpdateNegotiateDisableCnameLookup(); |
| 1039 UpdateNegotiateEnablePort(); |
| 1008 } | 1040 } |
| 1009 | 1041 |
| 1010 void IOThread::ClearHostCache() { | 1042 void IOThread::ClearHostCache() { |
| 1011 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1043 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1012 | 1044 |
| 1013 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 1045 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 1014 if (host_cache) | 1046 if (host_cache) |
| 1015 host_cache->clear(); | 1047 host_cache->clear(); |
| 1016 } | 1048 } |
| 1017 | 1049 |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1631 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 1663 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
| 1632 | 1664 |
| 1633 context->set_job_factory( | 1665 context->set_job_factory( |
| 1634 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1666 globals->proxy_script_fetcher_url_request_job_factory.get()); |
| 1635 | 1667 |
| 1636 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1668 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1637 // system URLRequestContext too. There's no reason this should be tied to a | 1669 // system URLRequestContext too. There's no reason this should be tied to a |
| 1638 // profile. | 1670 // profile. |
| 1639 return context; | 1671 return context; |
| 1640 } | 1672 } |
| OLD | NEW |