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

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

Powered by Google App Engine
This is Rietveld 408576698