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

Side by Side Diff: chrome/browser/prerender/prerender_resource_throttle.cc

Issue 2687173002: [Prerender] Ignores resources with unsupported schemes for Offline reqs (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/prerender/prerender_resource_throttle.h" 5 #include "chrome/browser/prerender/prerender_resource_throttle.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/numerics/safe_conversions.h" 9 #include "base/numerics/safe_conversions.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // If this is a full prerender, cancel the prerender in response to 172 // If this is a full prerender, cancel the prerender in response to
173 // invalid requests. For prefetches, cancel invalid requests but keep the 173 // invalid requests. For prefetches, cancel invalid requests but keep the
174 // prefetch going, unless it's the main frame that's invalid. 174 // prefetch going, unless it's the main frame that's invalid.
175 if (prerender_contents->prerender_mode() == FULL_PRERENDER || 175 if (prerender_contents->prerender_mode() == FULL_PRERENDER ||
176 resource_type == content::RESOURCE_TYPE_MAIN_FRAME) { 176 resource_type == content::RESOURCE_TYPE_MAIN_FRAME) {
177 prerender_contents->Destroy(FINAL_STATUS_INVALID_HTTP_METHOD); 177 prerender_contents->Destroy(FINAL_STATUS_INVALID_HTTP_METHOD);
178 } 178 }
179 cancel = true; 179 cancel = true;
180 } else if (!PrerenderManager::DoesSubresourceURLHaveValidScheme(url) && 180 } else if (!PrerenderManager::DoesSubresourceURLHaveValidScheme(url) &&
181 resource_type != content::RESOURCE_TYPE_MAIN_FRAME) { 181 resource_type != content::RESOURCE_TYPE_MAIN_FRAME) {
182 // Destroying the prerender for unsupported scheme only for non-main 182 // For ORIGIN_OFFLINE, simply cancel this invalid request and continue.
183 // resource to allow chrome://crash to actually crash in the 183 // For other origins, fail the prerender here.
184 // *RendererCrash tests instead of being intercepted here. The unsupported 184 if (prerender_contents->origin() != ORIGIN_OFFLINE) {
185 // scheme for the main resource is checked in WillRedirectRequestOnUI() 185 // Destroying the prerender for unsupported scheme only for non-main
186 // and PrerenderContents::CheckURL(). See http://crbug.com/673771. 186 // resource to allow chrome://crash to actually crash in the
187 prerender_contents->Destroy(FINAL_STATUS_UNSUPPORTED_SCHEME); 187 // *RendererCrash tests instead of being intercepted here. The
188 ReportUnsupportedPrerenderScheme(url); 188 // unsupported
189 // scheme for the main resource is checked in WillRedirectRequestOnUI()
190 // and PrerenderContents::CheckURL(). See http://crbug.com/673771.
191 prerender_contents->Destroy(FINAL_STATUS_UNSUPPORTED_SCHEME);
192 ReportUnsupportedPrerenderScheme(url);
193 }
189 cancel = true; 194 cancel = true;
190 #if defined(OS_ANDROID) 195 #if defined(OS_ANDROID)
191 } else if (resource_type == content::RESOURCE_TYPE_FAVICON) { 196 } else if (resource_type == content::RESOURCE_TYPE_FAVICON) {
192 // Delay icon fetching until the contents are getting swapped in 197 // Delay icon fetching until the contents are getting swapped in
193 // to conserve network usage in mobile devices. 198 // to conserve network usage in mobile devices.
194 prerender_contents->AddResourceThrottle(throttle); 199 prerender_contents->AddResourceThrottle(throttle);
195 return; 200 return;
196 #endif 201 #endif
197 } 202 }
198 } 203 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 if (g_prerender_contents_for_testing) 281 if (g_prerender_contents_for_testing)
277 return g_prerender_contents_for_testing; 282 return g_prerender_contents_for_testing;
278 return PrerenderContents::FromWebContents(web_contents_getter.Run()); 283 return PrerenderContents::FromWebContents(web_contents_getter.Run());
279 } 284 }
280 285
281 void PrerenderResourceThrottle::SetPrerenderMode(PrerenderMode mode) { 286 void PrerenderResourceThrottle::SetPrerenderMode(PrerenderMode mode) {
282 load_flags_ = (mode == PREFETCH_ONLY) ? net::LOAD_PREFETCH : net::LOAD_NORMAL; 287 load_flags_ = (mode == PREFETCH_ONLY) ? net::LOAD_PREFETCH : net::LOAD_NORMAL;
283 } 288 }
284 289
285 } // namespace prerender 290 } // namespace prerender
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698