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

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

Issue 2933213002: Revert of Move ObjectContentType entirely to HTMLPlugInElement (Closed)
Patch Set: Created 3 years, 6 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: 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 e74ced8e1c9621b12119ea393847c285e2891abe..ddfbe3e4b08df19c623b43bf266d27d6d38bb9cf 100644
--- a/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLPlugInElement.cpp
@@ -118,22 +118,23 @@
}
bool HTMLPlugInElement::RequestObjectInternal(
+ const String& url,
+ const String& mime_type,
const Vector<String>& param_names,
const Vector<String>& param_values) {
- if (url_.IsEmpty() && service_type_.IsEmpty())
- return false;
-
- if (ProtocolIsJavaScript(url_))
- return false;
-
- KURL completed_url =
- url_.IsEmpty() ? KURL() : GetDocument().CompleteURL(url_);
- if (!AllowedToLoadObject(completed_url, service_type_))
- return false;
-
- ObjectContentType object_type = GetObjectContentType();
- if (object_type == ObjectContentType::kFrame ||
- object_type == ObjectContentType::kImage) {
+ if (url.IsEmpty() && mime_type.IsEmpty())
+ return false;
+
+ if (ProtocolIsJavaScript(url))
+ return false;
+
+ KURL completed_url = url.IsEmpty() ? KURL() : GetDocument().CompleteURL(url);
+ if (!AllowedToLoadObject(completed_url, mime_type))
+ return false;
+
+ bool use_fallback;
+ if (!ShouldUsePlugin(completed_url, mime_type, HasFallbackContent(),
+ use_fallback)) {
// If the plugin element already contains a subframe,
// loadOrRedirectSubframe will re-use it. Otherwise, it will create a
// new frame and set it as the LayoutEmbeddedContent's EmbeddedContentView,
@@ -141,11 +142,7 @@
return LoadOrRedirectSubframe(completed_url, GetNameAttribute(), true);
}
- // If an object's content can't be handled and it has no fallback, let
- // it be handled as a plugin to show the broken plugin icon.
- bool use_fallback =
- object_type == ObjectContentType::kNone && HasFallbackContent();
- return LoadPlugin(completed_url, service_type_, param_names, param_values,
+ return LoadPlugin(completed_url, mime_type, param_names, param_values,
use_fallback, true);
}
@@ -197,7 +194,7 @@
image_loader_->UpdateFromElement();
} else if (NeedsPluginUpdate() && !GetLayoutEmbeddedItem().IsNull() &&
!GetLayoutEmbeddedItem().ShowsUnavailablePluginIndicator() &&
- GetObjectContentType() != ObjectContentType::kPlugin &&
+ !WouldLoadAsNetscapePlugin(url_, service_type_) &&
!is_delaying_load_event_) {
is_delaying_load_event_ = true;
GetDocument().IncrementLoadEventDelayCount();
@@ -472,46 +469,17 @@
return plugin_is_available_;
}
-HTMLPlugInElement::ObjectContentType HTMLPlugInElement::GetObjectContentType() {
- String mime_type = service_type_;
- KURL url = GetDocument().CompleteURL(url_);
- if (mime_type.IsEmpty()) {
- // Try to guess the MIME type based off the extension.
- String filename = url.LastPathComponent();
- int extension_pos = filename.ReverseFind('.');
- if (extension_pos >= 0) {
- String extension = filename.Substring(extension_pos + 1);
- mime_type = MIMETypeRegistry::GetWellKnownMIMETypeForExtension(extension);
- }
-
- if (mime_type.IsEmpty())
- return ObjectContentType::kFrame;
- }
-
- // If Chrome is started with the --disable-plugins switch, pluginData is 0.
- PluginData* plugin_data = GetDocument().GetFrame()->GetPluginData();
- bool plugin_supports_mime_type =
- plugin_data && plugin_data->SupportsMimeType(mime_type);
-
- if (MIMETypeRegistry::IsSupportedImageMIMEType(mime_type)) {
- return should_prefer_plug_ins_for_images_ && plugin_supports_mime_type
- ? ObjectContentType::kPlugin
- : ObjectContentType::kImage;
- }
-
- if (plugin_supports_mime_type)
- return ObjectContentType::kPlugin;
- if (MIMETypeRegistry::IsSupportedNonImageMIMEType(mime_type))
- return ObjectContentType::kFrame;
- return ObjectContentType::kNone;
-}
-
bool HTMLPlugInElement::IsImageType() {
if (service_type_.IsEmpty() && ProtocolIs(url_, "data"))
service_type_ = MimeTypeFromDataURL(url_);
- if (GetDocument().GetFrame())
- return GetObjectContentType() == ObjectContentType::kImage;
+ if (LocalFrame* frame = GetDocument().GetFrame()) {
+ KURL completed_url = GetDocument().CompleteURL(url_);
+ return frame->Loader().Client()->GetObjectContentType(
+ completed_url, service_type_, ShouldPreferPlugInsForImages()) ==
+ kObjectContentImage;
+ }
+
return Image::SupportsType(service_type_);
}
@@ -532,9 +500,25 @@
ContentFrame()->GetSecurityContext()->GetSecurityOrigin()));
}
-bool HTMLPlugInElement::RequestObject(const Vector<String>& param_names,
+// We don't use m_url, or m_serviceType as they may not be the final values
+// that <object> uses depending on <param> values.
+bool HTMLPlugInElement::WouldLoadAsNetscapePlugin(const String& url,
+ const String& service_type) {
+ DCHECK(GetDocument().GetFrame());
+ KURL completed_url;
+ if (!url.IsEmpty())
+ completed_url = GetDocument().CompleteURL(url);
+ return GetDocument().GetFrame()->Loader().Client()->GetObjectContentType(
+ completed_url, service_type, ShouldPreferPlugInsForImages()) ==
+ kObjectContentNetscapePlugin;
+}
+
+bool HTMLPlugInElement::RequestObject(const String& url,
+ const String& mime_type,
+ const Vector<String>& param_names,
const Vector<String>& param_values) {
- bool result = RequestObjectInternal(param_names, param_values);
+ bool result =
+ RequestObjectInternal(url, mime_type, param_names, param_values);
DEFINE_STATIC_LOCAL(
EnumerationHistogram, result_histogram,
@@ -609,6 +593,20 @@
return true;
}
+bool HTMLPlugInElement::ShouldUsePlugin(const KURL& url,
+ const String& mime_type,
+ bool has_fallback,
+ bool& use_fallback) {
+ ObjectContentType object_type =
+ GetDocument().GetFrame()->Loader().Client()->GetObjectContentType(
+ url, mime_type, ShouldPreferPlugInsForImages());
+ // If an object's content can't be handled and it has no fallback, let
+ // it be handled as a plugin to show the broken plugin icon.
+ use_fallback = object_type == kObjectContentNone && has_fallback;
+ return object_type == kObjectContentNone ||
+ object_type == kObjectContentNetscapePlugin;
+}
+
void HTMLPlugInElement::DispatchErrorEvent() {
if (GetDocument().IsPluginDocument() && GetDocument().LocalOwner())
GetDocument().LocalOwner()->DispatchEvent(
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLPlugInElement.h ('k') | third_party/WebKit/Source/core/loader/EmptyClients.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698