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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 1700233003: [WIP][SVG 2/4] Make data URL handling in ResourceFetcher and WebURLLoaderImpl consistent Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: auto-Rebase Created 4 years, 9 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
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/web_url_loader_impl.cc
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index 5abc0fbc26a4ab2e716825e319f5da77ddd61d8a..2e61032d53c80ee8101932c9f061d144677c4917 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -336,8 +336,6 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context> {
// Called when the body data stream is detached from the reader side.
void CancelBodyStreaming();
- // We can optimize the handling of data URLs in most cases.
- bool CanHandleDataURLRequestLocally() const;
void HandleDataURL();
WebURLLoaderImpl* loader_;
@@ -468,7 +466,8 @@ void WebURLLoaderImpl::Context::Start(const WebURLRequest& request,
GURL url = request.url();
- if (CanHandleDataURLRequestLocally()) {
+ if (CanHandleDataURLRequestLocally(request_,
+ resource_dispatcher_ != nullptr)) {
if (sync_load_response) {
// This is a sync load. Do the work now.
sync_load_response->url = url;
@@ -811,19 +810,21 @@ void WebURLLoaderImpl::Context::CancelBodyStreaming() {
Cancel();
}
-bool WebURLLoaderImpl::Context::CanHandleDataURLRequestLocally() const {
- GURL url = request_.url();
+bool WebURLLoaderImpl::CanHandleDataURLRequestLocally(
+ const WebURLRequest& request,
+ bool resource_dispatcher_exists) {
+ GURL url = request.url();
if (!url.SchemeIs(url::kDataScheme))
return false;
// The fast paths for data URL, Start() and HandleDataURL(), don't support
// the downloadToFile option.
- if (request_.downloadToFile())
+ if (request.downloadToFile())
return false;
// Data url requests from object tags may need to be intercepted as streams
// and so need to be sent to the browser.
- if (request_.getRequestContext() == WebURLRequest::RequestContextObject)
+ if (request.getRequestContext() == WebURLRequest::RequestContextObject)
return false;
// Optimize for the case where we can handle a data URL locally. We must
@@ -837,17 +838,17 @@ bool WebURLLoaderImpl::Context::CanHandleDataURLRequestLocally() const {
// For compatibility reasons on Android we need to expose top-level data://
// to the browser. In tests resource_dispatcher_ can be null, and test pages
// need to be loaded locally.
- if (resource_dispatcher_ &&
- request_.getFrameType() == WebURLRequest::FrameTypeTopLevel)
+ if (resource_dispatcher_exists &&
+ request.getFrameType() == WebURLRequest::FrameTypeTopLevel)
return false;
#endif
- if (request_.getFrameType() != WebURLRequest::FrameTypeTopLevel &&
- request_.getFrameType() != WebURLRequest::FrameTypeNested)
+ if (request.getFrameType() != WebURLRequest::FrameTypeTopLevel &&
+ request.getFrameType() != WebURLRequest::FrameTypeNested)
return true;
std::string mime_type, unused_charset;
- if (net::DataURL::Parse(request_.url(), &mime_type, &unused_charset, NULL) &&
+ if (net::DataURL::Parse(request.url(), &mime_type, &unused_charset, NULL) &&
mime_util::IsSupportedMimeType(mime_type))
return true;
« no previous file with comments | « content/child/web_url_loader_impl.h ('k') | third_party/WebKit/Source/core/fetch/Resource.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698