| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // the render process, so we can use requestorProcessID even for requests | 527 // the render process, so we can use requestorProcessID even for requests |
| 528 // from in-process plugins. | 528 // from in-process plugins. |
| 529 request_info.requestor_pid = request.requestorProcessID(); | 529 request_info.requestor_pid = request.requestorProcessID(); |
| 530 request_info.request_type = WebURLRequestToResourceType(request); | 530 request_info.request_type = WebURLRequestToResourceType(request); |
| 531 request_info.priority = | 531 request_info.priority = |
| 532 ConvertWebKitPriorityToNetPriority(request.getPriority()); | 532 ConvertWebKitPriorityToNetPriority(request.getPriority()); |
| 533 request_info.appcache_host_id = request.appCacheHostID(); | 533 request_info.appcache_host_id = request.appCacheHostID(); |
| 534 request_info.routing_id = request.requestorID(); | 534 request_info.routing_id = request.requestorID(); |
| 535 request_info.download_to_file = request.downloadToFile(); | 535 request_info.download_to_file = request.downloadToFile(); |
| 536 request_info.has_user_gesture = request.hasUserGesture(); | 536 request_info.has_user_gesture = request.hasUserGesture(); |
| 537 request_info.skip_service_worker = request.skipServiceWorker(); | 537 request_info.skip_service_worker = |
| 538 GetSkipServiceWorkerForWebURLRequest(request); |
| 538 request_info.should_reset_appcache = request.shouldResetAppCache(); | 539 request_info.should_reset_appcache = request.shouldResetAppCache(); |
| 539 request_info.fetch_request_mode = | 540 request_info.fetch_request_mode = |
| 540 GetFetchRequestModeForWebURLRequest(request); | 541 GetFetchRequestModeForWebURLRequest(request); |
| 541 request_info.fetch_credentials_mode = | 542 request_info.fetch_credentials_mode = |
| 542 GetFetchCredentialsModeForWebURLRequest(request); | 543 GetFetchCredentialsModeForWebURLRequest(request); |
| 543 request_info.fetch_redirect_mode = | 544 request_info.fetch_redirect_mode = |
| 544 GetFetchRedirectModeForWebURLRequest(request); | 545 GetFetchRedirectModeForWebURLRequest(request); |
| 545 request_info.fetch_request_context_type = | 546 request_info.fetch_request_context_type = |
| 546 GetRequestContextTypeForWebURLRequest(request); | 547 GetRequestContextTypeForWebURLRequest(request); |
| 547 request_info.fetch_frame_type = | 548 request_info.fetch_frame_type = |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 "loading", "WebURLLoaderImpl::Context::OnReceivedRedirect", | 602 "loading", "WebURLLoaderImpl::Context::OnReceivedRedirect", |
| 602 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 603 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
| 603 | 604 |
| 604 WebURLResponse response; | 605 WebURLResponse response; |
| 605 response.initialize(); | 606 response.initialize(); |
| 606 PopulateURLResponse(request_.url(), info, &response, | 607 PopulateURLResponse(request_.url(), info, &response, |
| 607 request_.reportRawHeaders()); | 608 request_.reportRawHeaders()); |
| 608 | 609 |
| 609 WebURLRequest new_request; | 610 WebURLRequest new_request; |
| 610 new_request.initialize(); | 611 new_request.initialize(); |
| 611 PopulateURLRequestForRedirect(request_, redirect_info, referrer_policy_, | 612 PopulateURLRequestForRedirect( |
| 612 !info.was_fetched_via_service_worker, | 613 request_, redirect_info, referrer_policy_, |
| 613 &new_request); | 614 info.was_fetched_via_service_worker |
| 615 ? blink::WebURLRequest::SkipServiceWorker::None |
| 616 : blink::WebURLRequest::SkipServiceWorker::All, |
| 617 &new_request); |
| 614 | 618 |
| 615 client_->willFollowRedirect(loader_, new_request, response); | 619 client_->willFollowRedirect(loader_, new_request, response); |
| 616 request_ = new_request; | 620 request_ = new_request; |
| 617 | 621 |
| 618 // Only follow the redirect if WebKit left the URL unmodified. | 622 // Only follow the redirect if WebKit left the URL unmodified. |
| 619 if (redirect_info.new_url == GURL(new_request.url())) { | 623 if (redirect_info.new_url == GURL(new_request.url())) { |
| 620 // First-party cookie logic moved from DocumentLoader in Blink to | 624 // First-party cookie logic moved from DocumentLoader in Blink to |
| 621 // net::URLRequest in the browser. Assert that Blink didn't try to change it | 625 // net::URLRequest in the browser. Assert that Blink didn't try to change it |
| 622 // to something else. | 626 // to something else. |
| 623 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), | 627 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1092 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 1096 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
| 1093 response->addHTTPHeaderField(WebString::fromLatin1(name), | 1097 response->addHTTPHeaderField(WebString::fromLatin1(name), |
| 1094 WebString::fromLatin1(value)); | 1098 WebString::fromLatin1(value)); |
| 1095 } | 1099 } |
| 1096 } | 1100 } |
| 1097 | 1101 |
| 1098 void WebURLLoaderImpl::PopulateURLRequestForRedirect( | 1102 void WebURLLoaderImpl::PopulateURLRequestForRedirect( |
| 1099 const blink::WebURLRequest& request, | 1103 const blink::WebURLRequest& request, |
| 1100 const net::RedirectInfo& redirect_info, | 1104 const net::RedirectInfo& redirect_info, |
| 1101 blink::WebReferrerPolicy referrer_policy, | 1105 blink::WebReferrerPolicy referrer_policy, |
| 1102 bool skip_service_worker, | 1106 blink::WebURLRequest::SkipServiceWorker skip_service_worker, |
| 1103 blink::WebURLRequest* new_request) { | 1107 blink::WebURLRequest* new_request) { |
| 1104 // TODO(darin): We lack sufficient information to construct the actual | 1108 // TODO(darin): We lack sufficient information to construct the actual |
| 1105 // request that resulted from the redirect. | 1109 // request that resulted from the redirect. |
| 1106 new_request->setURL(redirect_info.new_url); | 1110 new_request->setURL(redirect_info.new_url); |
| 1107 new_request->setFirstPartyForCookies( | 1111 new_request->setFirstPartyForCookies( |
| 1108 redirect_info.new_first_party_for_cookies); | 1112 redirect_info.new_first_party_for_cookies); |
| 1109 new_request->setDownloadToFile(request.downloadToFile()); | 1113 new_request->setDownloadToFile(request.downloadToFile()); |
| 1110 new_request->setUseStreamOnResponse(request.useStreamOnResponse()); | 1114 new_request->setUseStreamOnResponse(request.useStreamOnResponse()); |
| 1111 new_request->setRequestContext(request.getRequestContext()); | 1115 new_request->setRequestContext(request.getRequestContext()); |
| 1112 new_request->setFrameType(request.getFrameType()); | 1116 new_request->setFrameType(request.getFrameType()); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1225 response->clearHTTPHeaderField(webStringName); | 1229 response->clearHTTPHeaderField(webStringName); |
| 1226 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1230 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
| 1227 response->addHTTPHeaderField(webStringName, | 1231 response->addHTTPHeaderField(webStringName, |
| 1228 WebString::fromLatin1(value)); | 1232 WebString::fromLatin1(value)); |
| 1229 } | 1233 } |
| 1230 } | 1234 } |
| 1231 return true; | 1235 return true; |
| 1232 } | 1236 } |
| 1233 | 1237 |
| 1234 } // namespace content | 1238 } // namespace content |
| OLD | NEW |