| 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 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. | 5 // An implementation of WebURLLoader in terms of ResourceLoaderBridge. |
| 6 | 6 |
| 7 #include "webkit/child/weburlloader_impl.h" | 7 #include "webkit/child/weburlloader_impl.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 request_info.requestor_pid = request.requestorProcessID(); | 384 request_info.requestor_pid = request.requestorProcessID(); |
| 385 request_info.request_type = | 385 request_info.request_type = |
| 386 ResourceType::FromTargetType(request.targetType()); | 386 ResourceType::FromTargetType(request.targetType()); |
| 387 request_info.priority = | 387 request_info.priority = |
| 388 ConvertWebKitPriorityToNetPriority(request.priority()); | 388 ConvertWebKitPriorityToNetPriority(request.priority()); |
| 389 request_info.appcache_host_id = request.appCacheHostID(); | 389 request_info.appcache_host_id = request.appCacheHostID(); |
| 390 request_info.routing_id = request.requestorID(); | 390 request_info.routing_id = request.requestorID(); |
| 391 request_info.download_to_file = request.downloadToFile(); | 391 request_info.download_to_file = request.downloadToFile(); |
| 392 request_info.has_user_gesture = request.hasUserGesture(); | 392 request_info.has_user_gesture = request.hasUserGesture(); |
| 393 request_info.extra_data = request.extraData(); | 393 request_info.extra_data = request.extraData(); |
| 394 if (request.extraData()) { | 394 referrer_policy_ = request.referrerPolicy(); |
| 395 referrer_policy_ = static_cast<WebURLRequestExtraDataImpl*>( | 395 request_info.referrer_policy = request.referrerPolicy(); |
| 396 request.extraData())->referrer_policy(); | |
| 397 request_info.referrer_policy = referrer_policy_; | |
| 398 } | |
| 399 bridge_.reset(platform->CreateResourceLoader(request_info)); | 396 bridge_.reset(platform->CreateResourceLoader(request_info)); |
| 400 | 397 |
| 401 if (!request.httpBody().isNull()) { | 398 if (!request.httpBody().isNull()) { |
| 402 // GET and HEAD requests shouldn't have http bodies. | 399 // GET and HEAD requests shouldn't have http bodies. |
| 403 DCHECK(method != "GET" && method != "HEAD"); | 400 DCHECK(method != "GET" && method != "HEAD"); |
| 404 const WebHTTPBody& httpBody = request.httpBody(); | 401 const WebHTTPBody& httpBody = request.httpBody(); |
| 405 size_t i = 0; | 402 size_t i = 0; |
| 406 WebHTTPBody::Element element; | 403 WebHTTPBody::Element element; |
| 407 scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody; | 404 scoped_refptr<ResourceRequestBody> request_body = new ResourceRequestBody; |
| 408 while (httpBody.elementAt(i++, element)) { | 405 while (httpBody.elementAt(i++, element)) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 WebURLRequest new_request(new_url); | 480 WebURLRequest new_request(new_url); |
| 484 new_request.setFirstPartyForCookies(request_.firstPartyForCookies()); | 481 new_request.setFirstPartyForCookies(request_.firstPartyForCookies()); |
| 485 new_request.setDownloadToFile(request_.downloadToFile()); | 482 new_request.setDownloadToFile(request_.downloadToFile()); |
| 486 | 483 |
| 487 WebString referrer_string = WebString::fromUTF8("Referer"); | 484 WebString referrer_string = WebString::fromUTF8("Referer"); |
| 488 WebString referrer = WebSecurityPolicy::generateReferrerHeader( | 485 WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 489 referrer_policy_, | 486 referrer_policy_, |
| 490 new_url, | 487 new_url, |
| 491 request_.httpHeaderField(referrer_string)); | 488 request_.httpHeaderField(referrer_string)); |
| 492 if (!referrer.isEmpty()) | 489 if (!referrer.isEmpty()) |
| 493 new_request.setHTTPHeaderField(referrer_string, referrer); | 490 new_request.setHTTPReferrer(referrer, referrer_policy_); |
| 494 | 491 |
| 495 std::string new_method = net::URLRequest::ComputeMethodForRedirect( | 492 std::string new_method = net::URLRequest::ComputeMethodForRedirect( |
| 496 request_.httpMethod().utf8(), response.httpStatusCode()); | 493 request_.httpMethod().utf8(), response.httpStatusCode()); |
| 497 new_request.setHTTPMethod(WebString::fromUTF8(new_method)); | 494 new_request.setHTTPMethod(WebString::fromUTF8(new_method)); |
| 498 | 495 |
| 499 client_->willSendRequest(loader_, new_request, response); | 496 client_->willSendRequest(loader_, new_request, response); |
| 500 request_ = new_request; | 497 request_ = new_request; |
| 501 *has_new_first_party_for_cookies = true; | 498 *has_new_first_party_for_cookies = true; |
| 502 *new_first_party_for_cookies = request_.firstPartyForCookies(); | 499 *new_first_party_for_cookies = request_.firstPartyForCookies(); |
| 503 | 500 |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 850 |
| 854 void WebURLLoaderImpl::setDefersLoading(bool value) { | 851 void WebURLLoaderImpl::setDefersLoading(bool value) { |
| 855 context_->SetDefersLoading(value); | 852 context_->SetDefersLoading(value); |
| 856 } | 853 } |
| 857 | 854 |
| 858 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { | 855 void WebURLLoaderImpl::didChangePriority(WebURLRequest::Priority new_priority) { |
| 859 context_->DidChangePriority(new_priority); | 856 context_->DidChangePriority(new_priority); |
| 860 } | 857 } |
| 861 | 858 |
| 862 } // namespace webkit_glue | 859 } // namespace webkit_glue |
| OLD | NEW |