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

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, 2 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
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 request_.reportRawHeaders()); 636 request_.reportRawHeaders());
637 637
638 WebURLRequest new_request; 638 WebURLRequest new_request;
639 PopulateURLRequestForRedirect( 639 PopulateURLRequestForRedirect(
640 request_, redirect_info, referrer_policy_, 640 request_, redirect_info, referrer_policy_,
641 info.was_fetched_via_service_worker 641 info.was_fetched_via_service_worker
642 ? blink::WebURLRequest::SkipServiceWorker::None 642 ? blink::WebURLRequest::SkipServiceWorker::None
643 : blink::WebURLRequest::SkipServiceWorker::All, 643 : blink::WebURLRequest::SkipServiceWorker::All,
644 &new_request); 644 &new_request);
645 645
646 client_->willFollowRedirect(loader_, new_request, response); 646 bool follow = client_->willFollowRedirect(loader_, new_request, response);
647 if (!follow) {
648 request_ = WebURLRequest();
649
650 return false;
651 }
652
653 DCHECK(WebURL(redirect_info.new_url) == new_request.url());
654
647 request_ = new_request; 655 request_ = new_request;
648 656
649 // Only follow the redirect if WebKit left the URL unmodified. 657 // First-party cookie logic moved from DocumentLoader in Blink to
650 if (redirect_info.new_url == GURL(new_request.url())) { 658 // net::URLRequest in the browser. Assert that Blink didn't try to change it
651 // First-party cookie logic moved from DocumentLoader in Blink to 659 // to something else.
652 // net::URLRequest in the browser. Assert that Blink didn't try to change it 660 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
653 // to something else. 661 request_.firstPartyForCookies().string().utf8());
654 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 662 return true;
655 request_.firstPartyForCookies().string().utf8());
656 return true;
657 }
658
659 // We assume that WebKit only changes the URL to suppress a redirect, and we
660 // assume that it does so by setting it to be invalid.
661 DCHECK(!new_request.url().isValid());
662 return false;
663 } 663 }
664 664
665 void WebURLLoaderImpl::Context::OnReceivedResponse( 665 void WebURLLoaderImpl::Context::OnReceivedResponse(
666 const ResourceResponseInfo& initial_info) { 666 const ResourceResponseInfo& initial_info) {
667 if (!client_) 667 if (!client_)
668 return; 668 return;
669 669
670 TRACE_EVENT_WITH_FLOW0( 670 TRACE_EVENT_WITH_FLOW0(
671 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse", 671 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse",
672 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT); 672 this, TRACE_EVENT_FLAG_FLOW_IN | TRACE_EVENT_FLAG_FLOW_OUT);
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
1269 response->clearHTTPHeaderField(webStringName); 1269 response->clearHTTPHeaderField(webStringName);
1270 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1270 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1271 response->addHTTPHeaderField(webStringName, 1271 response->addHTTPHeaderField(webStringName,
1272 WebString::fromLatin1(value)); 1272 WebString::fromLatin1(value));
1273 } 1273 }
1274 } 1274 }
1275 return true; 1275 return true;
1276 } 1276 }
1277 1277
1278 } // namespace content 1278 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698