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

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: Rebase. 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 m_loader->didChangePriority( 126 m_loader->didChangePriority(
127 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue); 127 static_cast<WebURLRequest::Priority>(loadPriority), intraPriorityValue);
128 } 128 }
129 } 129 }
130 130
131 void ResourceLoader::cancel() { 131 void ResourceLoader::cancel() {
132 didFail( 132 didFail(
133 ResourceError::cancelledError(m_resource->lastResourceRequest().url())); 133 ResourceError::cancelledError(m_resource->lastResourceRequest().url()));
134 } 134 }
135 135
136 void ResourceLoader::cancelForRedirectAccessCheckError(const KURL& newURL) { 136 void ResourceLoader::cancelForRedirectAccessCheckError(
137 const KURL& newURL,
138 ResourceRequestBlockedReason blockedReason) {
137 m_resource->willNotFollowRedirect(); 139 m_resource->willNotFollowRedirect();
138 140
139 if (m_loader) 141 if (m_loader) {
140 didFail(ResourceError::cancelledDueToAccessCheckError(newURL)); 142 didFail(
143 ResourceError::cancelledDueToAccessCheckError(newURL, blockedReason));
144 }
141 } 145 }
142 146
143 bool ResourceLoader::willFollowRedirect( 147 bool ResourceLoader::willFollowRedirect(
144 WebURLRequest& passedNewRequest, 148 WebURLRequest& passedNewRequest,
145 const WebURLResponse& passedRedirectResponse) { 149 const WebURLResponse& passedRedirectResponse) {
146 DCHECK(!passedNewRequest.isNull()); 150 DCHECK(!passedNewRequest.isNull());
147 DCHECK(!passedRedirectResponse.isNull()); 151 DCHECK(!passedRedirectResponse.isNull());
148 152
149 if (m_isCacheAwareLoadingActivated) { 153 if (m_isCacheAwareLoadingActivated) {
150 // Fail as cache miss if cached response is a redirect. 154 // Fail as cache miss if cached response is a redirect.
151 didFail( 155 didFail(
152 ResourceError::cacheMissError(m_resource->lastResourceRequest().url())); 156 ResourceError::cacheMissError(m_resource->lastResourceRequest().url()));
153 return false; 157 return false;
154 } 158 }
155 159
156 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest()); 160 ResourceRequest& newRequest(passedNewRequest.toMutableResourceRequest());
157 const ResourceResponse& redirectResponse( 161 const ResourceResponse& redirectResponse(
158 passedRedirectResponse.toResourceResponse()); 162 passedRedirectResponse.toResourceResponse());
159 newRequest.setRedirectStatus( 163 newRequest.setRedirectStatus(
160 ResourceRequest::RedirectStatus::FollowedRedirect); 164 ResourceRequest::RedirectStatus::FollowedRedirect);
161 165
162 const KURL originalURL = newRequest.url(); 166 const KURL originalURL = newRequest.url();
163 167
164 if (!m_fetcher->willFollowRedirect(m_resource.get(), newRequest, 168 ResourceRequestBlockedReason blockedReason = m_fetcher->willFollowRedirect(
165 redirectResponse)) { 169 m_resource.get(), newRequest, redirectResponse);
166 cancelForRedirectAccessCheckError(newRequest.url()); 170 if (blockedReason != ResourceRequestBlockedReason::None) {
171 cancelForRedirectAccessCheckError(newRequest.url(), blockedReason);
167 return false; 172 return false;
168 } 173 }
169 174
170 // ResourceFetcher::willFollowRedirect() may rewrite the URL to 175 // ResourceFetcher::willFollowRedirect() may rewrite the URL to
171 // something else not for rejecting redirect but for other reasons. 176 // something else not for rejecting redirect but for other reasons.
172 // E.g. WebFrameTestClient::willSendRequest() and 177 // E.g. WebFrameTestClient::willSendRequest() and
173 // RenderFrameImpl::willSendRequest(). We should reflect the 178 // RenderFrameImpl::willSendRequest(). We should reflect the
174 // rewriting but currently we cannot. So, return false to make the 179 // rewriting but currently we cannot. So, return false to make the
175 // redirect fail. 180 // redirect fail.
176 if (newRequest.url() != originalURL) { 181 if (newRequest.url() != originalURL) {
177 cancelForRedirectAccessCheckError(newRequest.url()); 182 cancelForRedirectAccessCheckError(newRequest.url(),
183 ResourceRequestBlockedReason::Other);
178 return false; 184 return false;
179 } 185 }
180 186
181 if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) { 187 if (!m_resource->willFollowRedirect(newRequest, redirectResponse)) {
182 cancelForRedirectAccessCheckError(newRequest.url()); 188 cancelForRedirectAccessCheckError(newRequest.url(),
189 ResourceRequestBlockedReason::Other);
183 return false; 190 return false;
184 } 191 }
185 192
186 return true; 193 return true;
187 } 194 }
188 195
189 void ResourceLoader::didReceiveCachedMetadata(const char* data, int length) { 196 void ResourceLoader::didReceiveCachedMetadata(const char* data, int length) {
190 m_resource->setSerializedCachedMetadata(data, length); 197 m_resource->setSerializedCachedMetadata(data, length);
191 } 198 }
192 199
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 return; 319 return;
313 320
314 // Don't activate if cache policy is explicitly set. 321 // Don't activate if cache policy is explicitly set.
315 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy) 322 if (request.getCachePolicy() != WebCachePolicy::UseProtocolCachePolicy)
316 return; 323 return;
317 324
318 m_isCacheAwareLoadingActivated = true; 325 m_isCacheAwareLoadingActivated = true;
319 } 326 }
320 327
321 } // namespace blink 328 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/ResourceLoader.h ('k') | third_party/WebKit/Source/core/html/HTMLImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698