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

Unified Diff: content/browser/loader/buffered_resource_handler.cc

Issue 953793003: Ensuring interception of stream get determined by plugin path before checking mime type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 9 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: content/browser/loader/buffered_resource_handler.cc
diff --git a/content/browser/loader/buffered_resource_handler.cc b/content/browser/loader/buffered_resource_handler.cc
index 67e74a586f5231d3290ee813674357ce1d43bc7a..3c398fe648d5a8d8f2e6a45739bbec3845b62e2d 100644
--- a/content/browser/loader/buffered_resource_handler.cc
+++ b/content/browser/loader/buffered_resource_handler.cc
@@ -297,6 +297,52 @@ bool BufferedResourceHandler::DetermineMimeType() {
return made_final_decision;
}
+bool BufferedResourceHandler::IsHandledByPlugin(bool* defer, bool* result) {
+#if defined(ENABLE_PLUGINS)
+ *result = true;
+ bool stale;
+ WebPluginInfo plugin;
+ bool has_plugin = GetSupportingPlugin(&plugin, &stale);
+ if (stale) {
+ // Refresh the plugins asynchronously.
+ plugin_service_->GetPlugins(
+ base::Bind(&BufferedResourceHandler::OnPluginsLoaded,
+ weak_ptr_factory_.GetWeakPtr()));
+ request()->LogBlockedBy("BufferedResourceHandler");
+ *defer = true;
+ return true;
+ }
+
+ if (has_plugin) {
+ if (plugin.type == WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN) {
raymes 2015/03/16 05:36:50 We should add a unittest that hits this line by im
Deepak 2015/03/16 10:17:33 With the current test cases we can check above con
raymes 2015/03/18 03:45:51 Can we add a separate test though (copying one of
+ // If it is a MimeHandlerView plugin, intercept the stream.
+ std::string payload;
+ scoped_ptr<ResourceHandler> handler(host_->MaybeInterceptAsStream(
+ plugin.path, request(), response_.get(), &payload));
+ if (handler) {
+ *result = UseAlternateNextHandler(handler.Pass(), payload);
+ return true;
+ }
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+ // If we get here then we should try intercepting the stream for the old
+ // streamsPrivate extensions API. This API is deprecated and should go
+ // away.
+ std::string payload;
+ scoped_ptr<ResourceHandler> handler(host_->MaybeInterceptAsStream(
+ base::FilePath(), request(), response_.get(), &payload));
+ if (handler) {
+ *result = UseAlternateNextHandler(handler.Pass(), payload);
+ return true;
+ }
+#endif
+ return false;
+}
+
bool BufferedResourceHandler::SelectNextHandler(bool* defer) {
DCHECK(!response_->head.mime_type.empty());
@@ -314,13 +360,9 @@ bool BufferedResourceHandler::SelectNextHandler(bool* defer) {
// Allow requests for object/embed tags to be intercepted as streams.
if (info->GetResourceType() == content::RESOURCE_TYPE_OBJECT) {
DCHECK(!info->allow_download());
- std::string payload;
- scoped_ptr<ResourceHandler> handler(
- host_->MaybeInterceptAsStream(request(), response_.get(), &payload));
- if (handler) {
- DCHECK(!net::IsSupportedMimeType(mime_type));
- return UseAlternateNextHandler(handler.Pass(), payload);
- }
+ bool result;
+ if (IsHandledByPlugin(defer, &result))
+ return result;
}
if (!info->allow_download())
@@ -337,28 +379,9 @@ bool BufferedResourceHandler::SelectNextHandler(bool* defer) {
if (net::IsSupportedMimeType(mime_type))
return true;
- std::string payload;
- scoped_ptr<ResourceHandler> handler(
- host_->MaybeInterceptAsStream(request(), response_.get(), &payload));
- if (handler) {
- return UseAlternateNextHandler(handler.Pass(), payload);
- }
-
-#if defined(ENABLE_PLUGINS)
- bool stale;
- bool has_plugin = HasSupportingPlugin(&stale);
- if (stale) {
- // Refresh the plugins asynchronously.
- plugin_service_->GetPlugins(
- base::Bind(&BufferedResourceHandler::OnPluginsLoaded,
- weak_ptr_factory_.GetWeakPtr()));
- request()->LogBlockedBy("BufferedResourceHandler");
- *defer = true;
- return true;
- }
- if (has_plugin)
- return true;
-#endif
+ bool result;
+ if (IsHandledByPlugin(defer, &result))
+ return result;
}
// Install download handler
@@ -475,16 +498,15 @@ bool BufferedResourceHandler::MustDownload() {
return must_download_;
}
-bool BufferedResourceHandler::HasSupportingPlugin(bool* stale) {
+bool BufferedResourceHandler::GetSupportingPlugin(WebPluginInfo* plugin,
+ bool* stale) {
#if defined(ENABLE_PLUGINS)
ResourceRequestInfoImpl* info = GetRequestInfo();
-
bool allow_wildcard = false;
- WebPluginInfo plugin;
return plugin_service_->GetPluginInfo(
info->GetChildID(), info->GetRenderFrameID(), info->GetContext(),
request()->url(), GURL(), response_->head.mime_type, allow_wildcard,
- stale, &plugin, NULL);
+ stale, plugin, NULL);
#else
if (stale)
*stale = false;

Powered by Google App Engine
This is Rietveld 408576698