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

Unified Diff: third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp

Issue 1645313002: Don't apply the SandboxPlugins flag until we know a plugin will be used (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « third_party/WebKit/Source/core/html/HTMLPlugInElement.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp b/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
index e6a69bc8e321bb99769291a911d6fb780830fb39..eb1ab9d6c268871864f876f122c47b0f6dc4be77 100644
--- a/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
@@ -38,6 +38,7 @@
#include "core/html/HTMLImageLoader.h"
#include "core/html/PluginDocument.h"
#include "core/input/EventHandler.h"
+#include "core/inspector/ConsoleMessage.h"
#include "core/layout/LayoutBlockFlow.h"
#include "core/layout/LayoutEmbeddedObject.h"
#include "core/layout/LayoutImage.h"
@@ -474,12 +475,18 @@ bool HTMLPlugInElement::requestObject(const String& url, const String& mimeType,
return false;
KURL completedURL = url.isEmpty() ? KURL() : document().completeURL(url);
- if (!pluginIsLoadable(completedURL, mimeType))
+ if (!objectIsLoadable(completedURL, mimeType))
return false;
bool useFallback;
- if (shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallback))
+ if (shouldUsePlugin(completedURL, mimeType, hasFallbackContent(), useFallback)) {
+ if (document().isSandboxed(SandboxPlugins)) {
+ document().addConsoleMessage(ConsoleMessage::create(SecurityMessageSource, ErrorMessageLevel,
+ "Failed to load '" + completedURL.elidedString() + "' as a plugin, because the frame into which the plugin is loading is sandboxed."));
+ return false;
+ }
return loadPlugin(completedURL, mimeType, paramNames, paramValues, useFallback, true);
pdr. 2016/01/29 22:14:54 There is a scary side-codepath (requestPluginCreat
fs 2016/01/30 00:03:09 Yeah, I noticed that - and was equally frightened.
+ }
// If the plugin element already contains a subframe,
// loadOrRedirectSubframe will re-use it. Otherwise, it will create a new
@@ -541,8 +548,10 @@ bool HTMLPlugInElement::shouldUsePlugin(const KURL& url, const String& mimeType,
if (document().frame()->page() && (mimeType == "image/tiff" || mimeType == "image/tif" || mimeType == "image/x-tiff")) {
const PluginData* pluginData = document().frame()->page()->pluginData();
String pluginName = pluginData ? pluginData->pluginNameForMimeType(mimeType) : String();
- if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", TextCaseInsensitive))
+ if (!pluginName.isEmpty() && !pluginName.contains("QuickTime", TextCaseInsensitive)) {
+ useFallback = false;
return true;
+ }
}
ObjectContentType objectType = document().frame()->loader().client()->objectContentType(url, mimeType, shouldPreferPlugInsForImages());
@@ -561,7 +570,7 @@ void HTMLPlugInElement::dispatchErrorEvent()
dispatchEvent(Event::create(EventTypeNames::error));
}
-bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType)
+bool HTMLPlugInElement::objectIsLoadable(const KURL& url, const String& mimeType)
{
if (url.isEmpty() && mimeType.isEmpty())
return false;
@@ -574,9 +583,6 @@ bool HTMLPlugInElement::pluginIsLoadable(const KURL& url, const String& mimeType
if (MIMETypeRegistry::isJavaAppletMIMEType(mimeType))
return false;
- if (document().isSandboxed(SandboxPlugins))
pdr. 2016/01/29 22:14:54 It seems odd to me that sandboxing and the plugin
fs 2016/01/30 00:03:09 It's intended (for now at least) - as in better to
fs 2016/02/01 09:21:06 I shuffled the code a bit and the plugin-CSP check
fs 2016/02/01 11:52:34 Doing that added a new failure: http/tests/securi
- return false;
-
if (!document().securityOrigin()->canDisplay(url)) {
FrameLoader::reportLocalLoadFailed(frame, url.string());
return false;
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLPlugInElement.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698