Chromium Code Reviews| Index: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| diff --git a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| index 094ad36d1d50d83749d9d5bfccd19cdb8e1cf1c6..635ee35f42c16d6dc0aab62312207a5863211e6b 100644 |
| --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| @@ -207,36 +207,6 @@ void SendExecuteMimeTypeHandlerEvent(scoped_ptr<content::StreamInfo> stream, |
| extension_id, web_contents, stream.Pass(), view_id, expected_content_size, |
| embedded, render_process_id, render_frame_id); |
| } |
| - |
| -// TODO(raymes): This won't return the right result if plugins haven't been |
| -// loaded yet. Fixing this properly really requires fixing crbug.com/443466. |
| -bool IsPluginEnabledForExtension(const Extension* extension, |
| - const ResourceRequestInfo* info, |
| - const std::string& mime_type, |
| - const GURL& url) { |
| - content::PluginService* service = content::PluginService::GetInstance(); |
| - std::vector<content::WebPluginInfo> plugins; |
| - service->GetPluginInfoArray(url, mime_type, true, &plugins, nullptr); |
| - content::PluginServiceFilter* filter = service->GetFilter(); |
| - |
| - for (auto& plugin : plugins) { |
| - // Check that the plugin is running the extension. |
| - if (plugin.path != |
| - base::FilePath::FromUTF8Unsafe(extension->url().spec())) { |
| - continue; |
| - } |
| - // Check that the plugin is actually enabled. |
| - if (!filter || filter->IsPluginAvailable(info->GetChildID(), |
| - info->GetRenderFrameID(), |
| - info->GetContext(), |
| - url, |
| - GURL(), |
| - &plugin)) { |
| - return true; |
| - } |
| - } |
| - return false; |
| -} |
| #endif // !defined(ENABLE_EXTENSIONS) |
| void LaunchURL( |
| @@ -621,6 +591,7 @@ bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
| bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
| net::URLRequest* request, |
| + const base::FilePath& plugin_path, |
| const std::string& mime_type, |
| GURL* origin, |
| std::string* payload) { |
| @@ -644,25 +615,32 @@ bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
| !extension_info_map->IsIncognitoEnabled(extension_id))) { |
| continue; |
| } |
| - |
| MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
| - if (handler && handler->CanHandleMIMEType(mime_type)) { |
| - StreamTargetInfo target_info; |
| - *origin = Extension::GetBaseURLFromExtensionId(extension_id); |
| - target_info.extension_id = extension_id; |
| - if (!handler->handler_url().empty()) { |
| - // This is reached in the case of MimeHandlerViews. If the |
| - // MimeHandlerView plugin is disabled, then we shouldn't intercept the |
| - // stream. |
| - if (!IsPluginEnabledForExtension(extension, info, mime_type, |
| - request->url())) { |
| - continue; |
| - } |
| + if (!handler) |
| + continue; |
| + |
| + // If a plugin path is provided then we are trying to intercept the stream |
|
mmenke
2015/07/09 20:35:39
nit: SHouldn't use we in comments.
raymes
2015/07/17 03:21:00
Done.
|
| + // for the mimeHandlerPrivate API. Otherwise we are trying to intercept the |
| + // stream for the streamsPrivate API. |
| + if (!plugin_path.empty()) { |
| + // Check that the plugin path matches the handlers plugin path. |
| + if (handler->HasPlugin() && plugin_path == handler->GetPluginPath()) { |
| + StreamTargetInfo target_info; |
| + *origin = Extension::GetBaseURLFromExtensionId(extension_id); |
| + target_info.extension_id = extension_id; |
| target_info.view_id = base::GenerateGUID(); |
| *payload = target_info.view_id; |
| + stream_target_info_[request] = target_info; |
| + return true; |
| + } |
| + } else { |
|
Sam McNally
2015/07/07 06:44:28
else if
raymes
2015/07/17 03:21:00
Done. I reworked the code slightly
|
| + if (!handler->HasPlugin() && handler->CanHandleMIMEType(mime_type)) { |
| + StreamTargetInfo target_info; |
| + *origin = Extension::GetBaseURLFromExtensionId(extension_id); |
| + target_info.extension_id = extension_id; |
| + stream_target_info_[request] = target_info; |
| + return true; |
| } |
| - stream_target_info_[request] = target_info; |
| - return true; |
| } |
| } |
| #endif |