Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3028)

Unified Diff: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc

Issue 1164073006: Make the logic for stream interception by MimeHandlerViews consistent with starting the plugin (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 cbccea389687ba2bf3b19ea9876b0f3f3d778a53..1b6c3e761c9025093bb734f9f6e4dd5e2795d751 100644
--- a/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
+++ b/chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc
@@ -205,36 +205,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(
@@ -606,6 +576,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) {
@@ -629,25 +600,31 @@ 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 a stream is being intercepted for the
+ // mimeHandlerPrivate API. Otherwise a stream is being intercepted for the
+ // streamsPrivate API.
+ if (!plugin_path.empty()) {
+ 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 {
+ 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

Powered by Google App Engine
This is Rietveld 408576698