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 715ddcc62053273747a7998fc15493a582518051..1ba05898127ab5f7b87a36c49f45ab17ab8ad2af 100644 |
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc |
@@ -210,36 +210,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) |
#if !defined(OS_ANDROID) |
@@ -628,6 +598,7 @@ bool ChromeResourceDispatcherHostDelegate::ShouldForceDownloadResource( |
} |
bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
+ const base::FilePath& file_path, |
raymes
2015/03/12 05:21:03
plugin_path
|
net::URLRequest* request, |
const std::string& mime_type, |
GURL* origin, |
@@ -640,6 +611,9 @@ bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
const scoped_refptr<const extensions::InfoMap> extension_info_map( |
io_data->GetExtensionInfoMap()); |
std::vector<std::string> whitelist = MimeTypesHandler::GetMIMETypeWhitelist(); |
+ |
+ content::PluginService* service = content::PluginService::GetInstance(); |
+ content::PluginServiceFilter* filter = service->GetFilter(); |
raymes
2015/03/12 05:21:03
We can remove the above 2 lines (see below)
|
// Go through the white-listed extensions and try to use them to intercept |
// the URL request. |
for (size_t i = 0; i < whitelist.size(); ++i) { |
@@ -654,24 +628,39 @@ bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream( |
continue; |
} |
- MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension); |
- if (handler && handler->CanHandleMIMEType(mime_type)) { |
+ if (file_path == base::FilePath::FromUTF8Unsafe(extension->url().spec())) { |
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())) { |
+ |
+ content::WebPluginInfo plugin; |
+ bool plugin_info = service->GetPluginInfoByPath(file_path, &plugin); |
+ // Check that the plugin is actually enabled. |
raymes
2015/03/12 05:21:03
We don't need to check if it's enabled. This check
|
+ // MimeHandlerView plugin is disabled, then we shouldn't intercept the |
+ // stream. |
+ if (!plugin_info && filter && |
+ !filter->IsPluginAvailable( |
+ info->GetChildID(), info->GetRenderFrameID(), info->GetContext(), |
+ request->url(), GURL(), &plugin)) { |
continue; |
- } |
- target_info.view_id = base::GenerateGUID(); |
- *payload = target_info.view_id; |
} |
raymes
2015/03/12 05:21:03
I think we can add a DCHECK in this case:
DCHECK(!
|
+ target_info.view_id = base::GenerateGUID(); |
+ *payload = target_info.view_id; |
stream_target_info_[request] = target_info; |
return true; |
+ } else { |
+ 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()) { |
raymes
2015/03/12 05:21:03
In this case we should be able to remove this if-s
|
+ target_info.view_id = base::GenerateGUID(); |
+ *payload = target_info.view_id; |
raymes
2015/03/12 05:21:03
We can remove the above 2 lines here, they should
|
+ } |
+ stream_target_info_[request] = target_info; |
+ return true; |
+ } |
} |
} |
#endif |