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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 // the render process, so we can use requestorProcessID even for requests | 499 // the render process, so we can use requestorProcessID even for requests |
500 // from in-process plugins. | 500 // from in-process plugins. |
501 request_info.requestor_pid = request.requestorProcessID(); | 501 request_info.requestor_pid = request.requestorProcessID(); |
502 request_info.request_type = WebURLRequestToResourceType(request); | 502 request_info.request_type = WebURLRequestToResourceType(request); |
503 request_info.priority = | 503 request_info.priority = |
504 ConvertWebKitPriorityToNetPriority(request.getPriority()); | 504 ConvertWebKitPriorityToNetPriority(request.getPriority()); |
505 request_info.appcache_host_id = request.appCacheHostID(); | 505 request_info.appcache_host_id = request.appCacheHostID(); |
506 request_info.routing_id = request.requestorID(); | 506 request_info.routing_id = request.requestorID(); |
507 request_info.download_to_file = request.downloadToFile(); | 507 request_info.download_to_file = request.downloadToFile(); |
508 request_info.has_user_gesture = request.hasUserGesture(); | 508 request_info.has_user_gesture = request.hasUserGesture(); |
509 request_info.skip_service_worker = request.skipServiceWorker(); | 509 request_info.skip_service_worker = |
510 GetSkipServiceWorkerForWebURLRequest(request); | |
510 request_info.should_reset_appcache = request.shouldResetAppCache(); | 511 request_info.should_reset_appcache = request.shouldResetAppCache(); |
511 request_info.fetch_request_mode = | 512 request_info.fetch_request_mode = |
512 GetFetchRequestModeForWebURLRequest(request); | 513 GetFetchRequestModeForWebURLRequest(request); |
513 request_info.fetch_credentials_mode = | 514 request_info.fetch_credentials_mode = |
514 GetFetchCredentialsModeForWebURLRequest(request); | 515 GetFetchCredentialsModeForWebURLRequest(request); |
515 request_info.fetch_redirect_mode = | 516 request_info.fetch_redirect_mode = |
516 GetFetchRedirectModeForWebURLRequest(request); | 517 GetFetchRedirectModeForWebURLRequest(request); |
517 request_info.fetch_request_context_type = | 518 request_info.fetch_request_context_type = |
518 GetRequestContextTypeForWebURLRequest(request); | 519 GetRequestContextTypeForWebURLRequest(request); |
519 request_info.fetch_frame_type = | 520 request_info.fetch_frame_type = |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
573 "loading", "WebURLLoaderImpl::Context::OnReceivedRedirect", | 574 "loading", "WebURLLoaderImpl::Context::OnReceivedRedirect", |
574 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); | 575 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); |
575 | 576 |
576 WebURLResponse response; | 577 WebURLResponse response; |
577 response.initialize(); | 578 response.initialize(); |
578 PopulateURLResponse(request_.url(), info, &response, | 579 PopulateURLResponse(request_.url(), info, &response, |
579 request_.reportRawHeaders()); | 580 request_.reportRawHeaders()); |
580 | 581 |
581 WebURLRequest new_request; | 582 WebURLRequest new_request; |
582 new_request.initialize(); | 583 new_request.initialize(); |
583 PopulateURLRequestForRedirect(request_, redirect_info, referrer_policy_, | 584 PopulateURLRequestForRedirect( |
584 !info.was_fetched_via_service_worker, | 585 request_, redirect_info, referrer_policy_, |
585 &new_request); | 586 info.was_fetched_via_service_worker |
587 ? blink::WebURLRequest::SkipServiceWorker::None | |
588 : blink::WebURLRequest::SkipServiceWorker::All, | |
horo
2016/06/28 12:10:02
What should happen in this case?
1. https://exampl
Marijn Kruisselbrink
2016/06/28 17:06:12
This reminds me that I still need to write the int
| |
589 &new_request); | |
586 | 590 |
587 client_->willFollowRedirect(loader_, new_request, response); | 591 client_->willFollowRedirect(loader_, new_request, response); |
588 request_ = new_request; | 592 request_ = new_request; |
589 | 593 |
590 // Only follow the redirect if WebKit left the URL unmodified. | 594 // Only follow the redirect if WebKit left the URL unmodified. |
591 if (redirect_info.new_url == GURL(new_request.url())) { | 595 if (redirect_info.new_url == GURL(new_request.url())) { |
592 // First-party cookie logic moved from DocumentLoader in Blink to | 596 // First-party cookie logic moved from DocumentLoader in Blink to |
593 // net::URLRequest in the browser. Assert that Blink didn't try to change it | 597 // net::URLRequest in the browser. Assert that Blink didn't try to change it |
594 // to something else. | 598 // to something else. |
595 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), | 599 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { | 1069 while (headers->EnumerateHeaderLines(&iter, &name, &value)) { |
1066 response->addHTTPHeaderField(WebString::fromLatin1(name), | 1070 response->addHTTPHeaderField(WebString::fromLatin1(name), |
1067 WebString::fromLatin1(value)); | 1071 WebString::fromLatin1(value)); |
1068 } | 1072 } |
1069 } | 1073 } |
1070 | 1074 |
1071 void WebURLLoaderImpl::PopulateURLRequestForRedirect( | 1075 void WebURLLoaderImpl::PopulateURLRequestForRedirect( |
1072 const blink::WebURLRequest& request, | 1076 const blink::WebURLRequest& request, |
1073 const net::RedirectInfo& redirect_info, | 1077 const net::RedirectInfo& redirect_info, |
1074 blink::WebReferrerPolicy referrer_policy, | 1078 blink::WebReferrerPolicy referrer_policy, |
1075 bool skip_service_worker, | 1079 blink::WebURLRequest::SkipServiceWorker skip_service_worker, |
1076 blink::WebURLRequest* new_request) { | 1080 blink::WebURLRequest* new_request) { |
1077 // TODO(darin): We lack sufficient information to construct the actual | 1081 // TODO(darin): We lack sufficient information to construct the actual |
1078 // request that resulted from the redirect. | 1082 // request that resulted from the redirect. |
1079 new_request->setURL(redirect_info.new_url); | 1083 new_request->setURL(redirect_info.new_url); |
1080 new_request->setFirstPartyForCookies( | 1084 new_request->setFirstPartyForCookies( |
1081 redirect_info.new_first_party_for_cookies); | 1085 redirect_info.new_first_party_for_cookies); |
1082 new_request->setDownloadToFile(request.downloadToFile()); | 1086 new_request->setDownloadToFile(request.downloadToFile()); |
1083 new_request->setUseStreamOnResponse(request.useStreamOnResponse()); | 1087 new_request->setUseStreamOnResponse(request.useStreamOnResponse()); |
1084 new_request->setRequestContext(request.getRequestContext()); | 1088 new_request->setRequestContext(request.getRequestContext()); |
1085 new_request->setFrameType(request.getFrameType()); | 1089 new_request->setFrameType(request.getFrameType()); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1198 response->clearHTTPHeaderField(webStringName); | 1202 response->clearHTTPHeaderField(webStringName); |
1199 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1203 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
1200 response->addHTTPHeaderField(webStringName, | 1204 response->addHTTPHeaderField(webStringName, |
1201 WebString::fromLatin1(value)); | 1205 WebString::fromLatin1(value)); |
1202 } | 1206 } |
1203 } | 1207 } |
1204 return true; | 1208 return true; |
1205 } | 1209 } |
1206 | 1210 |
1207 } // namespace content | 1211 } // namespace content |
OLD | NEW |