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

Side by Side Diff: third_party/WebKit/Source/core/fetch/ResourceLoader.cpp

Issue 2535383003: Collapse images disallowed by the Safe Browsing Subresource Filter. (Closed)
Patch Set: Initial draft. Created 4 years 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 /* 1 /*
2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2010, 2011 Apple Inc. All rights reserved.
3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com) 3 * (C) 2007 Graham Dennis (graham.dennis@gmail.com)
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 m_loader->didChangePriority( 129 m_loader->didChangePriority(
130 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue); 130 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue);
131 } 131 }
132 } 132 }
133 133
134 void ResourceLoader::cancel() { 134 void ResourceLoader::cancel() {
135 didFail( 135 didFail(
136 ResourceError::cancelledError(m_resource->lastResourceRequest().url())); 136 ResourceError::cancelledError(m_resource->lastResourceRequest().url()));
137 } 137 }
138 138
139 void ResourceLoader::cancelForRedirectAccessCheckError(const KURL& newURL) { 139 void ResourceLoader::cancelForRedirectAccessCheckError(
140 const KURL& newURL,
141 ResourceRequestBlockedReason blockedReason) {
140 m_resource->willNotFollowRedirect(); 142 m_resource->willNotFollowRedirect();
141 143
142 if (m_loader) 144 if (m_loader) {
143 didFail(ResourceError::cancelledDueToAccessCheckError(newURL)); 145 didFail(
146 ResourceError::cancelledDueToAccessCheckError(newURL, blockedReason));
147 }
144 } 148 }
145 149
146 bool ResourceLoader::willFollowRedirect( 150 bool ResourceLoader::willFollowRedirect(
147 WebURLLoader*, 151 WebURLLoader*,
148 WebURLRequest& passedNewRequest, 152 WebURLRequest& passedNewRequest,
149 const WebURLResponse& passedRedirectResponse) { 153 const WebURLResponse& passedRedirectResponse) {
150 DCHECK(!passedNewRequest.isNull()); 154 DCHECK(!passedNewRequest.isNull());
151 DCHECK(!passedRedirectResponse.isNull()); 155 DCHECK(!passedRedirectResponse.isNull());
152 156
153 if (m_isCacheAwareLoadingActivated) { 157 if (m_isCacheAwareLoadingActivated) {
154 // Fail as cache miss if cached response is a redirect. 158 // Fail as cache miss if cached response is a redirect.
155 didFail( 159 didFail(
156 ResourceError::cacheMissError(m_resource->lastResourceRequest().url())); 160 ResourceError::cacheMissError(m_resource->lastResourceRequest().url()));
157 return false; 161 return false;
158 } 162 }
159 163
160 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); 164 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
161 const ResourceResponse& redirectResponse( 165 const ResourceResponse& redirectResponse(
162 passedRedirectResponse.toResourceResponse()); 166 passedRedirectResponse.toResourceResponse());
163 newRequest.setRedirectStatus( 167 newRequest.setRedirectStatus(
164 ResourceRequest::RedirectStatus::FollowedRedirect); 168 ResourceRequest::RedirectStatus::FollowedRedirect);
165 169
166 const KURL originalURL = newRequest.url(); 170 const KURL originalURL = newRequest.url();
167 171
168 if (!m_fetcher->willFollowRedirect(m_resource.get(), newRequest, 172 ResourceRequestBlockedReason blockedReason = m_fetcher->willFollowRedirect(
169 redirectResponse)) { 173 m_resource.get(), newRequest, redirectResponse);
170 cancelForRedirectAccessCheckError(newRequest.url()); 174 if (blockedReason != ResourceRequestBlockedReason::None) {
175 cancelForRedirectAccessCheckError(newRequest.url(), blockedReason);
171 return false; 176 return false;
172 } 177 }
173 178
174 // ResourceFetcher::willFollowRedirect() may rewrite the URL to 179 // ResourceFetcher::willFollowRedirect() may rewrite the URL to
175 // something else not for rejecting redirect but for other reasons. 180 // something else not for rejecting redirect but for other reasons.
176 // E.g. WebFrameTestClient::willSendRequest() and 181 // E.g. WebFrameTestClient::willSendRequest() and
177 // RenderFrameImpl::willSendRequest(). We should reflect the 182 // RenderFrameImpl::willSendRequest(). We should reflect the
178 // rewriting but currently we cannot. So, return false to make the 183 // rewriting but currently we cannot. So, return false to make the
179 // redirect fail. 184 // redirect fail.
180 if (newRequest.url() != originalURL) { 185 if (newRequest.url() != originalURL) {
181 cancelForRedirectAccessCheckError(newRequest.url()); 186 cancelForRedirectAccessCheckError(newRequest.url(),
187 ResourceRequestBlockedReason::Other);
182 return false; 188 return false;
183 } 189 }
184 190
185 if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) { 191 if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) {
186 cancelForRedirectAccessCheckError(newRequest.url()); 192 cancelForRedirectAccessCheckError(newRequest.url(),
193 ResourceRequestBlockedReason::Other);
187 return false; 194 return false;
188 } 195 }
189 196
190 return true; 197 return true;
191 } 198 }
192 199
193 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*, 200 void ResourceLoader::didReceiveCachedMetadata(WebURLLoader*,
194 const char* data, 201 const char* data,
195 int length) { 202 int length) {
196 m_resource->setSerializedCachedMetadata(data, length); 203 m_resource->setSerializedCachedMetadata(data, length);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 return; 327 return;
321 328
322 // Don't activate if cache policy is explicitly set. 329 // Don't activate if cache policy is explicitly set.
323 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) 330 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy)
324 return; 331 return;
325 332
326 m_isCacheAwareLoadingActivated = true; 333 m_isCacheAwareLoadingActivated = true;
327 } 334 }
328 335
329 } // namespace blink 336 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698