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

Unified Diff: third_party/WebKit/Source/web/LocalFrameClientImpl.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
« no previous file with comments | « third_party/WebKit/Source/web/LocalFrameClientImpl.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/web/LocalFrameClientImpl.cpp
diff --git a/third_party/WebKit/Source/web/LocalFrameClientImpl.cpp b/third_party/WebKit/Source/web/LocalFrameClientImpl.cpp
index 13762c2b8d53c933aee41d0dd41a84c962e0c338..7750470f391c4437e9306484f8c90d1fd2875188 100644
--- a/third_party/WebKit/Source/web/LocalFrameClientImpl.cpp
+++ b/third_party/WebKit/Source/web/LocalFrameClientImpl.cpp
@@ -80,6 +80,7 @@
#include "platform/feature_policy/FeaturePolicy.h"
#include "platform/loader/fetch/ResourceFetcher.h"
#include "platform/network/HTTPParsers.h"
+#include "platform/network/mime/MIMETypeRegistry.h"
#include "platform/plugins/PluginData.h"
#include "platform/wtf/PtrUtil.h"
#include "platform/wtf/StringExtras.h"
@@ -811,6 +812,47 @@
return HTMLMediaElementRemotePlayback::remote(html_media_element);
}
+ObjectContentType LocalFrameClientImpl::GetObjectContentType(
+ const KURL& url,
+ const String& explicit_mime_type,
+ bool should_prefer_plug_ins_for_images) {
+ // This code is based on Apple's implementation from
+ // WebCoreSupport/WebFrameBridge.mm.
+
+ String mime_type = explicit_mime_type;
+ 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 kObjectContentFrame;
+ }
+
+ // If Chrome is started with the --disable-plugins switch, pluginData is 0.
+ PluginData* plugin_data = web_frame_->GetFrame()->GetPluginData();
+ bool plug_in_supports_mime_type =
+ plugin_data && plugin_data->SupportsMimeType(mime_type);
+
+ if (MIMETypeRegistry::IsSupportedImageMIMEType(mime_type)) {
+ return should_prefer_plug_ins_for_images && plug_in_supports_mime_type
+ ? kObjectContentNetscapePlugin
+ : kObjectContentImage;
+ }
+
+ if (plug_in_supports_mime_type)
+ return kObjectContentNetscapePlugin;
+
+ if (MIMETypeRegistry::IsSupportedNonImageMIMEType(mime_type))
+ return kObjectContentFrame;
+
+ return kObjectContentNone;
+}
+
WebCookieJar* LocalFrameClientImpl::CookieJar() const {
if (!web_frame_->Client())
return 0;
« no previous file with comments | « third_party/WebKit/Source/web/LocalFrameClientImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698