Diff
Modified: trunk/Source/WebCore/ChangeLog (149463 => 149464)
--- trunk/Source/WebCore/ChangeLog 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebCore/ChangeLog 2013-05-01 23:46:55 UTC (rev 149464)
@@ -1,3 +1,31 @@
+2013-05-01 Tim Horton <[email protected]>
+
+ Move knowledge of PDF/PostScript MIME types into MIMETypeRegistry
+ https://bugs.webkit.org/show_bug.cgi?id=115487
+
+ Reviewed by Darin Adler.
+
+ No new tests, just a refactoring.
+
+ * WebCore.exp.in:
+ Export newly-added isPDFOrPostScriptMIMEType and getPDFAndPostScriptMIMETypes.
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createDocument):
+ Adopt MIMETypeRegistry::isPDFOrPostScriptMIMEType instead of duplicating
+ the list of MIME types. The previous list did not include PostScript, but
+ it seems reasonable to put plugins ahead of built-in support for it in addition to PDF.
+
+ * platform/MIMETypeRegistry.cpp:
+ (WebCore::initializePDFAndPostScriptMIMETypes): Added.
+ (WebCore::initializeMIMETypeRegistry): Call initializePDFAndPostScriptMIMETypes.
+ (WebCore::MIMETypeRegistry::isPDFOrPostScriptMIMEType):
+ Consult our new HashSet to see if the given MIME type is one of those used for PDF or PS.
+
+ (WebCore::MIMETypeRegistry::getPDFAndPostScriptMIMETypes): Added.
+ * platform/MIMETypeRegistry.h:
+ (MIMETypeRegistry): Add isPDFOrPostScriptMIMEType and getPDFAndPostScriptMIMETypes.
+
2013-05-01 Anders Carlsson <[email protected]>
Implement LocalStorageDatabase::importItems
Modified: trunk/Source/WebCore/WebCore.exp.in (149463 => 149464)
--- trunk/Source/WebCore/WebCore.exp.in 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebCore/WebCore.exp.in 2013-05-01 23:46:55 UTC (rev 149464)
@@ -528,9 +528,11 @@
__ZN7WebCore16MIMETypeRegistry20isJavaAppletMIMETypeERKN3WTF6StringE
__ZN7WebCore16MIMETypeRegistry23getMIMETypeForExtensionERKN3WTF6StringE
__ZN7WebCore16MIMETypeRegistry24isSupportedImageMIMETypeERKN3WTF6StringE
+__ZN7WebCore16MIMETypeRegistry25isPDFOrPostScriptMIMETypeERKN3WTF6StringE
__ZN7WebCore16MIMETypeRegistry26getSupportedImageMIMETypesEv
__ZN7WebCore16MIMETypeRegistry27getUnsupportedTextMIMETypesEv
__ZN7WebCore16MIMETypeRegistry27isSupportedNonImageMIMETypeERKN3WTF6StringE
+__ZN7WebCore16MIMETypeRegistry28getPDFAndPostScriptMIMETypesEv
__ZN7WebCore16MIMETypeRegistry29getSupportedNonImageMIMETypesEv
__ZN7WebCore16MIMETypeRegistry32isSupportedImageResourceMIMETypeERKN3WTF6StringE
__ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestE
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (149463 => 149464)
--- trunk/Source/WebCore/dom/DOMImplementation.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -402,7 +402,7 @@
// PDF is one image type for which a plugin can override built-in support.
// We do not want QuickTime to take over all image types, obviously.
- if ((type == "application/pdf" || type == "text/pdf") && pluginData && pluginData->supportsMimeType(type))
+ if ((MIMETypeRegistry::isPDFOrPostScriptMIMEType(type)) && pluginData && pluginData->supportsMimeType(type))
return PluginDocument::create(frame, url);
if (Image::supportsType(type))
return ImageDocument::create(frame, url);
@@ -418,7 +418,7 @@
// Everything else except text/plain can be overridden by plugins. In particular, Adobe SVG Viewer should be used for SVG, if installed.
// Disallowing plug-ins to use text/plain prevents plug-ins from hijacking a fundamental type that the browser is expected to handle,
// and also serves as an optimization to prevent loading the plug-in database in the common case.
- if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
+ if (type != "text/plain" && pluginData && pluginData->supportsMimeType(type))
return PluginDocument::create(frame, url);
if (isTextMIMEType(type))
return TextDocument::create(frame, url);
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.cpp (149463 => 149464)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -188,6 +188,7 @@
static HashSet<String>* supportedJavaScriptMIMETypes;
static HashSet<String>* supportedNonImageMIMETypes;
static HashSet<String>* supportedMediaMIMETypes;
+static HashSet<String>* pdfAndPostScriptMIMETypes;
static HashSet<String>* unsupportedTextMIMETypes;
typedef HashMap<String, Vector<String>*, CaseFoldingHash> MediaMIMETypeMap;
@@ -351,6 +352,17 @@
supportedJavaScriptMIMETypes->add(types[i]);
}
+static void initializePDFAndPostScriptMIMETypes()
+{
+ const char* const types[] = {
+ "application/pdf",
+ "text/pdf",
+ "application/postscript",
+ };
+ for (size_t i = 0; i < WTF_ARRAY_LENGTH(types); ++i)
+ pdfAndPostScriptMIMETypes->add(types[i]);
+}
+
static void initializeSupportedNonImageMimeTypes()
{
static const char* types[] = {
@@ -488,6 +500,9 @@
supportedImageMIMETypes = new HashSet<String>;
initializeSupportedImageMIMETypes();
+ pdfAndPostScriptMIMETypes = new HashSet<String>;
+ initializePDFAndPostScriptMIMETypes();
+
unsupportedTextMIMETypes = new HashSet<String>;
initializeUnsupportedTextMIMETypes();
}
@@ -602,6 +617,15 @@
|| mimeType.startsWith("application/x-java-vm", false);
}
+bool MIMETypeRegistry::isPDFOrPostScriptMIMEType(const String& mimeType)
+{
+ if (mimeType.isEmpty())
+ return false;
+ if (!pdfAndPostScriptMIMETypes)
+ initializeMIMETypeRegistry();
+ return pdfAndPostScriptMIMETypes->contains(mimeType);
+}
+
bool MIMETypeRegistry::canShowMIMEType(const String& mimeType)
{
if (isSupportedImageMIMEType(mimeType) || isSupportedNonImageMIMEType(mimeType) || isSupportedMediaMIMEType(mimeType))
@@ -648,6 +672,13 @@
return *supportedMediaMIMETypes;
}
+HashSet<String>& MIMETypeRegistry::getPDFAndPostScriptMIMETypes()
+{
+ if (!pdfAndPostScriptMIMETypes)
+ initializeMIMETypeRegistry();
+ return *pdfAndPostScriptMIMETypes;
+}
+
HashSet<String>& MIMETypeRegistry::getUnsupportedTextMIMETypes()
{
if (!unsupportedTextMIMETypes)
Modified: trunk/Source/WebCore/platform/MIMETypeRegistry.h (149463 => 149464)
--- trunk/Source/WebCore/platform/MIMETypeRegistry.h 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebCore/platform/MIMETypeRegistry.h 2013-05-01 23:46:55 UTC (rev 149464)
@@ -83,6 +83,9 @@
// browser (e.g. a Qt Plugin).
static bool isApplicationPluginMIMEType(const String& mimeType);
+ // Check to see if a mime type is one of the common PDF/PS types.
+ static bool isPDFOrPostScriptMIMEType(const String& mimeType);
+
// Check to see if a mime type is suitable for being shown inside a page.
// Returns true if any of isSupportedImageMIMEType(), isSupportedNonImageMIMEType(), isSupportedMediaMIMEType() returns true
// or if given mime type begins with "text/" and isUnsupportedTextMIMEType() returns false.
@@ -93,6 +96,7 @@
static HashSet<String>& getSupportedImageMIMETypesForEncoding();
static HashSet<String>& getSupportedNonImageMIMETypes();
static HashSet<String>& getSupportedMediaMIMETypes();
+ static HashSet<String>& getPDFAndPostScriptMIMETypes();
static HashSet<String>& getUnsupportedTextMIMETypes();
static String getNormalizedMIMEType(const String&);
Modified: trunk/Source/WebKit2/ChangeLog (149463 => 149464)
--- trunk/Source/WebKit2/ChangeLog 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-01 23:46:55 UTC (rev 149464)
@@ -1,3 +1,42 @@
+2013-05-01 Tim Horton <[email protected]>
+
+ Move knowledge of PDF/PostScript MIME types into MIMETypeRegistry
+ https://bugs.webkit.org/show_bug.cgi?id=115487
+
+ Reviewed by Darin Adler.
+
+ * UIProcess/WebContext.cpp:
+ * UIProcess/WebContext.h:
+ Remove pdfAndPostScriptMIMETypes.
+
+ * UIProcess/WebFrameProxy.cpp:
+ (WebKit::WebFrameProxy::canShowMIMEType): Move PDF bits to WebPageProxy.
+ (WebKit::WebFrameProxy::isDisplayingPDFDocument):
+ Make use of WebCore's newfound knowledge of PDF and PostScript MIME types,
+ so we don't have to duplicate it unnecessarily in WebKit2.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::canShowMIMEType):
+ Add code which used to be in WebFrameProxy::canShowMIMEType, and adapt it
+ to use WebCore's knowledge of PDF and PostScript MIME types.
+
+ * WebProcess/Plugins/PDF/SimplePDFPlugin.mm:
+ (WebKit::SimplePDFPlugin::pluginInfo):
+ We previously supported the "text/pdf" MIME type for PDFViewController,
+ so SimplePDFPlugin and PDFPlugin should support it as well.
+
+ * WebProcess/WebPage/WebPage.cpp:
+ (WebKit::WebPage::createPlugin):
+ Adopt MIMETypeRegistry::isPDFOrPostScriptMIMEType.
+
+ * WebProcess/WebPage/WebPage.h:
+ (WebPage):
+ Remove pdfAndPostScriptMIMETypes.
+
+ * WebProcess/WebPage/mac/WebPageMac.mm:
+ (WebKit::WebPage::platformPreferencesDidChange):
+ Adopt getPDFAndPostScriptMIMETypes instead of duplicating the list in WebKit2.
+
2013-05-01 Anders Carlsson <[email protected]>
Implement LocalStorageDatabase::importItems
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (149463 => 149464)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -901,18 +901,6 @@
return ensureSharedWebProcess()->createDownloadProxy();
}
-// FIXME: This is not the ideal place for this function.
-HashSet<String, CaseFoldingHash> WebContext::pdfAndPostScriptMIMETypes()
-{
- HashSet<String, CaseFoldingHash> mimeTypes;
-
- mimeTypes.add("application/pdf");
- mimeTypes.add("application/postscript");
- mimeTypes.add("text/pdf");
-
- return mimeTypes;
-}
-
void WebContext::addMessageReceiver(CoreIPC::StringReference messageReceiverName, CoreIPC::MessageReceiver* messageReceiver)
{
m_messageReceiverMap.addMessageReceiver(messageReceiverName, messageReceiver);
Modified: trunk/Source/WebKit2/UIProcess/WebContext.h (149463 => 149464)
--- trunk/Source/WebKit2/UIProcess/WebContext.h 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/UIProcess/WebContext.h 2013-05-01 23:46:55 UTC (rev 149464)
@@ -212,8 +212,6 @@
WebHistoryClient& historyClient() { return m_historyClient; }
WebContextClient& client() { return m_client; }
- static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
-
#if ENABLE(BATTERY_STATUS)
WebBatteryManagerProxy* batteryManagerProxy() const { return m_batteryManagerProxy.get(); }
#endif
Modified: trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp (149463 => 149464)
--- trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/UIProcess/WebFrameProxy.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -34,6 +34,7 @@
#include "WebPageProxy.h"
#include <WebCore/DOMImplementation.h>
#include <WebCore/Image.h>
+#include <WebCore/MIMETypeRegistry.h>
#include <stdio.h>
#include <wtf/text/WTFString.h>
@@ -95,16 +96,7 @@
if (!m_page)
return false;
- if (m_page->canShowMIMEType(mimeType))
- return true;
-
-#if PLATFORM(MAC)
- // On Mac, we can show PDFs.
- if (!mimeType.isEmpty())
- return WebContext::pdfAndPostScriptMIMETypes().contains(mimeType) && !WebContext::omitPDFSupport();
-#endif
-
- return false;
+ return m_page->canShowMIMEType(mimeType);
}
bool WebFrameProxy::isDisplayingStandaloneImageDocument() const
@@ -123,7 +115,7 @@
if (m_MIMEType.isEmpty())
return false;
- return WebContext::pdfAndPostScriptMIMETypes().contains(m_MIMEType);
+ return MIMETypeRegistry::isPDFOrPostScriptMIMEType(m_MIMEType);
}
void WebFrameProxy::didStartProvisionalLoad(const String& url)
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (149463 => 149464)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -933,6 +933,13 @@
if (!plugin.path.isNull() && m_pageGroup->preferences()->pluginsEnabled())
return true;
#endif // ENABLE(NETSCAPE_PLUGIN_API)
+
+#if PLATFORM(MAC)
+ // On Mac, we can show PDFs.
+ if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(mimeType) && !WebContext::omitPDFSupport())
+ return true;
+#endif // PLATFORM(MAC)
+
return false;
}
Modified: trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm (149463 => 149464)
--- trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/WebProcess/Plugins/PDF/SimplePDFPlugin.mm 2013-05-01 23:46:55 UTC (rev 149464)
@@ -184,6 +184,12 @@
pdfMimeClassInfo.desc = pdfDocumentTypeDescription();
pdfMimeClassInfo.extensions.append("pdf");
info.mimes.append(pdfMimeClassInfo);
+
+ MimeClassInfo textPDFMimeClassInfo;
+ textPDFMimeClassInfo.type = "text/pdf";
+ textPDFMimeClassInfo.desc = pdfDocumentTypeDescription();
+ textPDFMimeClassInfo.extensions.append("pdf");
+ info.mimes.append(textPDFMimeClassInfo);
MimeClassInfo postScriptMimeClassInfo;
postScriptMimeClassInfo.type = postScriptMIMEType;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (149463 => 149464)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp 2013-05-01 23:46:55 UTC (rev 149464)
@@ -556,8 +556,7 @@
if (pluginPath.isNull()) {
#if PLATFORM(MAC)
String path = parameters.url.path();
- if ((parameters.mimeType == "application/pdf" || parameters.mimeType == "application/postscript")
- || (parameters.mimeType.isEmpty() && (path.endsWith(".pdf", false) || path.endsWith(".ps", false)))) {
+ if (MIMETypeRegistry::isPDFOrPostScriptMIMEType(parameters.mimeType) || (parameters.mimeType.isEmpty() && (path.endsWith(".pdf", false) || path.endsWith(".ps", false)))) {
#if ENABLE(PDFKIT_PLUGIN)
if (shouldUsePDFPlugin())
return PDFPlugin::create(frame);
@@ -3769,7 +3768,7 @@
String pluginPath;
String newMIMEType;
uint32_t pluginLoadPolicy;
-
+
if (!sendSync(Messages::WebPageProxy::FindPlugin(response.mimeType(), response.url().string(), response.url().string(), response.url().string()), Messages::WebPageProxy::FindPlugin::Reply(pluginPath, newMIMEType, pluginLoadPolicy)))
return false;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h (149463 => 149464)
--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h 2013-05-01 23:46:55 UTC (rev 149464)
@@ -633,10 +633,6 @@
void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
#endif
-#if PLATFORM(MAC)
- static HashSet<String, CaseFoldingHash> pdfAndPostScriptMIMETypes();
-#endif
-
void savePDFToFileInDownloadsFolder(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size);
#if PLATFORM(MAC)
void savePDFToTemporaryFolderAndOpenWithNativeApplication(const String& suggestedFilename, const String& originatingURLString, const uint8_t* data, unsigned long size, const String& pdfUUID);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (149463 => 149464)
--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-05-01 23:28:46 UTC (rev 149463)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm 2013-05-01 23:46:55 UTC (rev 149464)
@@ -54,6 +54,7 @@
#import <WebCore/HTMLConverter.h>
#import <WebCore/HitTestResult.h>
#import <WebCore/KeyboardEvent.h>
+#import <WebCore/MIMETypeRegistry.h>
#import <WebCore/NetworkingContext.h>
#import <WebCore/Page.h>
#import <WebCore/PlatformKeyboardEvent.h>
@@ -104,9 +105,9 @@
BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
if (!shouldUsePDFPlugin() && !omitPDFSupport) {
- // We want to use a PDF view in the UI process for PDF MIME types.
- HashSet<String, CaseFoldingHash> mimeTypes = pdfAndPostScriptMIMETypes();
- for (HashSet<String, CaseFoldingHash>::iterator it = mimeTypes.begin(); it != mimeTypes.end(); ++it)
+ // If we don't have PDFPlugin, we will use a PDF view in the UI process for PDF and PostScript MIME types.
+ HashSet<String> mimeTypes = MIMETypeRegistry::getPDFAndPostScriptMIMETypes();
+ for (HashSet<String>::iterator it = mimeTypes.begin(); it != mimeTypes.end(); ++it)
m_mimeTypesWithCustomRepresentations.add(*it);
}
}
@@ -1002,16 +1003,4 @@
}
}
-// FIXME: This is not the ideal place for this function (and now it's duplicated here and in WebContextMac).
-HashSet<String, CaseFoldingHash> WebPage::pdfAndPostScriptMIMETypes()
-{
- HashSet<String, CaseFoldingHash> mimeTypes;
-
- mimeTypes.add("application/pdf");
- mimeTypes.add("application/postscript");
- mimeTypes.add("text/pdf");
-
- return mimeTypes;
-}
-
} // namespace WebKit