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::UpdateServerWhitelist, weak_factory_.GetWeakPtr())); | |
475 auth_server_whitelist_.MoveToThread(io_thread_proxy); | |
476 auth_delegate_whitelist_.Init(prefs::kAuthNegotiateDelegateWhitelist, | |
477 local_state, | |
478 base::Bind(&IOThread::UpdateDelegateWhitelist, | |
479 weak_factory_.GetWeakPtr())); | |
480 auth_delegate_whitelist_.MoveToThread(io_thread_proxy); | |
468 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 481 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
469 auth_android_negotiate_account_type_ = | 482 auth_android_negotiate_account_type_.Init( |
asanka
2015/10/28 03:27:43
Can we condition out the Android code?
aberent
2015/11/02 18:52:50
Not sure about this; should we also condition out
| |
470 local_state->GetString(prefs::kAuthAndroidNegotiateAccountType); | 483 prefs::kAuthAndroidNegotiateAccountType, local_state, |
484 base::Bind(&IOThread::UpdateAndroidAuthNegotiateAccount, | |
485 weak_factory_.GetWeakPtr())); | |
486 auth_android_negotiate_account_type_.MoveToThread(io_thread_proxy); | |
471 pref_proxy_config_tracker_.reset( | 487 pref_proxy_config_tracker_.reset( |
472 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 488 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
473 local_state)); | 489 local_state)); |
474 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 490 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
475 &system_enable_referrers_, | 491 &system_enable_referrers_, |
476 NULL, | 492 NULL, |
477 NULL, | 493 NULL, |
478 NULL, | 494 NULL, |
479 local_state); | 495 local_state); |
480 ssl_config_service_manager_.reset( | 496 ssl_config_service_manager_.reset( |
481 ssl_config::SSLConfigServiceManager::CreateDefaultManager( | 497 ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
482 local_state, | 498 local_state, |
483 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 499 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
484 | 500 |
485 base::Value* dns_client_enabled_default = new base::FundamentalValue( | 501 base::Value* dns_client_enabled_default = new base::FundamentalValue( |
486 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); | 502 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
487 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, | 503 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, |
488 dns_client_enabled_default); | 504 dns_client_enabled_default); |
489 chrome_browser_net::LogAsyncDnsPrefSource( | 505 chrome_browser_net::LogAsyncDnsPrefSource( |
490 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); | 506 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); |
491 | 507 |
492 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, | 508 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, |
493 local_state, | 509 local_state, |
494 base::Bind(&IOThread::UpdateDnsClientEnabled, | 510 base::Bind(&IOThread::UpdateDnsClientEnabled, |
495 base::Unretained(this))); | 511 base::Unretained(this))); |
496 dns_client_enabled_.MoveToThread( | 512 dns_client_enabled_.MoveToThread(io_thread_proxy); |
497 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
498 | 513 |
499 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 514 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
500 local_state); | 515 local_state); |
501 quick_check_enabled_.MoveToThread( | 516 quick_check_enabled_.MoveToThread(io_thread_proxy); |
502 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
503 | 517 |
504 #if defined(ENABLE_CONFIGURATION_POLICY) | 518 #if defined(ENABLE_CONFIGURATION_POLICY) |
505 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 519 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
506 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 520 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
507 policy::key::kDisableSpdy) != NULL; | 521 policy::key::kDisableSpdy) != NULL; |
508 | 522 |
509 const base::Value* value = policy_service->GetPolicies( | 523 const base::Value* value = policy_service->GetPolicies( |
510 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 524 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
511 std::string())).GetValue(policy::key::kQuicAllowed); | 525 std::string())).GetValue(policy::key::kQuicAllowed); |
512 if (value) | 526 if (value) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
713 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 727 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
714 // is fixed. | 728 // is fixed. |
715 tracked_objects::ScopedTracker tracking_profile10( | 729 tracked_objects::ScopedTracker tracking_profile10( |
716 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 730 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
717 "466432 IOThread::InitAsync::CertPolicyEnforcer")); | 731 "466432 IOThread::InitAsync::CertPolicyEnforcer")); |
718 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; | 732 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; |
719 globals_->cert_policy_enforcer.reset(policy_enforcer); | 733 globals_->cert_policy_enforcer.reset(policy_enforcer); |
720 | 734 |
721 globals_->ssl_config_service = GetSSLConfigService(); | 735 globals_->ssl_config_service = GetSSLConfigService(); |
722 | 736 |
723 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 737 CreateDefaultAuthHandlerFactory(); |
724 globals_->host_resolver.get())); | |
725 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 738 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
726 // For the ProxyScriptFetcher, we use a direct ProxyService. | 739 // For the ProxyScriptFetcher, we use a direct ProxyService. |
727 globals_->proxy_script_fetcher_proxy_service = | 740 globals_->proxy_script_fetcher_proxy_service = |
728 net::ProxyService::CreateDirectWithNetLog(net_log_); | 741 net::ProxyService::CreateDirectWithNetLog(net_log_); |
729 // In-memory cookie store. | 742 // In-memory cookie store. |
730 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 743 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
731 // is fixed. | 744 // is fixed. |
732 tracked_objects::ScopedTracker tracking_profile11( | 745 tracked_objects::ScopedTracker tracking_profile11( |
733 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 746 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
734 "466432 IOThread::InitAsync::CreateCookieStore::Start")); | 747 "466432 IOThread::InitAsync::CreateCookieStore::Start")); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 989 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
977 std::string()); | 990 std::string()); |
978 registry->RegisterStringPref( | 991 registry->RegisterStringPref( |
979 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); | 992 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); |
980 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); | 993 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
981 data_reduction_proxy::RegisterPrefs(registry); | 994 data_reduction_proxy::RegisterPrefs(registry); |
982 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); | 995 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); |
983 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); | 996 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); |
984 } | 997 } |
985 | 998 |
986 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 999 void IOThread::UpdateServerWhitelist() { |
987 net::HostResolver* resolver) { | 1000 std::string server_whitelist = auth_server_whitelist_.GetValue(); |
988 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 1001 if (!server_whitelist.empty()) { |
asanka
2015/10/28 03:27:43
It should be possible to set the whitelist to an e
aberent
2015/11/02 18:52:50
Done.
| |
989 if (!auth_server_whitelist_.empty()) { | 1002 globals_->url_security_manager->SetDefaultWhitelist( |
990 auth_filter_default_credentials = | 1003 new net::HttpAuthFilterWhitelist(server_whitelist)); |
asanka
2015/10/28 03:27:43
Let's use scoped_ptrs<> to transfer ownership like
aberent
2015/11/02 18:52:50
Done.
| |
991 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | |
992 } | 1004 } |
993 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | 1005 } |
994 if (!auth_delegate_whitelist_.empty()) { | 1006 |
995 auth_filter_delegate = | 1007 void IOThread::UpdateDelegateWhitelist() { |
996 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | 1008 std::string delegate_whitelist = auth_delegate_whitelist_.GetValue(); |
1009 if (!delegate_whitelist.empty()) { | |
asanka
2015/10/28 03:27:43
Ditto. It's valid to set the whitelist to an empty
aberent
2015/11/02 18:52:50
Done.
| |
1010 globals_->url_security_manager->SetDelegateWhitelist( | |
1011 new net::HttpAuthFilterWhitelist(delegate_whitelist)); | |
997 } | 1012 } |
998 globals_->url_security_manager.reset( | 1013 } |
999 net::URLSecurityManager::Create(auth_filter_default_credentials, | 1014 |
1000 auth_filter_delegate)); | 1015 void IOThread::UpdateAndroidAuthNegotiateAccount() { |
1016 globals_->http_auth_handler_factory->SetAndroidAuthNegotiateAccountType( | |
1017 make_scoped_ptr( | |
1018 new std::string(auth_android_negotiate_account_type_.GetValue()))); | |
1019 } | |
1020 | |
1021 void IOThread::UpdateNegotiateDisableCnameLookup() { | |
1022 globals_->http_auth_handler_factory->SetNegotiateDisableCnameLookup( | |
1023 negotiate_disable_cname_lookup_.GetValue()); | |
1024 } | |
1025 | |
1026 void IOThread::UpdateNegotiateEnablePort() { | |
1027 globals_->http_auth_handler_factory->SetNegotiateEnablePort( | |
1028 negotiate_enable_port_.GetValue()); | |
1029 } | |
1030 | |
1031 void IOThread::CreateDefaultAuthHandlerFactory() { | |
1001 std::vector<std::string> supported_schemes = base::SplitString( | 1032 std::vector<std::string> supported_schemes = base::SplitString( |
1002 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1033 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
asanka
2015/10/28 03:27:43
Pre-existing, but change this to specify base::SPL
aberent
2015/11/02 18:52:50
Done.
| |
1003 | 1034 globals_->http_auth_handler_factory.reset( |
1004 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( | 1035 net::HttpAuthHandlerRegistryFactory::Create(supported_schemes, |
1005 net::HttpAuthHandlerRegistryFactory::Create( | 1036 globals_->host_resolver.get(), |
1006 supported_schemes, globals_->url_security_manager.get(), resolver, | 1037 gssapi_library_name_)); |
1007 gssapi_library_name_, auth_android_negotiate_account_type_, | 1038 globals_->url_security_manager.reset( |
1008 negotiate_disable_cname_lookup_, negotiate_enable_port_)); | 1039 net::URLSecurityManager::Create(nullptr, nullptr)); |
1009 return registry_factory.release(); | 1040 UpdateServerWhitelist(); |
1041 UpdateDelegateWhitelist(); | |
1042 globals_->http_auth_handler_factory->SetSecurityManager( | |
asanka
2015/10/28 03:27:43
Let's move this up so that the Update*s are all in
aberent
2015/11/02 18:52:50
Actually no longer applies, since now moved back i
| |
1043 globals_->url_security_manager.get()); | |
1044 UpdateAndroidAuthNegotiateAccount(); | |
1045 UpdateNegotiateDisableCnameLookup(); | |
1046 UpdateNegotiateEnablePort(); | |
1010 } | 1047 } |
1011 | 1048 |
1012 void IOThread::ClearHostCache() { | 1049 void IOThread::ClearHostCache() { |
1013 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1050 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
1014 | 1051 |
1015 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 1052 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
1016 if (host_cache) | 1053 if (host_cache) |
1017 host_cache->clear(); | 1054 host_cache->clear(); |
1018 } | 1055 } |
1019 | 1056 |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 1667 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
1631 | 1668 |
1632 context->set_job_factory( | 1669 context->set_job_factory( |
1633 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1670 globals->proxy_script_fetcher_url_request_job_factory.get()); |
1634 | 1671 |
1635 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1672 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
1636 // system URLRequestContext too. There's no reason this should be tied to a | 1673 // system URLRequestContext too. There's no reason this should be tied to a |
1637 // profile. | 1674 // profile. |
1638 return context; | 1675 return context; |
1639 } | 1676 } |
OLD | NEW |