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

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 <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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 request_.reportRawHeaders()); 624 request_.reportRawHeaders());
625 625
626 WebURLRequest new_request; 626 WebURLRequest new_request;
627 PopulateURLRequestForRedirect( 627 PopulateURLRequestForRedirect(
628 request_, redirect_info, referrer_policy_, 628 request_, redirect_info, referrer_policy_,
629 info.was_fetched_via_service_worker 629 info.was_fetched_via_service_worker
630 ? blink::WebURLRequest::SkipServiceWorker::None 630 ? blink::WebURLRequest::SkipServiceWorker::None
631 : blink::WebURLRequest::SkipServiceWorker::All, 631 : blink::WebURLRequest::SkipServiceWorker::All,
632 &new_request); 632 &new_request);
633 633
634 client_->willFollowRedirect(loader_, new_request, response, 634 bool follow = client_->willFollowRedirect(loader_, new_request, response,
635 info.encoded_data_length); 635 info.encoded_data_length);
636 request_ = new_request; 636 if (follow) {
637 request_ = new_request;
637 638
638 // Only follow the redirect if WebKit left the URL unmodified.
639 if (redirect_info.new_url == GURL(new_request.url())) {
640 // First-party cookie logic moved from DocumentLoader in Blink to 639 // First-party cookie logic moved from DocumentLoader in Blink to
641 // net::URLRequest in the browser. Assert that Blink didn't try to change it 640 // net::URLRequest in the browser. Assert that Blink didn't try to change it
642 // to something else. 641 // to something else.
643 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(), 642 DCHECK_EQ(redirect_info.new_first_party_for_cookies.spec(),
644 request_.firstPartyForCookies().string().utf8()); 643 request_.firstPartyForCookies().string().utf8());
645 return true; 644 return true;
646 } 645 }
647 646
648 // We assume that WebKit only changes the URL to suppress a redirect, and we 647 request_ = WebURLRequest();
649 // assume that it does so by setting it to be invalid. 648
650 DCHECK(!new_request.url().isValid());
651 return false; 649 return false;
652 } 650 }
653 651
654 void WebURLLoaderImpl::Context::OnReceivedResponse( 652 void WebURLLoaderImpl::Context::OnReceivedResponse(
655 const ResourceResponseInfo& initial_info) { 653 const ResourceResponseInfo& initial_info) {
656 if (!client_) 654 if (!client_)
657 return; 655 return;
658 656
659 TRACE_EVENT_WITH_FLOW0( 657 TRACE_EVENT_WITH_FLOW0(
660 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse", 658 "loading", "WebURLLoaderImpl::Context::OnReceivedResponse",
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 response->clearHTTPHeaderField(webStringName); 1240 response->clearHTTPHeaderField(webStringName);
1243 while (response_headers->EnumerateHeader(&iterator, name, &value)) { 1241 while (response_headers->EnumerateHeader(&iterator, name, &value)) {
1244 response->addHTTPHeaderField(webStringName, 1242 response->addHTTPHeaderField(webStringName,
1245 WebString::fromLatin1(value)); 1243 WebString::fromLatin1(value));
1246 } 1244 }
1247 } 1245 }
1248 return true; 1246 return true;
1249 } 1247 }
1250 1248
1251 } // namespace content 1249 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/web_url_loader_impl_unittest.cc » ('j') | content/renderer/pepper/pepper_url_loader_host.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698