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 8bf559c1a6eece3df09a3c6062f8c809270b2f32..d77f658da9dc8ed4e45d80505fef727ec9b2718f 100644 |
| --- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| +++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
| @@ -16,6 +16,7 @@ |
| #include "chrome/browser/download/download_request_limiter.h" |
| #include "chrome/browser/download/download_resource_throttle.h" |
| #include "chrome/browser/net/resource_prefetch_predictor_observer.h" |
| +#include "chrome/browser/plugins/plugin_prefs.h" |
| #include "chrome/browser/prefetch/prefetch.h" |
| #include "chrome/browser/prerender/prerender_manager.h" |
| #include "chrome/browser/prerender/prerender_manager_factory.h" |
| @@ -37,6 +38,8 @@ |
| #include "components/variations/net/variations_http_header_provider.h" |
| #include "content/public/browser/browser_thread.h" |
| #include "content/public/browser/notification_service.h" |
| +#include "content/public/browser/plugin_service.h" |
| +#include "content/public/browser/plugin_service_filter.h" |
| #include "content/public/browser/render_process_host.h" |
| #include "content/public/browser/render_view_host.h" |
| #include "content/public/browser/resource_context.h" |
| @@ -207,6 +210,37 @@ 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); |
|
Sam McNally
2015/02/23 00:38:35
This looks like it can fit on the previous line.
raymes
2015/02/23 02:26:13
Done.
|
| + content::PluginServiceFilter* filter = service->GetFilter(); |
| + |
| + for (size_t i = 0; i < plugins.size(); ++i) { |
|
Sam McNally
2015/02/23 00:38:34
for-each loop?
raymes
2015/02/23 02:26:13
Done.
|
| + // Check that the plugin is running the extension. |
| + if (plugins[i].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(), |
| + &plugins[i])) { |
| + return true; |
| + } |
| + } |
| + return false; |
| +} |
| #endif // !defined(ENABLE_EXTENSIONS) |
| #if !defined(OS_ANDROID) |
| @@ -627,6 +661,13 @@ bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
| *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; |
| + } |
| target_info.view_id = base::GenerateGUID(); |
| *payload = target_info.view_id; |
| } |