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/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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 transport_security_state_->SetExpectCTReporter(nullptr); | 667 transport_security_state_->SetExpectCTReporter(nullptr); |
668 expect_ct_reporter_.reset(); | 668 expect_ct_reporter_.reset(); |
669 | 669 |
670 if (transport_security_state_) | 670 if (transport_security_state_) |
671 transport_security_state_->SetRequireCTDelegate(nullptr); | 671 transport_security_state_->SetRequireCTDelegate(nullptr); |
672 | 672 |
673 // And the same for the ReportingService. | 673 // And the same for the ReportingService. |
674 main_request_context_storage()->set_reporting_service( | 674 main_request_context_storage()->set_reporting_service( |
675 std::unique_ptr<net::ReportingService>()); | 675 std::unique_ptr<net::ReportingService>()); |
676 | 676 |
| 677 // This should be shut down last, as any other requests may initiate more |
| 678 // activity when the ProxyService aborts lookups. |
| 679 if (proxy_service_) |
| 680 proxy_service_->OnShutdown(); |
| 681 |
677 // TODO(ajwong): These AssertNoURLRequests() calls are unnecessary since they | 682 // TODO(ajwong): These AssertNoURLRequests() calls are unnecessary since they |
678 // are already done in the URLRequestContext destructor. | 683 // are already done in the URLRequestContext destructor. |
679 if (main_request_context_) | 684 if (main_request_context_) |
680 main_request_context_->AssertNoURLRequests(); | 685 main_request_context_->AssertNoURLRequests(); |
681 if (extensions_request_context_) | 686 if (extensions_request_context_) |
682 extensions_request_context_->AssertNoURLRequests(); | 687 extensions_request_context_->AssertNoURLRequests(); |
683 | 688 |
684 current_context = 0; | 689 current_context = 0; |
685 for (URLRequestContextMap::iterator it = app_request_context_map_.begin(); | 690 for (URLRequestContextMap::iterator it = app_request_context_map_.begin(); |
686 it != app_request_context_map_.end(); ++it) { | 691 it != app_request_context_map_.end(); ++it) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
984 // Create the common request contexts. | 989 // Create the common request contexts. |
985 main_request_context_.reset(new net::URLRequestContext()); | 990 main_request_context_.reset(new net::URLRequestContext()); |
986 main_request_context_storage_.reset( | 991 main_request_context_storage_.reset( |
987 new net::URLRequestContextStorage(main_request_context_.get())); | 992 new net::URLRequestContextStorage(main_request_context_.get())); |
988 extensions_request_context_.reset(new net::URLRequestContext()); | 993 extensions_request_context_.reset(new net::URLRequestContext()); |
989 main_request_context_->set_name("main"); | 994 main_request_context_->set_name("main"); |
990 extensions_request_context_->set_name("extensions"); | 995 extensions_request_context_->set_name("extensions"); |
991 | 996 |
992 main_request_context_->set_enable_brotli(io_thread_globals->enable_brotli); | 997 main_request_context_->set_enable_brotli(io_thread_globals->enable_brotli); |
993 | 998 |
994 std::unique_ptr<ChromeNetworkDelegate> network_delegate( | 999 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate( |
995 new ChromeNetworkDelegate( | 1000 new ChromeNetworkDelegate( |
996 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1001 #if BUILDFLAG(ENABLE_EXTENSIONS) |
997 io_thread_globals->extension_event_router_forwarder.get(), | 1002 io_thread_globals->extension_event_router_forwarder.get(), |
998 #else | 1003 #else |
999 NULL, | 1004 NULL, |
1000 #endif | 1005 #endif |
1001 &enable_referrers_)); | 1006 &enable_referrers_)); |
1002 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1007 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1003 network_delegate->set_extension_info_map( | 1008 chrome_network_delegate->set_extension_info_map( |
1004 profile_params_->extension_info_map.get()); | 1009 profile_params_->extension_info_map.get()); |
1005 if (!command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) { | 1010 if (!command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) { |
1006 extension_throttle_manager_.reset( | 1011 extension_throttle_manager_.reset( |
1007 new extensions::ExtensionThrottleManager()); | 1012 new extensions::ExtensionThrottleManager()); |
1008 } | 1013 } |
1009 #endif | 1014 #endif |
1010 | 1015 |
1011 network_delegate->set_url_blacklist_manager(url_blacklist_manager_.get()); | 1016 chrome_network_delegate->set_url_blacklist_manager( |
1012 network_delegate->set_profile(profile_params_->profile); | 1017 url_blacklist_manager_.get()); |
1013 network_delegate->set_profile_path(profile_params_->path); | 1018 chrome_network_delegate->set_profile(profile_params_->profile); |
1014 network_delegate->set_cookie_settings(profile_params_->cookie_settings.get()); | 1019 chrome_network_delegate->set_profile_path(profile_params_->path); |
1015 network_delegate->set_enable_do_not_track(&enable_do_not_track_); | 1020 chrome_network_delegate->set_cookie_settings( |
1016 network_delegate->set_force_google_safe_search(&force_google_safesearch_); | 1021 profile_params_->cookie_settings.get()); |
1017 network_delegate->set_force_youtube_restrict(&force_youtube_restrict_); | 1022 chrome_network_delegate->set_enable_do_not_track(&enable_do_not_track_); |
1018 network_delegate->set_allowed_domains_for_apps(&allowed_domains_for_apps_); | 1023 chrome_network_delegate->set_force_google_safe_search( |
1019 network_delegate->set_data_use_aggregator( | 1024 &force_google_safesearch_); |
| 1025 chrome_network_delegate->set_force_youtube_restrict(&force_youtube_restrict_); |
| 1026 chrome_network_delegate->set_allowed_domains_for_apps( |
| 1027 &allowed_domains_for_apps_); |
| 1028 chrome_network_delegate->set_data_use_aggregator( |
1020 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord()); | 1029 io_thread_globals->data_use_aggregator.get(), IsOffTheRecord()); |
1021 | 1030 |
| 1031 std::unique_ptr<net::NetworkDelegate> network_delegate = |
| 1032 ConfigureNetworkDelegate(profile_params_->io_thread, |
| 1033 std::move(chrome_network_delegate)); |
| 1034 |
| 1035 main_request_context_->set_host_resolver( |
| 1036 io_thread_globals->host_resolver.get()); |
| 1037 |
1022 // NOTE: Proxy service uses the default io thread network delegate, not the | 1038 // NOTE: Proxy service uses the default io thread network delegate, not the |
1023 // delegate just created. | 1039 // delegate just created. |
1024 proxy_service_ = ProxyServiceFactory::CreateProxyService( | 1040 proxy_service_ = ProxyServiceFactory::CreateProxyService( |
1025 io_thread->net_log(), | 1041 io_thread->net_log(), main_request_context_.get(), network_delegate.get(), |
1026 io_thread_globals->proxy_script_fetcher_context.get(), | |
1027 io_thread_globals->system_network_delegate.get(), | |
1028 std::move(profile_params_->proxy_config_service), command_line, | 1042 std::move(profile_params_->proxy_config_service), command_line, |
1029 io_thread->WpadQuickCheckEnabled(), | 1043 io_thread->WpadQuickCheckEnabled(), |
1030 io_thread->PacHttpsUrlStrippingEnabled()); | 1044 io_thread->PacHttpsUrlStrippingEnabled()); |
| 1045 |
| 1046 main_request_context_storage_->set_network_delegate( |
| 1047 std::move(network_delegate)); |
| 1048 |
1031 transport_security_state_.reset(new net::TransportSecurityState()); | 1049 transport_security_state_.reset(new net::TransportSecurityState()); |
1032 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); | 1050 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
1033 transport_security_persister_.reset( | 1051 transport_security_persister_.reset( |
1034 new net::TransportSecurityPersister( | 1052 new net::TransportSecurityPersister( |
1035 transport_security_state_.get(), | 1053 transport_security_state_.get(), |
1036 profile_params_->path, | 1054 profile_params_->path, |
1037 pool->GetSequencedTaskRunnerWithShutdownBehavior( | 1055 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
1038 pool->GetSequenceToken(), | 1056 pool->GetSequenceToken(), |
1039 base::SequencedWorkerPool::BLOCK_SHUTDOWN), | 1057 base::SequencedWorkerPool::BLOCK_SHUTDOWN), |
1040 IsOffTheRecord())); | 1058 IsOffTheRecord())); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( | 1130 ct_tree_tracker_.reset(new certificate_transparency::TreeStateTracker( |
1113 io_thread_globals->ct_logs, io_thread->net_log())); | 1131 io_thread_globals->ct_logs, io_thread->net_log())); |
1114 ct_verifier->SetObserver(ct_tree_tracker_.get()); | 1132 ct_verifier->SetObserver(ct_tree_tracker_.get()); |
1115 | 1133 |
1116 cert_transparency_verifier_ = std::move(ct_verifier); | 1134 cert_transparency_verifier_ = std::move(ct_verifier); |
1117 io_thread->RegisterSTHObserver(ct_tree_tracker_.get()); | 1135 io_thread->RegisterSTHObserver(ct_tree_tracker_.get()); |
1118 ct_tree_tracker_unregistration_ = | 1136 ct_tree_tracker_unregistration_ = |
1119 base::Bind(&IOThread::UnregisterSTHObserver, base::Unretained(io_thread), | 1137 base::Bind(&IOThread::UnregisterSTHObserver, base::Unretained(io_thread), |
1120 ct_tree_tracker_.get()); | 1138 ct_tree_tracker_.get()); |
1121 | 1139 |
1122 InitializeInternal(std::move(network_delegate), profile_params_.get(), | 1140 InitializeInternal(profile_params_.get(), protocol_handlers, |
1123 protocol_handlers, std::move(request_interceptors)); | 1141 std::move(request_interceptors)); |
1124 | 1142 |
1125 profile_params_.reset(); | 1143 profile_params_.reset(); |
1126 initialized_ = true; | 1144 initialized_ = true; |
1127 } | 1145 } |
1128 | 1146 |
1129 void ProfileIOData::ApplyProfileParamsToContext( | 1147 void ProfileIOData::ApplyProfileParamsToContext( |
1130 net::URLRequestContext* context) const { | 1148 net::URLRequestContext* context) const { |
1131 context->set_http_user_agent_settings( | 1149 context->set_http_user_agent_settings( |
1132 chrome_http_user_agent_settings_.get()); | 1150 chrome_http_user_agent_settings_.get()); |
1133 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); | 1151 context->set_ssl_config_service(profile_params_->ssl_config_service.get()); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 net::HttpTransactionFactory* main_http_factory, | 1321 net::HttpTransactionFactory* main_http_factory, |
1304 std::unique_ptr<net::HttpCache::BackendFactory> backend) const { | 1322 std::unique_ptr<net::HttpCache::BackendFactory> backend) const { |
1305 DCHECK(main_http_factory); | 1323 DCHECK(main_http_factory); |
1306 net::HttpNetworkSession* shared_session = main_http_factory->GetSession(); | 1324 net::HttpNetworkSession* shared_session = main_http_factory->GetSession(); |
1307 return base::MakeUnique<net::HttpCache>( | 1325 return base::MakeUnique<net::HttpCache>( |
1308 base::WrapUnique(new DevToolsNetworkTransactionFactory( | 1326 base::WrapUnique(new DevToolsNetworkTransactionFactory( |
1309 network_controller_handle_.GetController(), shared_session)), | 1327 network_controller_handle_.GetController(), shared_session)), |
1310 std::move(backend), false /* is_main_cache */); | 1328 std::move(backend), false /* is_main_cache */); |
1311 } | 1329 } |
1312 | 1330 |
| 1331 std::unique_ptr<net::NetworkDelegate> ProfileIOData::ConfigureNetworkDelegate( |
| 1332 IOThread* io_thread, |
| 1333 std::unique_ptr<ChromeNetworkDelegate> chrome_network_delegate) const { |
| 1334 return base::WrapUnique<net::NetworkDelegate>( |
| 1335 chrome_network_delegate.release()); |
| 1336 } |
| 1337 |
1313 void ProfileIOData::SetCookieSettingsForTesting( | 1338 void ProfileIOData::SetCookieSettingsForTesting( |
1314 content_settings::CookieSettings* cookie_settings) { | 1339 content_settings::CookieSettings* cookie_settings) { |
1315 DCHECK(!cookie_settings_.get()); | 1340 DCHECK(!cookie_settings_.get()); |
1316 cookie_settings_ = cookie_settings; | 1341 cookie_settings_ = cookie_settings; |
1317 } | 1342 } |
1318 | 1343 |
1319 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState( | 1344 policy::URLBlacklist::URLBlacklistState ProfileIOData::GetURLBlacklistState( |
1320 const GURL& url) const { | 1345 const GURL& url) const { |
1321 return url_blacklist_manager_->GetURLBlacklistState(url); | 1346 return url_blacklist_manager_->GetURLBlacklistState(url); |
1322 } | 1347 } |
OLD | NEW |