| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/message_loop.h" | 16 #include "base/message_loop.h" |
| 17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
| 18 #include "base/shared_memory.h" | 18 #include "base/shared_memory.h" |
| 19 #include "base/stl_util-inl.h" | 19 #include "base/stl_util-inl.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "chrome/browser/download/download_file_manager.h" | 21 #include "chrome/browser/download/download_file_manager.h" |
| 22 #include "chrome/browser/download/download_manager.h" | 22 #include "chrome/browser/download/download_manager.h" |
| 23 #include "chrome/browser/download/download_request_limiter.h" | 23 #include "chrome/browser/download/download_request_limiter.h" |
| 24 #include "chrome/browser/download/download_util.h" | 24 #include "chrome/browser/download/download_util.h" |
| 25 #include "chrome/browser/download/save_file_manager.h" | 25 #include "chrome/browser/download/save_file_manager.h" |
| 26 #include "chrome/browser/external_protocol/external_protocol_handler.h" | |
| 27 #include "chrome/browser/profiles/profile.h" | |
| 28 #include "chrome/browser/renderer_host/download_resource_handler.h" | 26 #include "chrome/browser/renderer_host/download_resource_handler.h" |
| 29 #include "chrome/browser/renderer_host/save_file_resource_handler.h" | 27 #include "chrome/browser/renderer_host/save_file_resource_handler.h" |
| 30 #include "chrome/browser/ssl/ssl_client_auth_handler.h" | 28 #include "chrome/browser/ssl/ssl_client_auth_handler.h" |
| 31 #include "chrome/browser/ssl/ssl_manager.h" | 29 #include "chrome/browser/ssl/ssl_manager.h" |
| 32 #include "chrome/browser/ui/login/login_prompt.h" | |
| 33 #include "chrome/common/chrome_switches.h" | |
| 34 #include "content/browser/appcache/chrome_appcache_service.h" | 30 #include "content/browser/appcache/chrome_appcache_service.h" |
| 35 #include "content/browser/cert_store.h" | 31 #include "content/browser/cert_store.h" |
| 36 #include "content/browser/child_process_security_policy.h" | 32 #include "content/browser/child_process_security_policy.h" |
| 37 #include "content/browser/chrome_blob_storage_context.h" | 33 #include "content/browser/chrome_blob_storage_context.h" |
| 38 #include "content/browser/content_browser_client.h" | 34 #include "content/browser/content_browser_client.h" |
| 39 #include "content/browser/cross_site_request_manager.h" | 35 #include "content/browser/cross_site_request_manager.h" |
| 40 #include "content/browser/in_process_webkit/webkit_thread.h" | 36 #include "content/browser/in_process_webkit/webkit_thread.h" |
| 41 #include "content/browser/plugin_service.h" | 37 #include "content/browser/plugin_service.h" |
| 42 #include "content/browser/resource_context.h" | 38 #include "content/browser/resource_context.h" |
| 43 #include "content/browser/renderer_host/async_resource_handler.h" | 39 #include "content/browser/renderer_host/async_resource_handler.h" |
| 44 #include "content/browser/renderer_host/buffered_resource_handler.h" | 40 #include "content/browser/renderer_host/buffered_resource_handler.h" |
| 45 #include "content/browser/renderer_host/cross_site_resource_handler.h" | 41 #include "content/browser/renderer_host/cross_site_resource_handler.h" |
| 46 #include "content/browser/renderer_host/global_request_id.h" | 42 #include "content/browser/renderer_host/global_request_id.h" |
| 47 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" | 43 #include "content/browser/renderer_host/redirect_to_file_resource_handler.h" |
| 48 #include "content/browser/renderer_host/render_view_host.h" | 44 #include "content/browser/renderer_host/render_view_host.h" |
| 49 #include "content/browser/renderer_host/render_view_host_delegate.h" | 45 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 50 #include "content/browser/renderer_host/render_view_host_notification_task.h" | 46 #include "content/browser/renderer_host/render_view_host_notification_task.h" |
| 47 #include "content/browser/renderer_host/resource_dispatcher_host_delegate.h" |
| 48 #include "content/browser/renderer_host/resource_dispatcher_host_login_delegate.
h" |
| 51 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" | 49 #include "content/browser/renderer_host/resource_dispatcher_host_request_info.h" |
| 52 #include "content/browser/renderer_host/resource_message_filter.h" | 50 #include "content/browser/renderer_host/resource_message_filter.h" |
| 53 #include "content/browser/renderer_host/resource_queue.h" | 51 #include "content/browser/renderer_host/resource_queue.h" |
| 54 #include "content/browser/renderer_host/resource_request_details.h" | 52 #include "content/browser/renderer_host/resource_request_details.h" |
| 55 #include "content/browser/renderer_host/sync_resource_handler.h" | 53 #include "content/browser/renderer_host/sync_resource_handler.h" |
| 56 #include "content/browser/worker_host/worker_service.h" | 54 #include "content/browser/worker_host/worker_service.h" |
| 55 #include "content/common/content_switches.h" |
| 57 #include "content/common/notification_service.h" | 56 #include "content/common/notification_service.h" |
| 58 #include "content/common/resource_messages.h" | 57 #include "content/common/resource_messages.h" |
| 59 #include "content/common/url_constants.h" | 58 #include "content/common/url_constants.h" |
| 60 #include "content/common/view_messages.h" | 59 #include "content/common/view_messages.h" |
| 61 #include "net/base/auth.h" | 60 #include "net/base/auth.h" |
| 62 #include "net/base/cert_status_flags.h" | 61 #include "net/base/cert_status_flags.h" |
| 63 #include "net/base/cookie_monster.h" | 62 #include "net/base/cookie_monster.h" |
| 64 #include "net/base/load_flags.h" | 63 #include "net/base/load_flags.h" |
| 65 #include "net/base/mime_util.h" | 64 #include "net/base/mime_util.h" |
| 66 #include "net/base/net_errors.h" | 65 #include "net/base/net_errors.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 download_request_limiter_(new DownloadRequestLimiter()), | 234 download_request_limiter_(new DownloadRequestLimiter()), |
| 236 ALLOW_THIS_IN_INITIALIZER_LIST( | 235 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 237 save_file_manager_(new SaveFileManager(this))), | 236 save_file_manager_(new SaveFileManager(this))), |
| 238 webkit_thread_(new WebKitThread), | 237 webkit_thread_(new WebKitThread), |
| 239 request_id_(-1), | 238 request_id_(-1), |
| 240 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), | 239 ALLOW_THIS_IN_INITIALIZER_LIST(method_runner_(this)), |
| 241 is_shutdown_(false), | 240 is_shutdown_(false), |
| 242 max_outstanding_requests_cost_per_process_( | 241 max_outstanding_requests_cost_per_process_( |
| 243 kMaxOutstandingRequestsCostPerProcess), | 242 kMaxOutstandingRequestsCostPerProcess), |
| 244 filter_(NULL), | 243 filter_(NULL), |
| 245 observer_(NULL), | 244 delegate_(NULL), |
| 246 allow_cross_origin_auth_prompt_(false) { | 245 allow_cross_origin_auth_prompt_(false) { |
| 247 resource_queue_.Initialize(resource_queue_delegates); | 246 resource_queue_.Initialize(resource_queue_delegates); |
| 248 } | 247 } |
| 249 | 248 |
| 250 ResourceDispatcherHost::~ResourceDispatcherHost() { | 249 ResourceDispatcherHost::~ResourceDispatcherHost() { |
| 251 AsyncResourceHandler::GlobalCleanup(); | 250 AsyncResourceHandler::GlobalCleanup(); |
| 252 STLDeleteValues(&pending_requests_); | 251 STLDeleteValues(&pending_requests_); |
| 253 } | 252 } |
| 254 | 253 |
| 255 void ResourceDispatcherHost::Initialize() { | 254 void ResourceDispatcherHost::Initialize() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 int route_id, | 304 int route_id, |
| 306 const GURL& url, | 305 const GURL& url, |
| 307 ResourceType::Type type, | 306 ResourceType::Type type, |
| 308 const net::URLRequestJobFactory& job_factory, | 307 const net::URLRequestJobFactory& job_factory, |
| 309 ResourceHandler* handler) { | 308 ResourceHandler* handler) { |
| 310 if (!ResourceType::IsFrame(type) || | 309 if (!ResourceType::IsFrame(type) || |
| 311 job_factory.IsHandledURL(url)) { | 310 job_factory.IsHandledURL(url)) { |
| 312 return false; | 311 return false; |
| 313 } | 312 } |
| 314 | 313 |
| 315 BrowserThread::PostTask( | 314 if (delegate_) |
| 316 BrowserThread::UI, FROM_HERE, | 315 delegate_->HandleExternalProtocol(url, child_id, route_id); |
| 317 NewRunnableFunction( | |
| 318 &ExternalProtocolHandler::LaunchUrl, url, child_id, route_id)); | |
| 319 | 316 |
| 320 handler->OnResponseCompleted( | 317 handler->OnResponseCompleted( |
| 321 request_id, | 318 request_id, |
| 322 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_ABORTED), | 319 net::URLRequestStatus(net::URLRequestStatus::FAILED, net::ERR_ABORTED), |
| 323 std::string()); // No security info necessary. | 320 std::string()); // No security info necessary. |
| 324 return true; | 321 return true; |
| 325 } | 322 } |
| 326 | 323 |
| 327 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, | 324 bool ResourceDispatcherHost::OnMessageReceived(const IPC::Message& message, |
| 328 ResourceMessageFilter* filter, | 325 ResourceMessageFilter* filter, |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 | 386 |
| 390 if (is_shutdown_ || | 387 if (is_shutdown_ || |
| 391 !ShouldServiceRequest(process_type, child_id, request_data)) { | 388 !ShouldServiceRequest(process_type, child_id, request_data)) { |
| 392 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 389 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
| 393 return; | 390 return; |
| 394 } | 391 } |
| 395 | 392 |
| 396 const GURL referrer = MaybeStripReferrer(request_data.referrer); | 393 const GURL referrer = MaybeStripReferrer(request_data.referrer); |
| 397 | 394 |
| 398 // Allow the observer to block/handle the request. | 395 // Allow the observer to block/handle the request. |
| 399 if (observer_ && !observer_->ShouldBeginRequest(child_id, route_id, | 396 if (delegate_ && !delegate_->ShouldBeginRequest(child_id, route_id, |
| 400 request_data, | 397 request_data, |
| 401 resource_context, | 398 resource_context, |
| 402 referrer)) { | 399 referrer)) { |
| 403 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); | 400 AbortRequestBeforeItStarts(filter_, sync_result, route_id, request_id); |
| 404 return; | 401 return; |
| 405 } | 402 } |
| 406 | 403 |
| 407 // Construct the event handler. | 404 // Construct the event handler. |
| 408 scoped_refptr<ResourceHandler> handler; | 405 scoped_refptr<ResourceHandler> handler; |
| 409 if (sync_result) { | 406 if (sync_result) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // has a chance to run before we render the new page. | 485 // has a chance to run before we render the new page. |
| 489 handler = new CrossSiteResourceHandler(handler, | 486 handler = new CrossSiteResourceHandler(handler, |
| 490 child_id, | 487 child_id, |
| 491 route_id, | 488 route_id, |
| 492 this); | 489 this); |
| 493 } | 490 } |
| 494 | 491 |
| 495 // Insert a buffered event handler before the actual one. | 492 // Insert a buffered event handler before the actual one. |
| 496 handler = new BufferedResourceHandler(handler, this, request); | 493 handler = new BufferedResourceHandler(handler, this, request); |
| 497 | 494 |
| 498 if (observer_) { | 495 if (delegate_) { |
| 499 bool sub = request_data.resource_type != ResourceType::MAIN_FRAME; | 496 bool sub = request_data.resource_type != ResourceType::MAIN_FRAME; |
| 500 ResourceHandler* temp_handler = handler; | 497 handler = delegate_->RequestBeginning( |
| 501 observer_->RequestBeginning( | 498 handler, request, sub, child_id, route_id); |
| 502 &temp_handler, request, sub, child_id, route_id); | |
| 503 handler = temp_handler; | |
| 504 } | 499 } |
| 505 | 500 |
| 506 // Make extra info and read footer (contains request ID). | 501 // Make extra info and read footer (contains request ID). |
| 507 ResourceDispatcherHostRequestInfo* extra_info = | 502 ResourceDispatcherHostRequestInfo* extra_info = |
| 508 new ResourceDispatcherHostRequestInfo( | 503 new ResourceDispatcherHostRequestInfo( |
| 509 handler, | 504 handler, |
| 510 process_type, | 505 process_type, |
| 511 child_id, | 506 child_id, |
| 512 route_id, | 507 route_id, |
| 513 request_data.origin_pid, | 508 request_data.origin_pid, |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 new DownloadResourceHandler(this, | 704 new DownloadResourceHandler(this, |
| 710 child_id, | 705 child_id, |
| 711 route_id, | 706 route_id, |
| 712 request_id_, | 707 request_id_, |
| 713 url, | 708 url, |
| 714 download_file_manager_.get(), | 709 download_file_manager_.get(), |
| 715 request, | 710 request, |
| 716 prompt_for_save_location, | 711 prompt_for_save_location, |
| 717 save_info)); | 712 save_info)); |
| 718 | 713 |
| 719 if (observer_) { | 714 if (delegate_) |
| 720 ResourceHandler* temp_handler = handler; | 715 handler = delegate_->DownloadStarting(handler, child_id, route_id); |
| 721 observer_->DownloadStarting(&temp_handler, child_id, route_id); | |
| 722 handler = temp_handler; | |
| 723 } | |
| 724 | 716 |
| 725 const net::URLRequestContext* request_context = context.request_context(); | 717 const net::URLRequestContext* request_context = context.request_context(); |
| 726 | 718 |
| 727 if (!request_context->job_factory()->IsHandledURL(url)) { | 719 if (!request_context->job_factory()->IsHandledURL(url)) { |
| 728 VLOG(1) << "Download request for unsupported protocol: " | 720 VLOG(1) << "Download request for unsupported protocol: " |
| 729 << url.possibly_invalid_spec(); | 721 << url.possibly_invalid_spec(); |
| 730 return; | 722 return; |
| 731 } | 723 } |
| 732 | 724 |
| 733 request->set_method("GET"); | 725 request->set_method("GET"); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 void ResourceDispatcherHost::RemovePendingRequest( | 961 void ResourceDispatcherHost::RemovePendingRequest( |
| 970 const PendingRequestList::iterator& iter) { | 962 const PendingRequestList::iterator& iter) { |
| 971 ResourceDispatcherHostRequestInfo* info = InfoForRequest(iter->second); | 963 ResourceDispatcherHostRequestInfo* info = InfoForRequest(iter->second); |
| 972 | 964 |
| 973 // Remove the memory credit that we added when pushing the request onto | 965 // Remove the memory credit that we added when pushing the request onto |
| 974 // the pending list. | 966 // the pending list. |
| 975 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), | 967 IncrementOutstandingRequestsMemoryCost(-1 * info->memory_cost(), |
| 976 info->child_id()); | 968 info->child_id()); |
| 977 | 969 |
| 978 // Notify interested parties that the request object is going away. | 970 // Notify interested parties that the request object is going away. |
| 979 if (info->login_handler()) | 971 if (info->login_delegate()) |
| 980 info->login_handler()->OnRequestCancelled(); | 972 info->login_delegate()->OnRequestCancelled(); |
| 981 if (info->ssl_client_auth_handler()) | 973 if (info->ssl_client_auth_handler()) |
| 982 info->ssl_client_auth_handler()->OnRequestCancelled(); | 974 info->ssl_client_auth_handler()->OnRequestCancelled(); |
| 983 resource_queue_.RemoveRequest(iter->first); | 975 resource_queue_.RemoveRequest(iter->first); |
| 984 | 976 |
| 985 delete iter->second; | 977 delete iter->second; |
| 986 pending_requests_.erase(iter); | 978 pending_requests_.erase(iter); |
| 987 | 979 |
| 988 // If we have no more pending requests, then stop the load state monitor | 980 // If we have no more pending requests, then stop the load state monitor |
| 989 if (pending_requests_.empty()) | 981 if (pending_requests_.empty()) |
| 990 update_load_states_timer_.Stop(); | 982 update_load_states_timer_.Stop(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 } | 1024 } |
| 1033 | 1025 |
| 1034 void ResourceDispatcherHost::OnAuthRequired( | 1026 void ResourceDispatcherHost::OnAuthRequired( |
| 1035 net::URLRequest* request, | 1027 net::URLRequest* request, |
| 1036 net::AuthChallengeInfo* auth_info) { | 1028 net::AuthChallengeInfo* auth_info) { |
| 1037 if (request->load_flags() & net::LOAD_DO_NOT_PROMPT_FOR_LOGIN) { | 1029 if (request->load_flags() & net::LOAD_DO_NOT_PROMPT_FOR_LOGIN) { |
| 1038 request->CancelAuth(); | 1030 request->CancelAuth(); |
| 1039 return; | 1031 return; |
| 1040 } | 1032 } |
| 1041 | 1033 |
| 1042 if (observer_ && !observer_->AcceptAuthRequest(request, auth_info)) { | 1034 if (delegate_ && !delegate_->AcceptAuthRequest(request, auth_info)) { |
| 1043 request->CancelAuth(); | 1035 request->CancelAuth(); |
| 1044 return; | 1036 return; |
| 1045 } | 1037 } |
| 1046 | 1038 |
| 1047 // Prevent third-party content from prompting for login, unless it is | 1039 // Prevent third-party content from prompting for login, unless it is |
| 1048 // a proxy that is trying to authenticate. This is often the foundation | 1040 // a proxy that is trying to authenticate. This is often the foundation |
| 1049 // of a scam to extract credentials for another domain from the user. | 1041 // of a scam to extract credentials for another domain from the user. |
| 1050 if (!auth_info->is_proxy) { | 1042 if (!auth_info->is_proxy) { |
| 1051 HttpAuthResourceType resource_type = HttpAuthResourceTypeOf(request); | 1043 HttpAuthResourceType resource_type = HttpAuthResourceTypeOf(request); |
| 1052 UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthResource", | 1044 UMA_HISTOGRAM_ENUMERATION("Net.HttpAuthResource", |
| 1053 resource_type, | 1045 resource_type, |
| 1054 HTTP_AUTH_RESOURCE_LAST); | 1046 HTTP_AUTH_RESOURCE_LAST); |
| 1055 | 1047 |
| 1056 if (resource_type == HTTP_AUTH_RESOURCE_BLOCKED_CROSS) { | 1048 if (resource_type == HTTP_AUTH_RESOURCE_BLOCKED_CROSS) { |
| 1057 request->CancelAuth(); | 1049 request->CancelAuth(); |
| 1058 return; | 1050 return; |
| 1059 } | 1051 } |
| 1060 } | 1052 } |
| 1061 | 1053 |
| 1062 | 1054 |
| 1063 // Create a login dialog on the UI thread to get authentication data, | 1055 // Create a login dialog on the UI thread to get authentication data, |
| 1064 // or pull from cache and continue on the IO thread. | 1056 // or pull from cache and continue on the IO thread. |
| 1065 // TODO(mpcomplete): We should block the parent tab while waiting for | 1057 // TODO(mpcomplete): We should block the parent tab while waiting for |
| 1066 // authentication. | 1058 // authentication. |
| 1067 // That would also solve the problem of the net::URLRequest being cancelled | 1059 // That would also solve the problem of the net::URLRequest being cancelled |
| 1068 // before we receive authentication. | 1060 // before we receive authentication. |
| 1069 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1061 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1070 DCHECK(!info->login_handler()) << | 1062 DCHECK(!info->login_delegate()) << |
| 1071 "OnAuthRequired called with login_handler pending"; | 1063 "OnAuthRequired called with login_delegate pending"; |
| 1072 info->set_login_handler(CreateLoginPrompt(auth_info, request)); | 1064 if (delegate_) { |
| 1065 info->set_login_delegate(delegate_->CreateLoginDelegate( |
| 1066 auth_info, request)); |
| 1067 } |
| 1068 if (!info->login_delegate()) |
| 1069 request->CancelAuth(); |
| 1073 } | 1070 } |
| 1074 | 1071 |
| 1075 void ResourceDispatcherHost::OnCertificateRequested( | 1072 void ResourceDispatcherHost::OnCertificateRequested( |
| 1076 net::URLRequest* request, | 1073 net::URLRequest* request, |
| 1077 net::SSLCertRequestInfo* cert_request_info) { | 1074 net::SSLCertRequestInfo* cert_request_info) { |
| 1078 DCHECK(request); | 1075 DCHECK(request); |
| 1079 if (observer_ && !observer_->AcceptSSLClientCertificateRequest( | 1076 if (delegate_ && !delegate_->AcceptSSLClientCertificateRequest( |
| 1080 request, cert_request_info)) { | 1077 request, cert_request_info)) { |
| 1081 request->Cancel(); | 1078 request->Cancel(); |
| 1082 return; | 1079 return; |
| 1083 } | 1080 } |
| 1084 | 1081 |
| 1085 if (cert_request_info->client_certs.empty()) { | 1082 if (cert_request_info->client_certs.empty()) { |
| 1086 // No need to query the user if there are no certs to choose from. | 1083 // No need to query the user if there are no certs to choose from. |
| 1087 request->ContinueWithCertificate(NULL); | 1084 request->ContinueWithCertificate(NULL); |
| 1088 return; | 1085 return; |
| 1089 } | 1086 } |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 } | 1219 } |
| 1223 | 1220 |
| 1224 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, | 1221 bool ResourceDispatcherHost::CancelRequestInternal(net::URLRequest* request, |
| 1225 bool from_renderer) { | 1222 bool from_renderer) { |
| 1226 VLOG(1) << "CancelRequest: " << request->url().spec(); | 1223 VLOG(1) << "CancelRequest: " << request->url().spec(); |
| 1227 | 1224 |
| 1228 // WebKit will send us a cancel for downloads since it no longer handles them. | 1225 // WebKit will send us a cancel for downloads since it no longer handles them. |
| 1229 // In this case, ignore the cancel since we handle downloads in the browser. | 1226 // In this case, ignore the cancel since we handle downloads in the browser. |
| 1230 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); | 1227 ResourceDispatcherHostRequestInfo* info = InfoForRequest(request); |
| 1231 if (!from_renderer || !info->is_download()) { | 1228 if (!from_renderer || !info->is_download()) { |
| 1232 if (info->login_handler()) { | 1229 if (info->login_delegate()) { |
| 1233 info->login_handler()->OnRequestCancelled(); | 1230 info->login_delegate()->OnRequestCancelled(); |
| 1234 info->set_login_handler(NULL); | 1231 info->set_login_delegate(NULL); |
| 1235 } | 1232 } |
| 1236 if (info->ssl_client_auth_handler()) { | 1233 if (info->ssl_client_auth_handler()) { |
| 1237 info->ssl_client_auth_handler()->OnRequestCancelled(); | 1234 info->ssl_client_auth_handler()->OnRequestCancelled(); |
| 1238 info->set_ssl_client_auth_handler(NULL); | 1235 info->set_ssl_client_auth_handler(NULL); |
| 1239 } | 1236 } |
| 1240 request->Cancel(); | 1237 request->Cancel(); |
| 1241 // Our callers assume |request| is valid after we return. | 1238 // Our callers assume |request| is valid after we return. |
| 1242 DCHECK(IsValidRequest(request)); | 1239 DCHECK(IsValidRequest(request)); |
| 1243 return true; | 1240 return true; |
| 1244 } | 1241 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1357 bool defer_start = false; | 1354 bool defer_start = false; |
| 1358 if (!info->resource_handler()->OnWillStart( | 1355 if (!info->resource_handler()->OnWillStart( |
| 1359 info->request_id(), request->url(), | 1356 info->request_id(), request->url(), |
| 1360 &defer_start)) { | 1357 &defer_start)) { |
| 1361 CancelRequestInternal(request, false); | 1358 CancelRequestInternal(request, false); |
| 1362 return; | 1359 return; |
| 1363 } | 1360 } |
| 1364 | 1361 |
| 1365 // TODO(cbentzel): Should we isolate this to resource handlers instead of | 1362 // TODO(cbentzel): Should we isolate this to resource handlers instead of |
| 1366 // adding an interface to the observer? | 1363 // adding an interface to the observer? |
| 1367 if (!defer_start && observer_ && filter_) { | 1364 if (!defer_start && delegate_ && filter_) { |
| 1368 defer_start = observer_->ShouldDeferStart(request, | 1365 defer_start = delegate_->ShouldDeferStart(request, |
| 1369 filter_->resource_context()); | 1366 filter_->resource_context()); |
| 1370 } | 1367 } |
| 1371 | 1368 |
| 1372 if (!defer_start) | 1369 if (!defer_start) |
| 1373 InsertIntoResourceQueue(request, *info); | 1370 InsertIntoResourceQueue(request, *info); |
| 1374 } | 1371 } |
| 1375 | 1372 |
| 1376 void ResourceDispatcherHost::InsertIntoResourceQueue( | 1373 void ResourceDispatcherHost::InsertIntoResourceQueue( |
| 1377 net::URLRequest* request, | 1374 net::URLRequest* request, |
| 1378 const ResourceDispatcherHostRequestInfo& request_info) { | 1375 const ResourceDispatcherHostRequestInfo& request_info) { |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 | 2007 |
| 2011 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { | 2008 bool ResourceDispatcherHost::allow_cross_origin_auth_prompt() { |
| 2012 return allow_cross_origin_auth_prompt_; | 2009 return allow_cross_origin_auth_prompt_; |
| 2013 } | 2010 } |
| 2014 | 2011 |
| 2015 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { | 2012 void ResourceDispatcherHost::set_allow_cross_origin_auth_prompt(bool value) { |
| 2016 allow_cross_origin_auth_prompt_ = value; | 2013 allow_cross_origin_auth_prompt_ = value; |
| 2017 } | 2014 } |
| 2018 | 2015 |
| 2019 | 2016 |
| OLD | NEW |