| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/net/chrome_net_log.h" | 25 #include "chrome/browser/net/chrome_net_log.h" |
| 26 #include "chrome/browser/net/chrome_network_delegate.h" | 26 #include "chrome/browser/net/chrome_network_delegate.h" |
| 27 #include "chrome/browser/net/chrome_url_request_context.h" | 27 #include "chrome/browser/net/chrome_url_request_context.h" |
| 28 #include "chrome/browser/net/connect_interceptor.h" | 28 #include "chrome/browser/net/connect_interceptor.h" |
| 29 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 29 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
| 30 #include "chrome/browser/net/load_time_stats.h" | 30 #include "chrome/browser/net/load_time_stats.h" |
| 31 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 31 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 32 #include "chrome/browser/net/proxy_service_factory.h" | 32 #include "chrome/browser/net/proxy_service_factory.h" |
| 33 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 33 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | 34 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/browser/spdyproxy/http_auth_handler_spdyproxy.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/common/content_client.h" | 39 #include "content/public/common/content_client.h" |
| 39 #include "net/base/cert_verifier.h" | 40 #include "net/base/cert_verifier.h" |
| 40 #include "net/base/default_server_bound_cert_store.h" | 41 #include "net/base/default_server_bound_cert_store.h" |
| 41 #include "net/base/host_cache.h" | 42 #include "net/base/host_cache.h" |
| 42 #include "net/base/host_mapping_rules.h" | 43 #include "net/base/host_mapping_rules.h" |
| 43 #include "net/base/host_resolver.h" | 44 #include "net/base/host_resolver.h" |
| 44 #include "net/base/mapped_host_resolver.h" | 45 #include "net/base/mapped_host_resolver.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 RegisterPrefs(local_state); | 348 RegisterPrefs(local_state); |
| 348 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 349 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 349 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 350 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
| 350 prefs::kDisableAuthNegotiateCnameLookup); | 351 prefs::kDisableAuthNegotiateCnameLookup); |
| 351 negotiate_enable_port_ = local_state->GetBoolean( | 352 negotiate_enable_port_ = local_state->GetBoolean( |
| 352 prefs::kEnableAuthNegotiatePort); | 353 prefs::kEnableAuthNegotiatePort); |
| 353 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 354 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
| 354 auth_delegate_whitelist_ = local_state->GetString( | 355 auth_delegate_whitelist_ = local_state->GetString( |
| 355 prefs::kAuthNegotiateDelegateWhitelist); | 356 prefs::kAuthNegotiateDelegateWhitelist); |
| 356 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 357 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 358 spdyproxy_origin_ = local_state->GetString(prefs::kSpdyProxyOrigin); |
| 357 pref_proxy_config_tracker_.reset( | 359 pref_proxy_config_tracker_.reset( |
| 358 ProxyServiceFactory::CreatePrefProxyConfigTracker(local_state)); | 360 ProxyServiceFactory::CreatePrefProxyConfigTracker(local_state)); |
| 359 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, | 361 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, |
| 360 local_state); | 362 local_state); |
| 361 ssl_config_service_manager_.reset( | 363 ssl_config_service_manager_.reset( |
| 362 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 364 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
| 363 | 365 |
| 364 BrowserThread::SetDelegate(BrowserThread::IO, this); | 366 BrowserThread::SetDelegate(BrowserThread::IO, this); |
| 365 } | 367 } |
| 366 | 368 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 568 |
| 567 delete globals_; | 569 delete globals_; |
| 568 globals_ = NULL; | 570 globals_ = NULL; |
| 569 | 571 |
| 570 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 572 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 571 } | 573 } |
| 572 | 574 |
| 573 // static | 575 // static |
| 574 void IOThread::RegisterPrefs(PrefService* local_state) { | 576 void IOThread::RegisterPrefs(PrefService* local_state) { |
| 575 local_state->RegisterStringPref(prefs::kAuthSchemes, | 577 local_state->RegisterStringPref(prefs::kAuthSchemes, |
| 576 "basic,digest,ntlm,negotiate"); | 578 "basic,digest,ntlm,negotiate," |
| 579 "spdyproxy"); |
| 577 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, | 580 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, |
| 578 false); | 581 false); |
| 579 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); | 582 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
| 580 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); | 583 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); |
| 581 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); | 584 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); |
| 582 local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); | 585 local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); |
| 586 local_state->RegisterStringPref(prefs::kSpdyProxyOrigin, ""); |
| 583 local_state->RegisterBooleanPref(prefs::kEnableReferrers, true); | 587 local_state->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 584 } | 588 } |
| 585 | 589 |
| 586 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 590 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( |
| 587 net::HostResolver* resolver) { | 591 net::HostResolver* resolver) { |
| 588 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 592 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; |
| 589 if (!auth_server_whitelist_.empty()) { | 593 if (!auth_server_whitelist_.empty()) { |
| 590 auth_filter_default_credentials = | 594 auth_filter_default_credentials = |
| 591 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | 595 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); |
| 592 } | 596 } |
| 593 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | 597 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; |
| 594 if (!auth_delegate_whitelist_.empty()) { | 598 if (!auth_delegate_whitelist_.empty()) { |
| 595 auth_filter_delegate = | 599 auth_filter_delegate = |
| 596 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | 600 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); |
| 597 } | 601 } |
| 598 globals_->url_security_manager.reset( | 602 globals_->url_security_manager.reset( |
| 599 net::URLSecurityManager::Create(auth_filter_default_credentials, | 603 net::URLSecurityManager::Create(auth_filter_default_credentials, |
| 600 auth_filter_delegate)); | 604 auth_filter_delegate)); |
| 601 std::vector<std::string> supported_schemes; | 605 std::vector<std::string> supported_schemes; |
| 602 base::SplitString(auth_schemes_, ',', &supported_schemes); | 606 base::SplitString(auth_schemes_, ',', &supported_schemes); |
| 603 | 607 |
| 604 return net::HttpAuthHandlerRegistryFactory::Create( | 608 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( |
| 605 supported_schemes, | 609 net::HttpAuthHandlerRegistryFactory::Create( |
| 606 globals_->url_security_manager.get(), | 610 supported_schemes, globals_->url_security_manager.get(), |
| 607 resolver, | 611 resolver, gssapi_library_name_, negotiate_disable_cname_lookup_, |
| 608 gssapi_library_name_, | 612 negotiate_enable_port_)); |
| 609 negotiate_disable_cname_lookup_, | 613 |
| 610 negotiate_enable_port_); | 614 if (!spdyproxy_origin_.empty()) { |
| 615 GURL origin_url(spdyproxy_origin_); |
| 616 if (origin_url.is_valid()) { |
| 617 registry_factory->RegisterSchemeFactory( |
| 618 "spdyproxy", |
| 619 new spdyproxy::HttpAuthHandlerSpdyProxy::Factory(origin_url)); |
| 620 } else { |
| 621 LOG(WARNING) << "Skipping creation of SpdyProxy auth handler since " |
| 622 << "authorized origin is invalid: " |
| 623 << spdyproxy_origin_; |
| 624 } |
| 625 } |
| 626 |
| 627 return registry_factory.release(); |
| 611 } | 628 } |
| 612 | 629 |
| 613 void IOThread::ClearHostCache() { | 630 void IOThread::ClearHostCache() { |
| 614 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 631 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 615 | 632 |
| 616 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 633 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 617 if (host_cache) | 634 if (host_cache) |
| 618 host_cache->clear(); | 635 host_cache->clear(); |
| 619 } | 636 } |
| 620 | 637 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 new net::HttpNetworkLayer( | 709 new net::HttpNetworkLayer( |
| 693 new net::HttpNetworkSession(system_params))); | 710 new net::HttpNetworkSession(system_params))); |
| 694 globals_->system_ftp_transaction_factory.reset( | 711 globals_->system_ftp_transaction_factory.reset( |
| 695 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 712 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 696 globals_->system_request_context.reset( | 713 globals_->system_request_context.reset( |
| 697 ConstructSystemRequestContext(globals_, net_log_)); | 714 ConstructSystemRequestContext(globals_, net_log_)); |
| 698 | 715 |
| 699 sdch_manager_->set_sdch_fetcher( | 716 sdch_manager_->set_sdch_fetcher( |
| 700 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 717 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 701 } | 718 } |
| OLD | NEW |