PDFPlugin: Enable PDFPlugin only if its dependencies exist on the system

https://bugs.webkit.org/show_bug.cgi?id=113372
<rdar://problem/12685301>

Reviewed by Alexey Proskuryakov.

* Shared/mac/PDFKitImports.h: Wrap in #if PLATFORM(MAC).
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): Use shouldUsePDFPlugin.
(WebKit::WebPage::shouldUsePDFPlugin): If the PDFPlugin setting is enabled but PDFLayerController is not available, don't use PDFPlugin.
* WebProcess/WebPage/WebPage.h:
(WebPage): Add shouldUsePDFPlugin
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformPreferencesDidChange): Use shouldUsePDFPlugin.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147067 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7dd9a661
2013-03-27 Tim Horton <timothy_horton@apple.com>
PDFPlugin: Enable PDFPlugin only if its dependencies exist on the system
https://bugs.webkit.org/show_bug.cgi?id=113372
<rdar://problem/12685301>
Reviewed by Alexey Proskuryakov.
* Shared/mac/PDFKitImports.h: Wrap in #if PLATFORM(MAC).
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::createPlugin): Use shouldUsePDFPlugin.
(WebKit::WebPage::shouldUsePDFPlugin): If the PDFPlugin setting is enabled but PDFLayerController is not available, don't use PDFPlugin.
* WebProcess/WebPage/WebPage.h:
(WebPage): Add shouldUsePDFPlugin
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformPreferencesDidChange): Use shouldUsePDFPlugin.
2013-03-27 Sam Weinig <sam@webkit.org>
[WebKit2] Need SPI to determine whether a plug-in is blocked
......@@ -26,6 +26,8 @@
#ifndef PDFKitImports_h
#define PDFKitImports_h
#if PLATFORM(MAC)
namespace WebKit {
NSString *pdfKitFrameworkPath();
......@@ -41,4 +43,6 @@ Class pdfAnnotationChoiceWidgetClass();
}
#endif // PLATFORM(MAC)
#endif // PDFKitImports_h
......@@ -39,6 +39,7 @@
#include "LayerTreeHost.h"
#include "NetscapePlugin.h"
#include "NotificationPermissionRequestManager.h"
#include "PDFKitImports.h"
#include "PageOverlay.h"
#include "PluginProxy.h"
#include "PluginView.h"
......@@ -546,7 +547,7 @@ PassRefPtr<Plugin> WebPage::createPlugin(WebFrame* frame, HTMLPlugInElement* plu
if ((parameters.mimeType == "application/pdf" || parameters.mimeType == "application/postscript")
|| (parameters.mimeType.isEmpty() && (path.endsWith(".pdf", false) || path.endsWith(".ps", false)))) {
#if ENABLE(PDFKIT_PLUGIN)
if (pdfPluginEnabled())
if (shouldUsePDFPlugin())
return PDFPlugin::create(frame);
#endif
return SimplePDFPlugin::create(frame);
......@@ -3676,6 +3677,13 @@ void WebPage::setScrollingPerformanceLoggingEnabled(bool enabled)
frameView->setScrollingPerformanceLoggingEnabled(enabled);
}
#if PLATFORM(MAC)
bool WebPage::shouldUsePDFPlugin() const
{
return pdfPluginEnabled() && pdfLayerControllerClass();
}
#endif
bool WebPage::canPluginHandleResponse(const ResourceResponse& response)
{
#if ENABLE(NETSCAPE_PLUGIN_API)
......
......@@ -619,6 +619,7 @@ public:
void setScrollingPerformanceLoggingEnabled(bool);
#if PLATFORM(MAC)
bool shouldUsePDFPlugin() const;
bool pdfPluginEnabled() const { return m_pdfPluginEnabled; }
void setPDFPluginEnabled(bool enabled) { m_pdfPluginEnabled = enabled; }
#endif
......
......@@ -101,7 +101,7 @@ void WebPage::platformPreferencesDidChange(const WebPreferencesStore& store)
inspector->setInspectorUsesWebKitUserInterface(store.getBoolValueForKey(WebPreferencesKey::inspectorUsesWebKitUserInterfaceKey()));
BOOL omitPDFSupport = [[NSUserDefaults standardUserDefaults] boolForKey:@"WebKitOmitPDFSupport"];
if (!pdfPluginEnabled() && !omitPDFSupport) {
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)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment