Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: content/child/web_url_loader_impl.cc

Issue 2230173002: Change WebURLLoaderClient::willFollowRedirect() API to return bool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 request_.reportRawHeaders()); 591 request_.reportRawHeaders());
592 592
593 WebURLRequest new_request; 593 WebURLRequest new_request;
594 PopulateURLRequestForRedirect( 594 PopulateURLRequestForRedirect(
595 request_, redirect_info, referrer_policy_, 595 request_, redirect_info, referrer_policy_,
596 info.was_fetched_via_service_worker 596 info.was_fetched_via_service_worker
597 ? blink::WebURLRequest::SkipServiceWorker::None 597 ? blink::WebURLRequest::SkipServiceWorker::None
598 : blink::WebURLRequest::SkipServiceWorker::All, 598 : blink::WebURLRequest::SkipServiceWorker::All,
599 &new_request); 599 &new_request);
600 600
601 client_->willFollowRedirect(loader_, new_request, response, 601 bool follow = client_->willFollowRedirect(loader_, new_request, response,
602 info.encoded_data_length); 602 info.encoded_data_length);
603 request_ = new_request; 603 if (follow) {
604 request_ = new_request;
604 605
605 // Only follow the redirect if WebKit left the URL unmodified.
606 if (redirect_info.new_url == GURL(new_request.url())) {
607 // First-party cookie logic moved from DocumentLoader in Blink to 606 // First-party cookie logic moved from DocumentLoader in Blink to
608 // net::URLRequest in the browser. Assert that Blink didn't try to change it 607 // net::URLRequest in the browser. Assert that Blink didn't try to change it
609 // to something else. 608 // to something else.
610 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 609 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
611 request_.firstPartyForCookies().string().utf8()); 610 request_.firstPartyForCookies().string().utf8());
612 return true; 611 return true;
613 } 612 }
614 613
615 // We assume that WebKit only changes the URL to suppress a redirect, and we 614 request_ = WebURLRequest();
616 // assume that it does so by setting it to be invalid. 615
617 DCHECK(!new_request.url().isValid());
618 return false; 616 return false;
619 } 617 }
620 618
621 void WebURLLoaderImpl::Context::OnReceivedResponse( 619 void WebURLLoaderImpl::Context::OnReceivedResponse(
622 const ResourceResponseInfo& initial_info) { 620 const ResourceResponseInfo& initial_info) {
623 if (!client_) 621 if (!client_)
624 return; 622 return;
625 623
626 TRACE_EVENT_WITH_FLOW0( 624 TRACE_EVENT_WITH_FLOW0(
627 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse", 625 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse",
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 response->clearHTTPHeaderField(webStringName); 1211 response->clearHTTPHeaderField(webStringName);
1214 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1212 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1215 response->addHTTPHeaderField(webStringName, 1213 response->addHTTPHeaderField(webStringName,
1216 WebString::fromLatin1(value)); 1214 WebString::fromLatin1(value));
1217 } 1215 }
1218 } 1216 }
1219 return true; 1217 return true;
1220 } 1218 }
1221 1219
1222 } // namespace content 1220 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | media/blink/resource_multibuffer_data_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698