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 <openssl/ssl.h> | 7 #include <openssl/ssl.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 valid_start.ToDoubleT(), | 322 valid_start.ToDoubleT(), |
323 valid_expiry.ToDoubleT(), | 323 valid_expiry.ToDoubleT(), |
324 web_cert, | 324 web_cert, |
325 sct_list); | 325 sct_list); |
326 | 326 |
327 response->setSecurityDetails(webSecurityDetails); | 327 response->setSecurityDetails(webSecurityDetails); |
328 } | 328 } |
329 | 329 |
330 } // namespace | 330 } // namespace |
331 | 331 |
| 332 StreamOverrideParameters::StreamOverrideParameters() {} |
| 333 StreamOverrideParameters::~StreamOverrideParameters() {} |
| 334 |
332 // This inner class exists since the WebURLLoader may be deleted while inside a | 335 // This inner class exists since the WebURLLoader may be deleted while inside a |
333 // call to WebURLLoaderClient. Refcounting is to keep the context from being | 336 // call to WebURLLoaderClient. Refcounting is to keep the context from being |
334 // deleted if it may have work to do after calling into the client. | 337 // deleted if it may have work to do after calling into the client. |
335 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { | 338 class WebURLLoaderImpl::Context : public base::RefCounted<Context> { |
336 public: | 339 public: |
337 using ReceivedData = RequestPeer::ReceivedData; | 340 using ReceivedData = RequestPeer::ReceivedData; |
338 | 341 |
339 Context(WebURLLoaderImpl* loader, | 342 Context(WebURLLoaderImpl* loader, |
340 ResourceDispatcher* resource_dispatcher, | 343 ResourceDispatcher* resource_dispatcher, |
341 mojom::URLLoaderFactory* factory); | 344 mojom::URLLoaderFactory* factory); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 request_.reportRawHeaders()); | 636 request_.reportRawHeaders()); |
634 | 637 |
635 WebURLRequest new_request; | 638 WebURLRequest new_request; |
636 PopulateURLRequestForRedirect( | 639 PopulateURLRequestForRedirect( |
637 request_, redirect_info, referrer_policy_, | 640 request_, redirect_info, referrer_policy_, |
638 info.was_fetched_via_service_worker | 641 info.was_fetched_via_service_worker |
639 ? blink::WebURLRequest::SkipServiceWorker::None | 642 ? blink::WebURLRequest::SkipServiceWorker::None |
640 : blink::WebURLRequest::SkipServiceWorker::All, | 643 : blink::WebURLRequest::SkipServiceWorker::All, |
641 &new_request); | 644 &new_request); |
642 | 645 |
643 client_->willFollowRedirect(loader_, new_request, response, | 646 client_->willFollowRedirect(loader_, new_request, response); |
644 info.encoded_data_length); | |
645 request_ = new_request; | 647 request_ = new_request; |
646 | 648 |
647 // Only follow the redirect if WebKit left the URL unmodified. | 649 // Only follow the redirect if WebKit left the URL unmodified. |
648 if (redirect_info.new_url == GURL(new_request.url())) { | 650 if (redirect_info.new_url == GURL(new_request.url())) { |
649 // First-party cookie logic moved from DocumentLoader in Blink to | 651 // First-party cookie logic moved from DocumentLoader in Blink to |
650 // net::URLRequest in the browser. Assert that Blink didn't try to change it | 652 // net::URLRequest in the browser. Assert that Blink didn't try to change it |
651 // to something else. | 653 // to something else. |
652 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), | 654 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), |
653 request_.firstPartyForCookies().string().utf8()); | 655 request_.firstPartyForCookies().string().utf8()); |
654 return true; | 656 return true; |
(...skipping 20 matching lines...) Expand all Loading... |
675 // received on the browser side, and has been passed down to the renderer. | 677 // received on the browser side, and has been passed down to the renderer. |
676 if (stream_override_.get()) { | 678 if (stream_override_.get()) { |
677 CHECK(IsBrowserSideNavigationEnabled()); | 679 CHECK(IsBrowserSideNavigationEnabled()); |
678 info = stream_override_->response; | 680 info = stream_override_->response; |
679 } | 681 } |
680 | 682 |
681 WebURLResponse response; | 683 WebURLResponse response; |
682 PopulateURLResponse(request_.url(), info, &response, | 684 PopulateURLResponse(request_.url(), info, &response, |
683 request_.reportRawHeaders()); | 685 request_.reportRawHeaders()); |
684 | 686 |
| 687 if (stream_override_.get()) { |
| 688 CHECK(IsBrowserSideNavigationEnabled()); |
| 689 DCHECK(stream_override_->redirect_responses.size() == |
| 690 stream_override_->redirects.size()); |
| 691 for (size_t i = 0; i < stream_override_->redirects.size(); ++i) { |
| 692 WebURLResponse previous_response; |
| 693 // TODO(arthursonzogni) Once Devtool is supported by PlzNavigate, the |
| 694 // |report_raw_header| argument must be checked. |
| 695 WebURLLoaderImpl::PopulateURLResponse( |
| 696 stream_override_->redirects[i], |
| 697 stream_override_->redirect_responses[i], |
| 698 &previous_response, |
| 699 request_.reportRawHeaders()); |
| 700 response.appendRedirectResponse(previous_response); |
| 701 } |
| 702 } |
| 703 |
685 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); | 704 bool show_raw_listing = (GURL(request_.url()).query() == "raw"); |
686 | 705 |
687 if (info.mime_type == "text/vnd.chromium.ftp-dir") { | 706 if (info.mime_type == "text/vnd.chromium.ftp-dir") { |
688 if (show_raw_listing) { | 707 if (show_raw_listing) { |
689 // Set the MIME type to plain text to prevent any active content. | 708 // Set the MIME type to plain text to prevent any active content. |
690 response.setMIMEType("text/plain"); | 709 response.setMIMEType("text/plain"); |
691 } else { | 710 } else { |
692 // We're going to produce a parsed listing in HTML. | 711 // We're going to produce a parsed listing in HTML. |
693 response.setMIMEType("text/html"); | 712 response.setMIMEType("text/html"); |
694 } | 713 } |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 info.is_in_cache_storage | 1028 info.is_in_cache_storage |
1010 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) | 1029 ? blink::WebString::fromUTF8(info.cache_storage_cache_name) |
1011 : blink::WebString()); | 1030 : blink::WebString()); |
1012 blink::WebVector<blink::WebString> cors_exposed_header_names( | 1031 blink::WebVector<blink::WebString> cors_exposed_header_names( |
1013 info.cors_exposed_header_names.size()); | 1032 info.cors_exposed_header_names.size()); |
1014 std::transform( | 1033 std::transform( |
1015 info.cors_exposed_header_names.begin(), | 1034 info.cors_exposed_header_names.begin(), |
1016 info.cors_exposed_header_names.end(), cors_exposed_header_names.begin(), | 1035 info.cors_exposed_header_names.end(), cors_exposed_header_names.begin(), |
1017 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); | 1036 [](const std::string& h) { return blink::WebString::fromLatin1(h); }); |
1018 response->setCorsExposedHeaderNames(cors_exposed_header_names); | 1037 response->setCorsExposedHeaderNames(cors_exposed_header_names); |
| 1038 response->addToEncodedDataLength(info.encoded_data_length); |
1019 | 1039 |
1020 SetSecurityStyleAndDetails(url, info, response, report_security_info); | 1040 SetSecurityStyleAndDetails(url, info, response, report_security_info); |
1021 | 1041 |
1022 WebURLResponseExtraDataImpl* extra_data = | 1042 WebURLResponseExtraDataImpl* extra_data = |
1023 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); | 1043 new WebURLResponseExtraDataImpl(info.npn_negotiated_protocol); |
1024 response->setExtraData(extra_data); | 1044 response->setExtraData(extra_data); |
1025 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); | 1045 extra_data->set_was_fetched_via_spdy(info.was_fetched_via_spdy); |
1026 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); | 1046 extra_data->set_was_npn_negotiated(info.was_npn_negotiated); |
1027 extra_data->set_was_alternate_protocol_available( | 1047 extra_data->set_was_alternate_protocol_available( |
1028 info.was_alternate_protocol_available); | 1048 info.was_alternate_protocol_available); |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1251 response->clearHTTPHeaderField(webStringName); | 1271 response->clearHTTPHeaderField(webStringName); |
1252 while (response_headers->EnumerateHeader(&iterator, name, &value)) { | 1272 while (response_headers->EnumerateHeader(&iterator, name, &value)) { |
1253 response->addHTTPHeaderField(webStringName, | 1273 response->addHTTPHeaderField(webStringName, |
1254 WebString::fromLatin1(value)); | 1274 WebString::fromLatin1(value)); |
1255 } | 1275 } |
1256 } | 1276 } |
1257 return true; | 1277 return true; |
1258 } | 1278 } |
1259 | 1279 |
1260 } // namespace content | 1280 } // namespace content |
OLD | NEW |