| 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;
|
|
|
|
|