| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 std::string())); // No security info needed, connection was not | 357 std::string())); // No security info needed, connection was not |
| 358 // established. | 358 // established. |
| 359 } | 359 } |
| 360 return; | 360 return; |
| 361 } | 361 } |
| 362 | 362 |
| 363 // Note that context can still be NULL here when running unit tests. | 363 // Note that context can still be NULL here when running unit tests. |
| 364 Blacklist::Match* match = context && context->blacklist() ? | 364 Blacklist::Match* match = context && context->blacklist() ? |
| 365 context->blacklist()->findMatch(request_data.url) : NULL; | 365 context->blacklist()->findMatch(request_data.url) : NULL; |
| 366 if (match && match->IsBlocked(request_data.url)) { | 366 if (match && match->IsBlocked(request_data.url)) { |
| 367 // TODO(idanan): Send a ResourceResponse to replace the blocked resource. | 367 // TODO(idanan): Send a ResourceResponse to replace the blocked resource |
| 368 // instead of the FAILED return code below. |
| 368 delete match; | 369 delete match; |
| 370 URLRequestStatus status(URLRequestStatus::FAILED, net::ERR_ABORTED); |
| 371 if (sync_result) { |
| 372 SyncLoadResult result; |
| 373 result.status = status; |
| 374 ViewHostMsg_SyncLoad::WriteReplyParams(sync_result, result); |
| 375 receiver_->Send(sync_result); |
| 376 } else { |
| 377 // Tell the renderer that this request was disallowed. |
| 378 receiver_->Send(new ViewMsg_Resource_RequestComplete( |
| 379 route_id, |
| 380 request_id, |
| 381 status, |
| 382 std::string())); // No connection, security info not needed. |
| 383 } |
| 369 return; | 384 return; |
| 370 } | 385 } |
| 371 | 386 |
| 372 // Ensure the Chrome plugins are loaded, as they may intercept network | 387 // Ensure the Chrome plugins are loaded, as they may intercept network |
| 373 // requests. Does nothing if they are already loaded. | 388 // requests. Does nothing if they are already loaded. |
| 374 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by | 389 // TODO(mpcomplete): This takes 200 ms! Investigate parallelizing this by |
| 375 // starting the load earlier in a BG thread. | 390 // starting the load earlier in a BG thread. |
| 376 plugin_service_->LoadChromePlugins(this); | 391 plugin_service_->LoadChromePlugins(this); |
| 377 | 392 |
| 378 // Construct the event handler. | 393 // Construct the event handler. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 390 | 405 |
| 391 if (HandleExternalProtocol(request_id, process_id, route_id, | 406 if (HandleExternalProtocol(request_id, process_id, route_id, |
| 392 request_data.url, request_data.resource_type, | 407 request_data.url, request_data.resource_type, |
| 393 handler)) { | 408 handler)) { |
| 394 return; | 409 return; |
| 395 } | 410 } |
| 396 | 411 |
| 397 // Construct the request. | 412 // Construct the request. |
| 398 URLRequest* request = new URLRequest(request_data.url, this); | 413 URLRequest* request = new URLRequest(request_data.url, this); |
| 399 if (match) { | 414 if (match) { |
| 400 request->SetUserData((void*)&Blacklist::kRequestDataKey, match); | 415 request->SetUserData(&Blacklist::kRequestDataKey, match); |
| 401 } | 416 } |
| 402 request->set_method(request_data.method); | 417 request->set_method(request_data.method); |
| 403 request->set_first_party_for_cookies(request_data.first_party_for_cookies); | 418 request->set_first_party_for_cookies(request_data.first_party_for_cookies); |
| 404 | 419 |
| 405 if (!match || !(match->attributes() & Blacklist::kDontSendReferrer)) | 420 if (!match || !(match->attributes() & Blacklist::kDontSendReferrer)) |
| 406 request->set_referrer(request_data.referrer.spec()); | 421 request->set_referrer(request_data.referrer.spec()); |
| 407 | 422 |
| 408 request->SetExtraRequestHeaders(request_data.headers); | 423 request->SetExtraRequestHeaders(request_data.headers); |
| 409 | 424 |
| 410 int load_flags = request_data.load_flags; | 425 int load_flags = request_data.load_flags; |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1004 response->response_head.status = request->status(); | 1019 response->response_head.status = request->status(); |
| 1005 response->response_head.request_time = request->request_time(); | 1020 response->response_head.request_time = request->request_time(); |
| 1006 response->response_head.response_time = request->response_time(); | 1021 response->response_head.response_time = request->response_time(); |
| 1007 response->response_head.headers = request->response_headers(); | 1022 response->response_head.headers = request->response_headers(); |
| 1008 request->GetCharset(&response->response_head.charset); | 1023 request->GetCharset(&response->response_head.charset); |
| 1009 response->response_head.filter_policy = info->filter_policy; | 1024 response->response_head.filter_policy = info->filter_policy; |
| 1010 response->response_head.content_length = request->GetExpectedContentSize(); | 1025 response->response_head.content_length = request->GetExpectedContentSize(); |
| 1011 response->response_head.app_cache_id = WebAppCacheContext::kNoAppCacheId; | 1026 response->response_head.app_cache_id = WebAppCacheContext::kNoAppCacheId; |
| 1012 request->GetMimeType(&response->response_head.mime_type); | 1027 request->GetMimeType(&response->response_head.mime_type); |
| 1013 | 1028 |
| 1029 const URLRequest::UserData* d = |
| 1030 request->GetUserData(&Blacklist::kRequestDataKey); |
| 1031 if (d) { |
| 1032 const Blacklist::Match* match = static_cast<const Blacklist::Match*>(d); |
| 1033 if (match->attributes() & Blacklist::kBlockByType) { |
| 1034 if (match->MatchType(response->response_head.mime_type)) |
| 1035 return false; // TODO(idanan): Generate a replacement response. |
| 1036 } |
| 1037 } |
| 1038 |
| 1014 if (request->ssl_info().cert) { | 1039 if (request->ssl_info().cert) { |
| 1015 int cert_id = | 1040 int cert_id = |
| 1016 CertStore::GetSharedInstance()->StoreCert( | 1041 CertStore::GetSharedInstance()->StoreCert( |
| 1017 request->ssl_info().cert, | 1042 request->ssl_info().cert, |
| 1018 info->process_id); | 1043 info->process_id); |
| 1019 response->response_head.security_info = | 1044 response->response_head.security_info = |
| 1020 SSLManager::SerializeSecurityInfo(cert_id, | 1045 SSLManager::SerializeSecurityInfo(cert_id, |
| 1021 request->ssl_info().cert_status, | 1046 request->ssl_info().cert_status, |
| 1022 request->ssl_info().security_bits); | 1047 request->ssl_info().security_bits); |
| 1023 } else { | 1048 } else { |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 case ViewHostMsg_UploadProgress_ACK::ID: | 1645 case ViewHostMsg_UploadProgress_ACK::ID: |
| 1621 case ViewHostMsg_SyncLoad::ID: | 1646 case ViewHostMsg_SyncLoad::ID: |
| 1622 return true; | 1647 return true; |
| 1623 | 1648 |
| 1624 default: | 1649 default: |
| 1625 break; | 1650 break; |
| 1626 } | 1651 } |
| 1627 | 1652 |
| 1628 return false; | 1653 return false; |
| 1629 } | 1654 } |
| OLD | NEW |