Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: chrome/browser/profiles/profile_io_data.cc

Issue 2986623002: Revert of Make ProfileIOData use URLRequestContextBuilder (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/profiles/profile_io_data.h" 5 #include "chrome/browser/profiles/profile_io_data.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 #include "net/ssl/channel_id_service.h" 99 #include "net/ssl/channel_id_service.h"
100 #include "net/ssl/client_cert_store.h" 100 #include "net/ssl/client_cert_store.h"
101 #include "net/traffic_annotation/network_traffic_annotation.h" 101 #include "net/traffic_annotation/network_traffic_annotation.h"
102 #include "net/url_request/data_protocol_handler.h" 102 #include "net/url_request/data_protocol_handler.h"
103 #include "net/url_request/file_protocol_handler.h" 103 #include "net/url_request/file_protocol_handler.h"
104 #include "net/url_request/ftp_protocol_handler.h" 104 #include "net/url_request/ftp_protocol_handler.h"
105 #include "net/url_request/report_sender.h" 105 #include "net/url_request/report_sender.h"
106 #include "net/url_request/url_request.h" 106 #include "net/url_request/url_request.h"
107 #include "net/url_request/url_request_context.h" 107 #include "net/url_request/url_request_context.h"
108 #include "net/url_request/url_request_context_builder.h" 108 #include "net/url_request/url_request_context_builder.h"
109 #include "net/url_request/url_request_context_builder_mojo.h"
110 #include "net/url_request/url_request_context_storage.h" 109 #include "net/url_request/url_request_context_storage.h"
111 #include "net/url_request/url_request_file_job.h" 110 #include "net/url_request/url_request_file_job.h"
112 #include "net/url_request/url_request_intercepting_job_factory.h" 111 #include "net/url_request/url_request_intercepting_job_factory.h"
113 #include "net/url_request/url_request_interceptor.h" 112 #include "net/url_request/url_request_interceptor.h"
114 #include "net/url_request/url_request_job_factory_impl.h" 113 #include "net/url_request/url_request_job_factory_impl.h"
115 #include "third_party/WebKit/public/public_features.h" 114 #include "third_party/WebKit/public/public_features.h"
116 115
117 #if BUILDFLAG(ENABLE_EXTENSIONS) 116 #if BUILDFLAG(ENABLE_EXTENSIONS)
118 #include "chrome/browser/extensions/extension_cookie_monster_delegate.h" 117 #include "chrome/browser/extensions/extension_cookie_monster_delegate.h"
119 #include "extensions/browser/extension_protocols.h" 118 #include "extensions/browser/extension_protocols.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // For safe shutdown, must be called before the ProfileIOData is destroyed. 362 // For safe shutdown, must be called before the ProfileIOData is destroyed.
364 void NotifyContextGettersOfShutdownOnIO( 363 void NotifyContextGettersOfShutdownOnIO(
365 std::unique_ptr<ProfileIOData::ChromeURLRequestContextGetterVector> 364 std::unique_ptr<ProfileIOData::ChromeURLRequestContextGetterVector>
366 getters) { 365 getters) {
367 DCHECK_CURRENTLY_ON(BrowserThread::IO); 366 DCHECK_CURRENTLY_ON(BrowserThread::IO);
368 ProfileIOData::ChromeURLRequestContextGetterVector::iterator iter; 367 ProfileIOData::ChromeURLRequestContextGetterVector::iterator iter;
369 for (auto& chrome_context_getter : *getters) 368 for (auto& chrome_context_getter : *getters)
370 chrome_context_getter->NotifyContextShuttingDown(); 369 chrome_context_getter->NotifyContextShuttingDown();
371 } 370 }
372 371
373 // Wraps |inner_job_factory| with |protocol_handler_interceptor|.
374 std::unique_ptr<net::URLRequestJobFactory> CreateURLRequestJobFactory(
375 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
376 protocol_handler_interceptor,
377 std::unique_ptr<net::URLRequestJobFactory> inner_job_factory) {
378 protocol_handler_interceptor->Chain(std::move(inner_job_factory));
379 return std::move(protocol_handler_interceptor);
380 }
381
382 } // namespace 372 } // namespace
383 373
384 void ProfileIOData::InitializeOnUIThread(Profile* profile) { 374 void ProfileIOData::InitializeOnUIThread(Profile* profile) {
385 DCHECK_CURRENTLY_ON(BrowserThread::UI); 375 DCHECK_CURRENTLY_ON(BrowserThread::UI);
386 PrefService* pref_service = profile->GetPrefs(); 376 PrefService* pref_service = profile->GetPrefs();
387 377
388 std::unique_ptr<ProfileParams> params(new ProfileParams); 378 std::unique_ptr<ProfileParams> params(new ProfileParams);
389 params->path = profile->GetPath(); 379 params->path = profile->GetPath();
390 380
391 params->io_thread = g_browser_process->io_thread(); 381 params->io_thread = g_browser_process->io_thread();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // since the former has a reference to the latter. 670 // since the former has a reference to the latter.
681 main_request_context_->transport_security_state()->SetReportSender(nullptr); 671 main_request_context_->transport_security_state()->SetReportSender(nullptr);
682 certificate_report_sender_.reset(); 672 certificate_report_sender_.reset();
683 673
684 main_request_context_->transport_security_state()->SetExpectCTReporter( 674 main_request_context_->transport_security_state()->SetExpectCTReporter(
685 nullptr); 675 nullptr);
686 expect_ct_reporter_.reset(); 676 expect_ct_reporter_.reset();
687 677
688 main_request_context_->transport_security_state()->SetRequireCTDelegate( 678 main_request_context_->transport_security_state()->SetRequireCTDelegate(
689 nullptr); 679 nullptr);
680
681 // And the same for the ReportingService.
682 main_request_context_storage()->set_reporting_service(
683 std::unique_ptr<net::ReportingService>());
684
685 // This should be shut down last, as any other requests may initiate more
686 // activity when the ProxyService aborts lookups.
687 main_request_context_->proxy_service()->OnShutdown();
690 } 688 }
691 689
692 // TODO(ajwong): These AssertNoURLRequests() calls are unnecessary since they 690 // TODO(ajwong): These AssertNoURLRequests() calls are unnecessary since they
693 // are already done in the URLRequestContext destructor. 691 // are already done in the URLRequestContext destructor.
692 if (main_request_context_)
693 main_request_context_->AssertNoURLRequests();
694 if (extensions_request_context_) 694 if (extensions_request_context_)
695 extensions_request_context_->AssertNoURLRequests(); 695 extensions_request_context_->AssertNoURLRequests();
696 696
697 current_context = 0; 697 current_context = 0;
698 for (URLRequestContextMap::iterator it = app_request_context_map_.begin(); 698 for (URLRequestContextMap::iterator it = app_request_context_map_.begin();
699 it != app_request_context_map_.end(); ++it) { 699 it != app_request_context_map_.end(); ++it) {
700 if (current_context < kMaxCachedContexts) { 700 if (current_context < kMaxCachedContexts) {
701 CHECK_EQ(app_context_cache[current_context], it->second); 701 CHECK_EQ(app_context_cache[current_context], it->second);
702 memcpy(&tmp_vtable, static_cast<void*>(it->second), sizeof(void*)); 702 memcpy(&tmp_vtable, static_cast<void*>(it->second), sizeof(void*));
703 CHECK_EQ(app_context_vtable_cache[current_context], tmp_vtable); 703 CHECK_EQ(app_context_vtable_cache[current_context], tmp_vtable);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 for (content::ProtocolHandlerMap::iterator it = 778 for (content::ProtocolHandlerMap::iterator it =
779 protocol_handlers->begin(); 779 protocol_handlers->begin();
780 it != protocol_handlers->end(); 780 it != protocol_handlers->end();
781 ++it) { 781 ++it) {
782 bool set_protocol = job_factory->SetProtocolHandler( 782 bool set_protocol = job_factory->SetProtocolHandler(
783 it->first, base::WrapUnique(it->second.release())); 783 it->first, base::WrapUnique(it->second.release()));
784 DCHECK(set_protocol); 784 DCHECK(set_protocol);
785 } 785 }
786 protocol_handlers->clear(); 786 protocol_handlers->clear();
787 } 787 }
788
789 // static
790 void ProfileIOData::AddProtocolHandlersToBuilder(
791 net::URLRequestContextBuilder* builder,
792 content::ProtocolHandlerMap* protocol_handlers) {
793 for (auto& protocol_handler : *protocol_handlers) {
794 builder->SetProtocolHandler(
795 protocol_handler.first,
796 base::WrapUnique(protocol_handler.second.release()));
797 }
798 protocol_handlers->clear();
799 }
800 788
801 // static 789 // static
802 void ProfileIOData::SetCertVerifierForTesting( 790 void ProfileIOData::SetCertVerifierForTesting(
803 net::CertVerifier* cert_verifier) { 791 net::CertVerifier* cert_verifier) {
804 g_cert_verifier_for_testing = cert_verifier; 792 g_cert_verifier_for_testing = cert_verifier;
805 } 793 }
806 794
807 content::ResourceContext* ProfileIOData::GetResourceContext() const { 795 content::ResourceContext* ProfileIOData::GetResourceContext() const {
808 return resource_context_.get(); 796 return resource_context_.get();
809 } 797 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 #else 938 #else
951 #error Unknown platform. 939 #error Unknown platform.
952 #endif 940 #endif
953 } 941 }
954 942
955 void ProfileIOData::DisableQuicOnIOThread() { 943 void ProfileIOData::DisableQuicOnIOThread() {
956 // If the URLRequestContext has not been created yet, it will not be updated 944 // If the URLRequestContext has not been created yet, it will not be updated
957 // here. Instead, it will inherit its QUIC enablement from IOThread on 945 // here. Instead, it will inherit its QUIC enablement from IOThread on
958 // construction, which is fine, as NetHttpSessionParamsObserver also disables 946 // construction, which is fine, as NetHttpSessionParamsObserver also disables
959 // QUIC there. 947 // QUIC there.
960 if (!main_request_context_) 948 if (!main_request_context_storage_ ||
949 !main_request_context_storage_->http_network_session())
961 return; 950 return;
962 951
963 main_request_context_->http_transaction_factory() 952 main_request_context_storage_->http_network_session()->DisableQuic();
964 ->GetSession()
965 ->DisableQuic();
966 } 953 }
967 954
968 void ProfileIOData::set_data_reduction_proxy_io_data( 955 void ProfileIOData::set_data_reduction_proxy_io_data(
969 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData> 956 std::unique_ptr<data_reduction_proxy::DataReductionProxyIOData>
970 data_reduction_proxy_io_data) const { 957 data_reduction_proxy_io_data) const {
971 data_reduction_proxy_io_data_ = std::move(data_reduction_proxy_io_data); 958 data_reduction_proxy_io_data_ = std::move(data_reduction_proxy_io_data);
972 } 959 }
973 960
974 void ProfileIOData::set_previews_io_data( 961 void ProfileIOData::set_previews_io_data(
975 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const { 962 std::unique_ptr<previews::PreviewsIOData> previews_io_data) const {
(...skipping 26 matching lines...) Expand all
1002 content::URLRequestInterceptorScopedVector request_interceptors) const { 989 content::URLRequestInterceptorScopedVector request_interceptors) const {
1003 // The basic logic is implemented here. The specific initialization 990 // The basic logic is implemented here. The specific initialization
1004 // is done in InitializeInternal(), implemented by subtypes. Static helper 991 // is done in InitializeInternal(), implemented by subtypes. Static helper
1005 // functions have been provided to assist in common operations. 992 // functions have been provided to assist in common operations.
1006 DCHECK_CURRENTLY_ON(BrowserThread::IO); 993 DCHECK_CURRENTLY_ON(BrowserThread::IO);
1007 DCHECK(!initialized_); 994 DCHECK(!initialized_);
1008 DCHECK(profile_params_.get()); 995 DCHECK(profile_params_.get());
1009 996
1010 IOThread* const io_thread = profile_params_->io_thread; 997 IOThread* const io_thread = profile_params_->io_thread;
1011 IOThread::Globals* const io_thread_globals = io_thread->globals(); 998 IOThread::Globals* const io_thread_globals = io_thread->globals();
999 const base::CommandLine& command_line =
1000 *base::CommandLine::ForCurrentProcess();
1012 1001
1013 // Create extension request context. Only used for cookies. 1002 // Create extension request context. Only used for cookies.
1014 extensions_request_context_.reset(new net::URLRequestContext()); 1003 extensions_request_context_.reset(new net::URLRequestContext());
1015 extensions_request_context_->set_name("extensions"); 1004 extensions_request_context_->set_name("extensions");
1016 1005
1017 // Create the main request context. 1006 // Create the main request context.
1018 net::URLRequestContextBuilderMojo builder; 1007 main_request_context_.reset(new net::URLRequestContext());
1019 builder.set_name("main"); 1008 main_request_context_storage_.reset(
1009 new net::URLRequestContextStorage(main_request_context_.get()));
1010 main_request_context_->set_name("main");
1020 1011
1021 builder.set_net_log(io_thread->net_log()); 1012 ApplyProfileParamsToContext(main_request_context_.get());
1022 builder.set_shared_http_user_agent_settings( 1013 main_request_context_->set_net_log(io_thread->net_log());
1023 chrome_http_user_agent_settings_.get());
1024 builder.set_ssl_config_service(profile_params_->ssl_config_service);
1025 1014
1026 builder.set_enable_brotli(io_thread_globals->enable_brotli); 1015 main_request_context_->set_enable_brotli(io_thread_globals->enable_brotli);
1027 1016
1028 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( 1017 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate(
1029 new ChromeNetworkDelegate( 1018 new ChromeNetworkDelegate(
1030 #if BUILDFLAG(ENABLE_EXTENSIONS) 1019 #if BUILDFLAG(ENABLE_EXTENSIONS)
1031 io_thread_globals->extension_event_router_forwarder.get(), 1020 io_thread_globals->extension_event_router_forwarder.get(),
1032 #else 1021 #else
1033 NULL, 1022 NULL,
1034 #endif 1023 #endif
1035 &enable_referrers_)); 1024 &enable_referrers_));
1036 #if BUILDFLAG(ENABLE_EXTENSIONS) 1025 #if BUILDFLAG(ENABLE_EXTENSIONS)
1037 chrome_network_delegate->set_extension_info_map( 1026 chrome_network_delegate->set_extension_info_map(
1038 profile_params_->extension_info_map.get()); 1027 profile_params_->extension_info_map.get());
1039 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 1028 if (!command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) {
1040 switches::kDisableExtensionsHttpThrottling)) {
1041 extension_throttle_manager_.reset( 1029 extension_throttle_manager_.reset(
1042 new extensions::ExtensionThrottleManager()); 1030 new extensions::ExtensionThrottleManager());
1043 } 1031 }
1044 #endif 1032 #endif
1045 1033
1046 chrome_network_delegate->set_url_blacklist_manager( 1034 chrome_network_delegate->set_url_blacklist_manager(
1047 url_blacklist_manager_.get()); 1035 url_blacklist_manager_.get());
1048 chrome_network_delegate->set_profile(profile_params_->profile); 1036 chrome_network_delegate->set_profile(profile_params_->profile);
1049 chrome_network_delegate->set_profile_path(profile_params_->path); 1037 chrome_network_delegate->set_profile_path(profile_params_->path);
1050 chrome_network_delegate->set_cookie_settings( 1038 chrome_network_delegate->set_cookie_settings(
1051 profile_params_->cookie_settings.get()); 1039 profile_params_->cookie_settings.get());
1052 chrome_network_delegate->set_enable_do_not_track(&enable_do_not_track_); 1040 chrome_network_delegate->set_enable_do_not_track(&enable_do_not_track_);
1053 chrome_network_delegate->set_force_google_safe_search( 1041 chrome_network_delegate->set_force_google_safe_search(
1054 &force_google_safesearch_); 1042 &force_google_safesearch_);
1055 chrome_network_delegate->set_force_youtube_restrict(&force_youtube_restrict_); 1043 chrome_network_delegate->set_force_youtube_restrict(&force_youtube_restrict_);
1056 chrome_network_delegate->set_allowed_domains_for_apps( 1044 chrome_network_delegate->set_allowed_domains_for_apps(
1057 &allowed_domains_for_apps_); 1045 &allowed_domains_for_apps_);
1058 chrome_network_delegate->set_data_use_aggregator( 1046 chrome_network_delegate->set_data_use_aggregator(
1059 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord()); 1047 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord());
1060 1048
1061 std::unique_ptr<net::NetworkDelegate> network_delegate = 1049 std::unique_ptr<net::NetworkDelegate> network_delegate =
1062 ConfigureNetworkDelegate(profile_params_->io_thread, 1050 ConfigureNetworkDelegate(profile_params_->io_thread,
1063 std::move(chrome_network_delegate)); 1051 std::move(chrome_network_delegate));
1064 1052
1065 builder.set_shared_host_resolver( 1053 main_request_context_->set_host_resolver(
1066 io_thread_globals->system_request_context->host_resolver()); 1054 io_thread_globals->system_request_context->host_resolver());
1067 1055
1068 builder.set_shared_http_auth_handler_factory( 1056 main_request_context_->set_http_auth_handler_factory(
1069 io_thread_globals->system_request_context->http_auth_handler_factory()); 1057 io_thread_globals->system_request_context->http_auth_handler_factory());
1070 1058
1071 io_thread->SetUpProxyConfigService( 1059 main_request_context_storage_->set_proxy_service(
1072 &builder, std::move(profile_params_->proxy_config_service)); 1060 ProxyServiceFactory::CreateProxyService(
1061 io_thread->net_log(), main_request_context_.get(),
1062 network_delegate.get(),
1063 std::move(profile_params_->proxy_config_service), command_line,
1064 io_thread->WpadQuickCheckEnabled(),
1065 io_thread->PacHttpsUrlStrippingEnabled()));
1073 1066
1074 builder.set_network_delegate(std::move(network_delegate)); 1067 main_request_context_storage_->set_network_delegate(
1068 std::move(network_delegate));
1075 1069
1076 builder.set_transport_security_persister_path(profile_params_->path); 1070 std::unique_ptr<net::TransportSecurityState> transport_security_state(
1077 builder.set_transport_security_persister_readonly(IsOffTheRecord()); 1071 base::MakeUnique<net::TransportSecurityState>());
1072 transport_security_persister_.reset(new net::TransportSecurityPersister(
1073 transport_security_state.get(), profile_params_->path,
1074 base::CreateSequencedTaskRunnerWithTraits(
1075 {base::MayBlock(), base::TaskPriority::BACKGROUND,
1076 base::TaskShutdownBehavior::BLOCK_SHUTDOWN}),
1077 IsOffTheRecord()));
1078 main_request_context_storage_->set_transport_security_state(
1079 std::move(transport_security_state));
1078 1080
1079 // Take ownership over these parameters. 1081 // Take ownership over these parameters.
1080 cookie_settings_ = profile_params_->cookie_settings; 1082 cookie_settings_ = profile_params_->cookie_settings;
1081 host_content_settings_map_ = profile_params_->host_content_settings_map; 1083 host_content_settings_map_ = profile_params_->host_content_settings_map;
1082 #if BUILDFLAG(ENABLE_EXTENSIONS) 1084 #if BUILDFLAG(ENABLE_EXTENSIONS)
1083 extension_info_map_ = profile_params_->extension_info_map; 1085 extension_info_map_ = profile_params_->extension_info_map;
1084 #endif 1086 #endif
1085 1087
1088 resource_context_->host_resolver_ =
1089 io_thread_globals->system_request_context->host_resolver();
1090 resource_context_->request_context_ = main_request_context_.get();
1091
1086 if (profile_params_->loading_predictor_observer_) { 1092 if (profile_params_->loading_predictor_observer_) {
1087 loading_predictor_observer_ = 1093 loading_predictor_observer_ =
1088 std::move(profile_params_->loading_predictor_observer_); 1094 std::move(profile_params_->loading_predictor_observer_);
1089 } 1095 }
1090 1096
1091 #if defined(OS_CHROMEOS) 1097 #if defined(OS_CHROMEOS)
1092 username_hash_ = profile_params_->username_hash; 1098 username_hash_ = profile_params_->username_hash;
1093 use_system_key_slot_ = profile_params_->use_system_key_slot; 1099 use_system_key_slot_ = profile_params_->use_system_key_slot;
1094 if (use_system_key_slot_) 1100 if (use_system_key_slot_)
1095 EnableNSSSystemKeySlotForResourceContext(resource_context_.get()); 1101 EnableNSSSystemKeySlotForResourceContext(resource_context_.get());
1096 1102
1097 certificate_provider_ = std::move(profile_params_->certificate_provider); 1103 certificate_provider_ = std::move(profile_params_->certificate_provider);
1098 #endif 1104 #endif
1099 1105
1100 if (g_cert_verifier_for_testing) { 1106 if (g_cert_verifier_for_testing) {
1101 builder.set_shared_cert_verifier(g_cert_verifier_for_testing); 1107 main_request_context_->set_cert_verifier(g_cert_verifier_for_testing);
1102 } else { 1108 } else {
1103 #if defined(OS_CHROMEOS) 1109 #if defined(OS_CHROMEOS)
1104 crypto::ScopedPK11Slot public_slot = 1110 crypto::ScopedPK11Slot public_slot =
1105 crypto::GetPublicSlotForChromeOSUser(username_hash_); 1111 crypto::GetPublicSlotForChromeOSUser(username_hash_);
1106 // The private slot won't be ready by this point. It shouldn't be necessary 1112 // The private slot won't be ready by this point. It shouldn't be necessary
1107 // for cert trust purposes anyway. 1113 // for cert trust purposes anyway.
1108 scoped_refptr<net::CertVerifyProc> verify_proc( 1114 scoped_refptr<net::CertVerifyProc> verify_proc(
1109 new chromeos::CertVerifyProcChromeOS(std::move(public_slot))); 1115 new chromeos::CertVerifyProcChromeOS(std::move(public_slot)));
1110 if (policy_cert_verifier_) { 1116 if (policy_cert_verifier_) {
1111 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get()); 1117 DCHECK_EQ(policy_cert_verifier_, cert_verifier_.get());
1112 policy_cert_verifier_->InitializeOnIOThread(verify_proc); 1118 policy_cert_verifier_->InitializeOnIOThread(verify_proc);
1113 } else { 1119 } else {
1114 cert_verifier_ = base::MakeUnique<net::CachingCertVerifier>( 1120 cert_verifier_ = base::MakeUnique<net::CachingCertVerifier>(
1115 base::MakeUnique<net::MultiThreadedCertVerifier>(verify_proc.get())); 1121 base::MakeUnique<net::MultiThreadedCertVerifier>(verify_proc.get()));
1116 } 1122 }
1117 builder.set_shared_cert_verifier(cert_verifier_.get()); 1123 main_request_context_->set_cert_verifier(cert_verifier_.get());
1118 #else 1124 #else
1119 builder.set_shared_cert_verifier( 1125 main_request_context_->set_cert_verifier(
1120 io_thread_globals->system_request_context->cert_verifier()); 1126 io_thread_globals->system_request_context->cert_verifier());
1121 #endif 1127 #endif
1122 } 1128 }
1123 1129
1124 // Install the New Tab Page Interceptor. 1130 // Install the New Tab Page Interceptor.
1125 if (profile_params_->new_tab_page_interceptor.get()) { 1131 if (profile_params_->new_tab_page_interceptor.get()) {
1126 request_interceptors.push_back( 1132 request_interceptors.push_back(
1127 std::move(profile_params_->new_tab_page_interceptor)); 1133 std::move(profile_params_->new_tab_page_interceptor));
1128 } 1134 }
1129 1135
1130 std::unique_ptr<net::MultiLogCTVerifier> ct_verifier( 1136 std::unique_ptr<net::MultiLogCTVerifier> ct_verifier(
1131 new net::MultiLogCTVerifier()); 1137 new net::MultiLogCTVerifier());
1132 ct_verifier->AddLogs(io_thread_globals->ct_logs); 1138 ct_verifier->AddLogs(io_thread_globals->ct_logs);
1133 1139
1134 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( 1140 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker(
1135 io_thread_globals->ct_logs, io_thread->net_log())); 1141 io_thread_globals->ct_logs, io_thread->net_log()));
1136 ct_verifier->SetObserver(ct_tree_tracker_.get()); 1142 ct_verifier->SetObserver(ct_tree_tracker_.get());
1137 1143
1138 builder.set_ct_verifier(std::move(ct_verifier)); 1144 main_request_context_storage_->set_cert_transparency_verifier(
1145 std::move(ct_verifier));
1139 1146
1140 io_thread->RegisterSTHObserver(ct_tree_tracker_.get()); 1147 io_thread->RegisterSTHObserver(ct_tree_tracker_.get());
1141 ct_tree_tracker_unregistration_ = 1148 ct_tree_tracker_unregistration_ =
1142 base::Bind(&IOThread::UnregisterSTHObserver, base::Unretained(io_thread), 1149 base::Bind(&IOThread::UnregisterSTHObserver, base::Unretained(io_thread),
1143 ct_tree_tracker_.get()); 1150 ct_tree_tracker_.get());
1144 1151
1145 builder.set_http_network_session_params( 1152 main_request_context_storage_->set_ct_policy_enforcer(
1146 profile_params_->io_thread->NetworkSessionParams()); 1153 base::MakeUnique<net::CTPolicyEnforcer>());
1147 if (data_reduction_proxy_io_data_.get()) {
1148 builder.set_shared_proxy_delegate(
1149 data_reduction_proxy_io_data_->proxy_delegate());
1150 }
1151 1154
1152 InitializeInternal(&builder, profile_params_.get(), protocol_handlers, 1155 InitializeInternal(profile_params_.get(), protocol_handlers,
1153 std::move(request_interceptors)); 1156 std::move(request_interceptors));
1154 1157
1155 main_request_context_ = builder.Build();
1156
1157 // Attach some things to the URLRequestContextBuilder's
1158 // TransportSecurityState. Since no requests have been made yet, safe to do
1159 // this even after the call to Build().
1160
1161 net::NetworkTrafficAnnotationTag traffic_annotation = 1158 net::NetworkTrafficAnnotationTag traffic_annotation =
1162 net::DefineNetworkTrafficAnnotation("domain_security_policy", R"( 1159 net::DefineNetworkTrafficAnnotation("domain_security_policy", R"(
1163 semantics { 1160 semantics {
1164 sender: "Domain Security Policy" 1161 sender: "Domain Security Policy"
1165 description: 1162 description:
1166 "Websites can opt in to have Chrome send reports to them when " 1163 "Websites can opt in to have Chrome send reports to them when "
1167 "Chrome observes connections to that website that do not meet " 1164 "Chrome observes connections to that website that do not meet "
1168 "stricter security policies, such as with HTTP Public Key Pinning. " 1165 "stricter security policies, such as with HTTP Public Key Pinning. "
1169 "Websites can use this feature to discover misconfigurations that " 1166 "Websites can use this feature to discover misconfigurations that "
1170 "prevent them from complying with stricter security policies that " 1167 "prevent them from complying with stricter security policies that "
(...skipping 21 matching lines...) Expand all
1192 certificate_report_sender_.get()); 1189 certificate_report_sender_.get());
1193 1190
1194 expect_ct_reporter_.reset( 1191 expect_ct_reporter_.reset(
1195 new ChromeExpectCTReporter(main_request_context_.get())); 1192 new ChromeExpectCTReporter(main_request_context_.get()));
1196 main_request_context_->transport_security_state()->SetExpectCTReporter( 1193 main_request_context_->transport_security_state()->SetExpectCTReporter(
1197 expect_ct_reporter_.get()); 1194 expect_ct_reporter_.get());
1198 1195
1199 main_request_context_->transport_security_state()->SetRequireCTDelegate( 1196 main_request_context_->transport_security_state()->SetRequireCTDelegate(
1200 ct_policy_manager_->GetDelegate()); 1197 ct_policy_manager_->GetDelegate());
1201 1198
1202 resource_context_->host_resolver_ =
1203 io_thread_globals->system_request_context->host_resolver();
1204 resource_context_->request_context_ = main_request_context_.get();
1205
1206 OnMainRequestContextCreated(profile_params_.get());
1207
1208 profile_params_.reset(); 1199 profile_params_.reset();
1209 initialized_ = true; 1200 initialized_ = true;
1210 } 1201 }
1211 1202
1203 void ProfileIOData::ApplyProfileParamsToContext(
1204 net::URLRequestContext* context) const {
1205 context->set_http_user_agent_settings(
1206 chrome_http_user_agent_settings_.get());
1207 context->set_ssl_config_service(profile_params_->ssl_config_service.get());
1208 }
1209
1212 std::unique_ptr<net::URLRequestJobFactory> 1210 std::unique_ptr<net::URLRequestJobFactory>
1213 ProfileIOData::SetUpJobFactoryDefaults( 1211 ProfileIOData::SetUpJobFactoryDefaults(
1214 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory, 1212 std::unique_ptr<net::URLRequestJobFactoryImpl> job_factory,
1215 content::URLRequestInterceptorScopedVector request_interceptors, 1213 content::URLRequestInterceptorScopedVector request_interceptors,
1216 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory> 1214 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
1217 protocol_handler_interceptor, 1215 protocol_handler_interceptor,
1218 net::NetworkDelegate* network_delegate, 1216 net::NetworkDelegate* network_delegate,
1219 net::HostResolver* host_resolver) const { 1217 net::HostResolver* host_resolver) const {
1220 // NOTE(willchan): Keep these protocol handlers in sync with 1218 // NOTE(willchan): Keep these protocol handlers in sync with
1221 // ProfileIOData::IsHandledProtocol(). 1219 // ProfileIOData::IsHandledProtocol().
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 request_interceptors.clear(); 1279 request_interceptors.clear();
1282 1280
1283 if (protocol_handler_interceptor) { 1281 if (protocol_handler_interceptor) {
1284 protocol_handler_interceptor->Chain(std::move(top_job_factory)); 1282 protocol_handler_interceptor->Chain(std::move(top_job_factory));
1285 return std::move(protocol_handler_interceptor); 1283 return std::move(protocol_handler_interceptor);
1286 } else { 1284 } else {
1287 return top_job_factory; 1285 return top_job_factory;
1288 } 1286 }
1289 } 1287 }
1290 1288
1291 void ProfileIOData::SetUpJobFactoryDefaultsForBuilder(
1292 net::URLRequestContextBuilder* builder,
1293 content::URLRequestInterceptorScopedVector request_interceptors,
1294 std::unique_ptr<ProtocolHandlerRegistry::JobInterceptorFactory>
1295 protocol_handler_interceptor,
1296 net::HostResolver* host_resolver) const {
1297 // NOTE(willchan): Keep these protocol handlers in sync with
1298 // ProfileIOData::IsHandledProtocol().
1299 builder->SetProtocolHandler(
1300 url::kFileScheme,
1301 base::MakeUnique<net::FileProtocolHandler>(
1302 base::CreateTaskRunnerWithTraits(
1303 {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
1304 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
1305
1306 #if BUILDFLAG(ENABLE_EXTENSIONS)
1307 DCHECK(extension_info_map_.get());
1308 // Check only for incognito (and not Chrome OS guest mode GUEST_PROFILE).
1309 bool is_incognito = profile_type() == Profile::INCOGNITO_PROFILE;
1310 builder->SetProtocolHandler(extensions::kExtensionScheme,
1311 extensions::CreateExtensionProtocolHandler(
1312 is_incognito, extension_info_map_.get()));
1313 #endif
1314 builder->SetProtocolHandler(url::kDataScheme,
1315 base::MakeUnique<net::DataProtocolHandler>());
1316 #if defined(OS_CHROMEOS)
1317 if (profile_params_) {
1318 builder->SetProtocolHandler(
1319 content::kExternalFileScheme,
1320 base::MakeUnique<chromeos::ExternalFileProtocolHandler>(
1321 profile_params_->profile));
1322 }
1323 #endif // defined(OS_CHROMEOS)
1324 #if defined(OS_ANDROID)
1325 builder->SetProtocolHandler(
1326 url::kContentScheme,
1327 content::ContentProtocolHandler::Create(base::CreateTaskRunnerWithTraits(
1328 {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
1329 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN})));
1330 #endif
1331
1332 builder->SetProtocolHandler(
1333 url::kAboutScheme,
1334 base::MakeUnique<about_handler::AboutProtocolHandler>());
1335
1336 #if !BUILDFLAG(DISABLE_FTP_SUPPORT)
1337 builder->SetProtocolHandler(url::kFtpScheme,
1338 net::FtpProtocolHandler::Create(host_resolver));
1339 #endif // !BUILDFLAG(DISABLE_FTP_SUPPORT)
1340
1341 #if BUILDFLAG(DEBUG_DEVTOOLS)
1342 request_interceptors.push_back(base::MakeUnique<DebugDevToolsInterceptor>());
1343 #endif
1344
1345 builder->SetInterceptors(std::move(request_interceptors));
1346
1347 if (protocol_handler_interceptor) {
1348 builder->set_create_intercepting_job_factory(
1349 base::BindOnce(&CreateURLRequestJobFactory,
1350 base::Passed(std::move(protocol_handler_interceptor))));
1351 }
1352 }
1353
1354 void ProfileIOData::ShutdownOnUIThread( 1289 void ProfileIOData::ShutdownOnUIThread(
1355 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters) { 1290 std::unique_ptr<ChromeURLRequestContextGetterVector> context_getters) {
1356 DCHECK_CURRENTLY_ON(BrowserThread::UI); 1291 DCHECK_CURRENTLY_ON(BrowserThread::UI);
1357 1292
1358 google_services_user_account_id_.Destroy(); 1293 google_services_user_account_id_.Destroy();
1359 sync_suppress_start_.Destroy(); 1294 sync_suppress_start_.Destroy();
1360 sync_first_setup_complete_.Destroy(); 1295 sync_first_setup_complete_.Destroy();
1361 enable_referrers_.Destroy(); 1296 enable_referrers_.Destroy();
1362 enable_do_not_track_.Destroy(); 1297 enable_do_not_track_.Destroy();
1363 force_google_safesearch_.Destroy(); 1298 force_google_safesearch_.Destroy();
(...skipping 22 matching lines...) Expand all
1386 1321
1387 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this); 1322 bool posted = BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, this);
1388 if (!posted) 1323 if (!posted)
1389 delete this; 1324 delete this;
1390 } 1325 }
1391 1326
1392 void ProfileIOData::DestroyResourceContext() { 1327 void ProfileIOData::DestroyResourceContext() {
1393 resource_context_.reset(); 1328 resource_context_.reset();
1394 } 1329 }
1395 1330
1331 std::unique_ptr<net::HttpNetworkSession>
1332 ProfileIOData::CreateHttpNetworkSession(
1333 const ProfileParams& profile_params) const {
1334 net::URLRequestContext* context = main_request_context();
1335
1336 IOThread* const io_thread = profile_params.io_thread;
1337
1338 net::HttpNetworkSession::Context session_context;
1339 net::URLRequestContextBuilder::SetHttpNetworkSessionComponents(
1340 context, &session_context);
1341 if (data_reduction_proxy_io_data_.get()) {
1342 session_context.proxy_delegate =
1343 data_reduction_proxy_io_data_->proxy_delegate();
1344 }
1345
1346 return std::unique_ptr<net::HttpNetworkSession>(new net::HttpNetworkSession(
1347 io_thread->NetworkSessionParams(), session_context));
1348 }
1349
1396 std::unique_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory( 1350 std::unique_ptr<net::HttpCache> ProfileIOData::CreateMainHttpFactory(
1397 net::HttpNetworkSession* session, 1351 net::HttpNetworkSession* session,
1398 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const { 1352 std::unique_ptr<net::HttpCache::BackendFactory> main_backend) const {
1399 return base::MakeUnique<net::HttpCache>( 1353 return base::MakeUnique<net::HttpCache>(
1400 base::WrapUnique(new DevToolsNetworkTransactionFactory( 1354 base::WrapUnique(new DevToolsNetworkTransactionFactory(
1401 network_controller_handle_.GetController(), session)), 1355 network_controller_handle_.GetController(), session)),
1402 std::move(main_backend), true /* is_main_cache */); 1356 std::move(main_backend), true /* is_main_cache */);
1403 } 1357 }
1404 1358
1405 std::unique_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory( 1359 std::unique_ptr<net::HttpCache> ProfileIOData::CreateHttpFactory(
(...skipping 17 matching lines...) Expand all
1423 void ProfileIOData::SetCookieSettingsForTesting( 1377 void ProfileIOData::SetCookieSettingsForTesting(
1424 content_settings::CookieSettings* cookie_settings) { 1378 content_settings::CookieSettings* cookie_settings) {
1425 DCHECK(!cookie_settings_.get()); 1379 DCHECK(!cookie_settings_.get());
1426 cookie_settings_ = cookie_settings; 1380 cookie_settings_ = cookie_settings;
1427 } 1381 }
1428 1382
1429 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState( 1383 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState(
1430 const GURL& url) const { 1384 const GURL& url) const {
1431 return url_blacklist_manager_->GetURLBlacklistState(url); 1385 return url_blacklist_manager_->GetURLBlacklistState(url);
1432 } 1386 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.h ('k') | net/url_request/url_request_context_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698