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

Unified Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
diff --git a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
index 5085721e81f06b478dd8247f3a6191cd55106163..6396070d6eaf4cb2a98aa23d1ecb4248f0487200 100644
--- a/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
+++ b/third_party/WebKit/Source/core/fetch/ResourceLoader.cpp
@@ -123,7 +123,7 @@ void ResourceLoader::cancel()
didFail(nullptr, ResourceError::cancelledError(m_resource->lastResourceRequest().url()));
}
-void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength)
+bool ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewRequest, const WebURLResponse& passedRedirectResponse, int64_t encodedDataLength)
{
ASSERT(!passedNewRequest.isNull());
ASSERT(!passedRedirectResponse.isNull());
@@ -132,12 +132,24 @@ void ResourceLoader::willFollowRedirect(WebURLLoader*, WebURLRequest& passedNewR
const ResourceResponse& redirectResponse(passedRedirectResponse.toResourceResponse());
newRequest.setRedirectStatus(ResourceRequest::RedirectStatus::FollowedRedirect);
+ const KURL originalURL = newRequest.url();
if (m_fetcher->willFollowRedirect(m_resource.get(), newRequest, redirectResponse, encodedDataLength)) {
Nate Chapin 2016/09/07 17:05:45 This nesting is a bit difficult to reason about, i
tyoshino (SeeGerritForStatus) 2016/09/14 14:53:47 Nice suggestion. Reorganized.
- m_resource->willFollowRedirect(newRequest, redirectResponse);
+ if (m_resource->willFollowRedirect(newRequest, redirectResponse)) {
+ // ResourceFetcher::willFollowRedirect() may rewrite the URL to
+ // something else not for rejecting redirect but for other reasons.
+ // E.g. WebFrameTestClient::willSendRequest() and
+ // RenderFrameImpl::willSendRequest(). We should reflect the
+ // rewriting but currently we cannot. So, return false to make the
+ // redirect fail.
+ return newRequest.url() == originalURL;
+ }
+
+ return false;
} else {
m_resource->willNotFollowRedirect();
if (m_loader)
didFail(nullptr, ResourceError::cancelledDueToAccessCheckError(newRequest.url()));
+ return false;
}
}
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.h ('k') | third_party/WebKit/Source/core/loader/DocumentLoader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698