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

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

Issue 933093002: Ensure streams aren't intercepted unless their associated plugin is enabled (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..85c2746d804881395c594152fda00e413d321012 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,7 @@
#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/render_process_host.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/resource_context.h"
@@ -207,6 +209,34 @@ 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);
}
+
+bool IsPluginEnabledForExtension(const Extension* extension,
+ int render_process_id,
+ int render_view_id) {
+ content::WebPluginInfo plugin_info;
+ base::FilePath plugin_path =
+ base::FilePath::FromUTF8Unsafe(extension->url().spec());
+ if (!content::PluginService::GetInstance()->GetPluginInfoByPath(
+ plugin_path, &plugin_info)) {
+ return false;
+ }
+
+ content::WebContents* web_contents =
+ tab_util::GetWebContentsByID(render_process_id, render_view_id);
+ if (!web_contents)
+ return false;
+
+ content::BrowserContext* browser_context = web_contents->GetBrowserContext();
+ if (!browser_context)
+ return false;
+
+ if (!PluginPrefs::GetForProfile(Profile::FromBrowserContext(
Lei Zhang 2015/02/18 04:24:18 You can just return the IsPluginEnabled() result h
raymes 2015/02/18 21:24:27 Done.
+ browser_context))->IsPluginEnabled(plugin_info)) {
+ return false;
+ }
+
+ return true;
+}
#endif // !defined(ENABLE_EXTENSIONS)
#if !defined(OS_ANDROID)
@@ -621,6 +651,12 @@ bool ChromeResourceDispatcherHostDelegate::ShouldInterceptResourceAsStream(
continue;
}
+ if (!IsPluginEnabledForExtension(extension,
+ info->GetChildID(),
+ info->GetRouteID())) {
+ continue;
+ }
+
MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension);
if (handler && handler->CanHandleMIMEType(mime_type)) {
StreamTargetInfo target_info;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698