Chromium Code Reviews| Index: content/browser/loader/mime_type_resource_handler.cc |
| diff --git a/content/browser/loader/mime_type_resource_handler.cc b/content/browser/loader/mime_type_resource_handler.cc |
| index 576d81fa9423bed7beade05ca6ad01047e6cfc63..2908bd3b098330e870bef24a36b9b4658a43edbd 100644 |
| --- a/content/browser/loader/mime_type_resource_handler.cc |
| +++ b/content/browser/loader/mime_type_resource_handler.cc |
| @@ -292,6 +292,49 @@ bool MimeTypeResourceHandler::DetermineMimeType() { |
| return made_final_decision; |
| } |
| +bool MimeTypeResourceHandler::SelectPluginHandler(bool* defer, |
| + bool* request_handled) { |
|
mmenke
2015/07/09 20:35:39
request_handled -> handled_by_plugin (Clearer, and
raymes
2015/07/17 03:21:00
Done.
|
| +#if defined(ENABLE_PLUGINS) |
| + *request_handled = false; |
|
mmenke
2015/07/09 20:35:39
I don't think initialization is needed. Alternati
raymes
2015/07/17 03:21:00
Done.
|
| + bool stale; |
| + WebPluginInfo plugin; |
| + bool allow_wildcard = false; |
| + ResourceRequestInfoImpl* info = GetRequestInfo(); |
| + bool has_plugin = plugin_service_->GetPluginInfo( |
| + info->GetChildID(), info->GetRenderFrameID(), info->GetContext(), |
| + request()->url(), GURL(), response_->head.mime_type, allow_wildcard, |
| + &stale, &plugin, NULL); |
| + |
| + if (stale) { |
| + // Refresh the plugins asynchronously. |
| + plugin_service_->GetPlugins( |
| + base::Bind(&MimeTypeResourceHandler::OnPluginsLoaded, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + request()->LogBlockedBy("MimeTypeResourceHandler"); |
| + *defer = true; |
| + return true; |
| + } |
| + |
| + if (has_plugin && plugin.type != WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) { |
| + *request_handled = true; |
| + return true; |
| + } |
| + |
| + // Attempt to intercept the request as a stream. |
| + base::FilePath plugin_path; |
| + if (has_plugin) |
| + plugin_path = plugin.path; |
| + std::string payload; |
| + scoped_ptr<ResourceHandler> handler(host_->MaybeInterceptAsStream( |
| + plugin_path, request(), response_.get(), &payload)); |
| + if (handler) { |
| + *request_handled = true; |
| + return UseAlternateNextHandler(handler.Pass(), payload); |
| + } |
| +#endif |
| + return true; |
| +} |
| + |
| bool MimeTypeResourceHandler::SelectNextHandler(bool* defer) { |
| DCHECK(!response_->head.mime_type.empty()); |
| @@ -309,13 +352,14 @@ bool MimeTypeResourceHandler::SelectNextHandler(bool* defer) { |
| // Allow requests for object/embed tags to be intercepted as streams. |
| if (info->GetResourceType() == content::RESOURCE_TYPE_OBJECT) { |
| DCHECK(!info->allow_download()); |
| - std::string payload; |
| - scoped_ptr<ResourceHandler> handler( |
| - host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); |
| - if (handler) { |
| - DCHECK(!mime_util::IsSupportedMimeType(mime_type)); |
| - return UseAlternateNextHandler(handler.Pass(), payload); |
| - } |
| + |
| + |
| + bool handled_by_plugin = false; |
| + bool request_handled = SelectPluginHandler(defer, &handled_by_plugin); |
|
mmenke
2015/07/09 20:35:39
request_handled is a misnomer (And easy to confuse
raymes
2015/07/17 03:21:00
Done.
|
| + if (!request_handled) |
| + return false; |
| + if (handled_by_plugin || defer) |
| + return true; |
| } |
| if (!info->allow_download()) |
| @@ -332,28 +376,12 @@ bool MimeTypeResourceHandler::SelectNextHandler(bool* defer) { |
| if (mime_util::IsSupportedMimeType(mime_type)) |
| return true; |
| - std::string payload; |
| - scoped_ptr<ResourceHandler> handler( |
| - host_->MaybeInterceptAsStream(request(), response_.get(), &payload)); |
| - if (handler) { |
| - return UseAlternateNextHandler(handler.Pass(), payload); |
| - } |
| - |
| -#if defined(ENABLE_PLUGINS) |
| - bool stale; |
| - bool has_plugin = HasSupportingPlugin(&stale); |
| - if (stale) { |
| - // Refresh the plugins asynchronously. |
| - plugin_service_->GetPlugins( |
| - base::Bind(&MimeTypeResourceHandler::OnPluginsLoaded, |
| - weak_ptr_factory_.GetWeakPtr())); |
| - request()->LogBlockedBy("MimeTypeResourceHandler"); |
| - *defer = true; |
| - return true; |
| - } |
| - if (has_plugin) |
| + bool handled_by_plugin = false; |
| + bool request_handled = SelectPluginHandler(defer, &handled_by_plugin); |
|
mmenke
2015/07/09 20:35:39
See above comment about "request_handled"
raymes
2015/07/17 03:21:00
Done.
|
| + if (!request_handled) |
| + return false; |
| + if (handled_by_plugin || defer) |
| return true; |
| -#endif |
| } |
| // Install download handler |
| @@ -470,23 +498,6 @@ bool MimeTypeResourceHandler::MustDownload() { |
| return must_download_; |
| } |
| -bool MimeTypeResourceHandler::HasSupportingPlugin(bool* stale) { |
| -#if defined(ENABLE_PLUGINS) |
| - ResourceRequestInfoImpl* info = GetRequestInfo(); |
| - |
| - bool allow_wildcard = false; |
| - WebPluginInfo plugin; |
| - return plugin_service_->GetPluginInfo( |
| - info->GetChildID(), info->GetRenderFrameID(), info->GetContext(), |
| - request()->url(), GURL(), response_->head.mime_type, allow_wildcard, |
| - stale, &plugin, NULL); |
| -#else |
| - if (stale) |
| - *stale = false; |
| - return false; |
| -#endif |
| -} |
| - |
| bool MimeTypeResourceHandler::CopyReadBufferToNextHandler() { |
| if (!read_buffer_.get()) |
| return true; |