diff options
Diffstat (limited to 'Source/WebKit2/PluginProcess')
10 files changed, 154 insertions, 121 deletions
diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp index 1fd1b1124..81b290a1f 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp @@ -69,7 +69,6 @@ PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, c , m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint) , m_pluginDestructionProtectCount(0) , m_pluginDestroyTimer(RunLoop::main(), this, &PluginControllerProxy::destroy) - , m_pluginCreationParameters(0) , m_waitingForDidUpdate(false) , m_pluginCanceledManualStreamLoad(false) #if PLATFORM(MAC) @@ -106,9 +105,7 @@ bool PluginControllerProxy::initialize(const PluginCreationParameters& creationP m_windowNPObject = m_connection->npRemoteObjectMap()->createNPObjectProxy(creationParameters.windowNPObjectID, m_plugin.get()); ASSERT(m_windowNPObject); - m_pluginCreationParameters = &creationParameters; bool returnValue = m_plugin->initialize(this, creationParameters.parameters); - m_pluginCreationParameters = 0; if (!returnValue) { // Get the plug-in so we can pass it to removePluginControllerProxy. The pointer is only @@ -122,7 +119,7 @@ bool PluginControllerProxy::initialize(const PluginCreationParameters& creationP return false; } - platformInitialize(); + platformInitialize(creationParameters); return true; } @@ -269,9 +266,6 @@ NPObject* PluginControllerProxy::pluginElementNPObject() bool PluginControllerProxy::evaluate(NPObject* npObject, const String& scriptString, NPVariant* result, bool allowPopups) { - if (tryToShortCircuitEvaluate(npObject, scriptString, result)) - return true; - PluginDestructionProtector protector(this); NPVariant npObjectAsNPVariant; @@ -293,58 +287,6 @@ bool PluginControllerProxy::evaluate(NPObject* npObject, const String& scriptStr return true; } -bool PluginControllerProxy::tryToShortCircuitInvoke(NPObject* npObject, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result) -{ - // Only try to short circuit evaluate for plug-ins that have the quirk specified. -#if PLUGIN_ARCHITECTURE(MAC) - if (!PluginProcess::shared().netscapePluginModule()->pluginQuirks().contains(PluginQuirks::CanShortCircuitSomeNPRuntimeCallsDuringInitialization)) - return false; -#else - return false; -#endif - - // And only when we're in initialize. - if (!inInitialize()) - return false; - - // And only when the NPObject is the window NPObject. - if (npObject != m_windowNPObject) - return false; - - // And only when we don't have any arguments. - if (argumentCount) - return false; - - IdentifierRep* methodNameRep = static_cast<IdentifierRep*>(methodName); - if (!methodNameRep->isString()) - return false; - - if (!strcmp(methodNameRep->string(), "__flash_getWindowLocation")) { - result.type = NPVariantType_String; - result.value.stringValue = createNPString(m_pluginCreationParameters->parameters.documentURL.utf8()); - returnValue = true; - return true; - } - - if (!strcmp(methodNameRep->string(), "__flash_getTopLocation")) { - if (m_pluginCreationParameters->parameters.toplevelDocumentURL.isNull()) { - // If the toplevel document is URL it means that the frame that the plug-in is in doesn't have access to the toplevel document. - // In this case, just pass the string "[object]" to Flash. - result.type = NPVariantType_String; - result.value.stringValue = createNPString("[object]"); - returnValue = true; - return true; - } - - result.type = NPVariantType_String; - result.value.stringValue = createNPString(m_pluginCreationParameters->parameters.toplevelDocumentURL.utf8()); - returnValue = true; - return true; - } - - return false; -} - void PluginControllerProxy::setStatusbarText(const String& statusbarText) { m_connection->connection()->send(Messages::PluginProxy::SetStatusbarText(statusbarText), m_pluginInstanceID); @@ -598,32 +540,19 @@ void PluginControllerProxy::getFormValue(bool& returnValue, String& formValue) returnValue = m_plugin->getFormValue(formValue); } -bool PluginControllerProxy::tryToShortCircuitEvaluate(NPObject* npObject, const String& scriptString, NPVariant* result) +#if PLUGIN_ARCHITECTURE(X11) +uint64_t PluginControllerProxy::createPluginContainer() { - // Only try to short circuit evaluate for plug-ins that have the quirk specified. -#if PLUGIN_ARCHITECTURE(MAC) - if (!PluginProcess::shared().netscapePluginModule()->pluginQuirks().contains(PluginQuirks::CanShortCircuitSomeNPRuntimeCallsDuringInitialization)) - return false; -#else - return false; -#endif - - // And only when we're in initialize. - if (!inInitialize()) - return false; - - // And only when the NPObject is the window NPObject. - if (npObject != m_windowNPObject) - return false; - - // Now, check for the right strings. - if (scriptString != "function __flash_getWindowLocation() { return window.location; }" - && scriptString != "function __flash_getTopLocation() { return top.location; }") - return false; + uint64_t windowID = 0; + m_connection->connection()->sendSync(Messages::PluginProxy::CreatePluginContainer(), Messages::PluginProxy::CreatePluginContainer::Reply(windowID), m_pluginInstanceID); + return windowID; +} - VOID_TO_NPVARIANT(*result); - return true; +void PluginControllerProxy::windowedPluginGeometryDidChange(const IntRect& frameRect, const IntRect& clipRect, uint64_t windowID) +{ + m_connection->connection()->send(Messages::PluginProxy::WindowedPluginGeometryDidChange(frameRect, clipRect, windowID), m_pluginInstanceID); } +#endif } // namespace WebKit diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.h b/Source/WebKit2/PluginProcess/PluginControllerProxy.h index e860925c1..7022fd0c9 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.h +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.h @@ -84,7 +84,6 @@ private: virtual NPObject* windowScriptNPObject(); virtual NPObject* pluginElementNPObject(); virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups); - virtual bool tryToShortCircuitInvoke(NPObject*, NPIdentifier methodName, const NPVariant* arguments, uint32_t argumentCount, bool& returnValue, NPVariant& result); virtual void setStatusbarText(const String&); virtual bool isAcceleratedCompositingEnabled(); virtual void pluginProcessCrashed(); @@ -104,6 +103,10 @@ private: virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password); virtual void protectPluginFromDestruction(); virtual void unprotectPluginFromDestruction(); +#if PLUGIN_ARCHITECTURE(X11) + virtual uint64_t createPluginContainer(); + virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID); +#endif // Message handlers. void frameDidFinishLoading(uint64_t requestID); @@ -134,16 +137,15 @@ private: void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates); void windowVisibilityChanged(bool); void sendComplexTextInput(const String& textInput); + void setLayerHostingMode(uint32_t); + + void updateLayerHostingContext(LayerHostingMode); #endif void privateBrowsingStateChanged(bool); void getFormValue(bool& returnValue, String& formValue); - bool tryToShortCircuitEvaluate(NPObject*, const String& scriptString, NPVariant* result); - - bool inInitialize() const { return m_pluginCreationParameters; } - - void platformInitialize(); + void platformInitialize(const PluginCreationParameters&); void platformDestroy(); void platformGeometryDidChange(); @@ -171,9 +173,6 @@ private: // code is on the stack. WebCore::RunLoop::Timer<PluginControllerProxy> m_pluginDestroyTimer; - // Will point to the plug-in creation parameters of the plug-in we're currently initializing and will be null when we're done initializing. - const PluginCreationParameters* m_pluginCreationParameters; - // Whether we're waiting for the plug-in proxy in the web process to draw the contents of its // backing store into the web process backing store. bool m_waitingForDidUpdate; diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in index dd9a4d67a..371bee237 100644 --- a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in +++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in @@ -98,6 +98,9 @@ messages -> PluginControllerProxy { # Sent when the containing NSWindow's visibility changes WindowVisibilityChanged(bool isVisible) + + # Sent when the containing window's layer hosting mode changes + SetLayerHostingMode(uint32_t layerHostingMode) #endif # Return a snapshot of the plugin diff --git a/Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp b/Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp index 28304df2a..cbcc1d730 100644 --- a/Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp +++ b/Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp @@ -34,7 +34,7 @@ using namespace WebCore; namespace WebKit { -void PluginControllerProxy::platformInitialize() +void PluginControllerProxy::platformInitialize(const PluginCreationParameters&) { notImplemented(); } diff --git a/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp b/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp index 992d74075..870c01c27 100644 --- a/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp +++ b/Source/WebKit2/PluginProcess/gtk/PluginProcessMainGtk.cpp @@ -26,6 +26,7 @@ #include "config.h" #include "PluginProcessMainGtk.h" +#include "NetscapePlugin.h" #include "PluginProcess.h" #include <WebCore/RunLoop.h> #include <gdk/gdkx.h> @@ -53,12 +54,22 @@ static int webkitgtkXError(Display* xdisplay, XErrorEvent* error) WK_EXPORT int PluginProcessMainGtk(int argc, char* argv[]) { - ASSERT(argc == 2); + ASSERT(argc == 2 || argc == 3); + bool scanPlugin = !strcmp(argv[1], "-scanPlugin"); + ASSERT(argc == 2 || (argc == 3 && scanPlugin)); gtk_init(&argc, &argv); JSC::initializeThreading(); WTF::initializeMainThread(); + + if (scanPlugin) { + String pluginPath(argv[2]); + if (!NetscapePluginModule::scanPlugin(pluginPath)) + return EXIT_FAILURE; + return EXIT_SUCCESS; + } + RunLoop::initializeMainRunLoop(); // Plugins can produce X errors that are handled by the GDK X error handler, which diff --git a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm b/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm index aa2ea4979..f049678d6 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm @@ -29,6 +29,7 @@ #if ENABLE(PLUGIN_PROCESS) #import "LayerHostingContext.h" +#import "PluginCreationParameters.h" #import "PluginProcess.h" #import "PluginProxyMessages.h" #import "WebProcessConnection.h" @@ -53,15 +54,10 @@ mach_port_t PluginControllerProxy::compositingRenderServerPort() return PluginProcess::shared().compositingRenderServerPort(); } -void PluginControllerProxy::platformInitialize() +void PluginControllerProxy::platformInitialize(const PluginCreationParameters& creationParameters) { - CALayer * platformLayer = m_plugin->pluginLayer(); - if (!platformLayer) - return; - ASSERT(!m_layerHostingContext); - m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort()); - m_layerHostingContext->setRootLayer(platformLayer); + updateLayerHostingContext(creationParameters.parameters.layerHostingMode); } void PluginControllerProxy::platformDestroy() @@ -112,6 +108,44 @@ void PluginControllerProxy::sendComplexTextInput(const String& textInput) m_plugin->sendComplexTextInput(textInput); } +void PluginControllerProxy::setLayerHostingMode(uint32_t opaqueLayerHostingMode) +{ + LayerHostingMode layerHostingMode = static_cast<LayerHostingMode>(opaqueLayerHostingMode); + + m_plugin->setLayerHostingMode(layerHostingMode); + updateLayerHostingContext(layerHostingMode); + + if (m_layerHostingContext) + m_connection->connection()->send(Messages::PluginProxy::SetLayerHostingContextID(m_layerHostingContext->contextID()), m_pluginInstanceID); +} + +void PluginControllerProxy::updateLayerHostingContext(LayerHostingMode layerHostingMode) +{ + CALayer *platformLayer = m_plugin->pluginLayer(); + if (!platformLayer) + return; + + if (m_layerHostingContext) { + if (m_layerHostingContext->layerHostingMode() == layerHostingMode) + return; + + m_layerHostingContext->invalidate(); + } + + switch (layerHostingMode) { + case LayerHostingModeDefault: + m_layerHostingContext = LayerHostingContext::createForPort(PluginProcess::shared().compositingRenderServerPort()); + break; +#if HAVE(LAYER_HOSTING_IN_WINDOW_SERVER) + case LayerHostingModeInWindowServer: + m_layerHostingContext = LayerHostingContext::createForWindowServer(); + break; +#endif + } + + m_layerHostingContext->setRootLayer(platformLayer); +} + } // namespace WebKit #endif // ENABLE(PLUGIN_PROCESS) diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm index 8561f9959..0ee4cb642 100644 --- a/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm +++ b/Source/WebKit2/PluginProcess/mac/PluginProcessMainMac.mm @@ -32,6 +32,7 @@ #import "EnvironmentUtilities.h" #import "NetscapePluginModule.h" #import "PluginProcess.h" +#import <Foundation/NSUserDefaults.h> #import <WebCore/RunLoop.h> #import <WebKitSystemInterface.h> #import <mach/mach_error.h> @@ -78,7 +79,7 @@ int PluginProcessMain(const CommandLine& commandLine) mach_port_t serverPort; kern_return_t kr = bootstrap_look_up(bootstrap_port, serviceName.utf8().data(), &serverPort); if (kr) { - fprintf(stderr, "bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr); + WTFLogAlways("bootstrap_look_up result: %s (%x)\n", mach_error_string(kr), kr); return EXIT_FAILURE; } @@ -87,6 +88,18 @@ int PluginProcessMain(const CommandLine& commandLine) if (cfLocalization) WKSetDefaultLocalization(cfLocalization.get()); +#if defined(__i386__) + { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + NSDictionary *defaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"AppleMagnifiedMode", nil]; + [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; + [defaults release]; + + [pool drain]; + } +#endif + #if !SHOW_CRASH_REPORTER // Installs signal handlers that exit on a crash so that CrashReporter does not show up. signal(SIGILL, _exit); diff --git a/Source/WebKit2/PluginProcess/mac/com.apple.WebKit.PluginProcess.sb.in b/Source/WebKit2/PluginProcess/mac/com.apple.WebKit.PluginProcess.sb.in index ea5241a39..276399fe5 100644 --- a/Source/WebKit2/PluginProcess/mac/com.apple.WebKit.PluginProcess.sb.in +++ b/Source/WebKit2/PluginProcess/mac/com.apple.WebKit.PluginProcess.sb.in @@ -110,12 +110,15 @@ (global-name "com.apple.ImageCaptureExtension2.presence") (global-name "com.apple.SecurityServer") (global-name "com.apple.SystemConfiguration.configd") + (global-name "com.apple.SystemConfiguration.PPPController") + (global-name "com.apple.SystemConfiguration.SCNetworkReachability") (global-name "com.apple.audio.VDCAssistant") (global-name "com.apple.audio.audiohald") (global-name "com.apple.audio.coreaudiod") (global-name "com.apple.cmio.VDCAssistant") (global-name "com.apple.cookied") ;; FIXME: <rdar://problem/10790768> Limit access to cookies. (global-name "com.apple.cvmsServ") + (global-name "com.apple.networkd") (global-name "com.apple.ocspd") (global-name "com.apple.pasteboard.1") (global-name "com.apple.window_proxies") diff --git a/Source/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp index 6c592425c..743adfaa4 100644 --- a/Source/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp +++ b/Source/WebKit2/PluginProcess/qt/PluginControllerProxyQt.cpp @@ -35,7 +35,7 @@ using namespace WebCore; namespace WebKit { -void PluginControllerProxy::platformInitialize() +void PluginControllerProxy::platformInitialize(const PluginCreationParameters&) { notImplemented(); } diff --git a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp index d3a0ec3e2..8cb6bcdf5 100644 --- a/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp +++ b/Source/WebKit2/PluginProcess/qt/PluginProcessMainQt.cpp @@ -1,5 +1,6 @@ /* * Copyright (C) 2010, 2011 Nokia Inc. All rights reserved. + * Copyright (C) 2011 University of Szeged. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -24,44 +25,84 @@ */ #include "config.h" -#include "PluginProcessMain.h" #if ENABLE(PLUGIN_PROCESS) +#include "PluginProcessMain.h" -#include "CommandLine.h" +#include "NetscapePluginModule.h" #include "PluginProcess.h" -#include <WebCore/NotImplemented.h> +#include <QDebug> +#include <QGuiApplication> +#include <QStringList> +#include <QtGlobal> #include <WebCore/RunLoop.h> #include <runtime/InitializeThreading.h> #include <wtf/MainThread.h> -#include <wtf/RetainPtr.h> -#include <wtf/text/CString.h> -#include <wtf/text/WTFString.h> - -#define SHOW_CRASH_REPORTER 1 +#include <wtf/Threading.h> using namespace WebCore; namespace WebKit { -int PluginProcessMain(const CommandLine& commandLine) +static void messageHandler(QtMsgType type, const char* message) { - String serviceName = commandLine["servicename"]; - if (serviceName.isEmpty()) - return EXIT_FAILURE; + if (type == QtCriticalMsg) { + fprintf(stderr, "%s\n", message); + return; + } + + // Do nothing +} -#if !SHOW_CRASH_REPORTER - // Installs signal handlers that exit on a crash so that CrashReporter does not show up. - signal(SIGILL, _exit); - signal(SIGFPE, _exit); - signal(SIGBUS, _exit); - signal(SIGSEGV, _exit); -#endif +static bool initializeGtk() +{ + QLibrary gtkLibrary(QLatin1String("libgtk-x11-2.0"), 0); + if (!gtkLibrary.load()) + return false; + typedef void* (*gtk_init_ptr)(void*, void*); + gtk_init_ptr gtkInit = reinterpret_cast<gtk_init_ptr>(gtkLibrary.resolve("gtk_init")); + if (!gtkInit) + return false; + gtkInit(0, 0); + return true; +} + +Q_DECL_EXPORT int PluginProcessMain(int argc, char** argv) +{ + QByteArray suppressOutput = qgetenv("QT_WEBKIT_SUPPRESS_WEB_PROCESS_OUTPUT"); + if (!suppressOutput.isEmpty() && suppressOutput != "0") + qInstallMsgHandler(messageHandler); + + QGuiApplication app(argc, argv); + + // Workaround the issue that some versions of flash does not initialize Gtk properly. + if (!initializeGtk()) + return EXIT_FAILURE; JSC::initializeThreading(); WTF::initializeMainThread(); + + if (argc <= 1) + return EXIT_FAILURE; + + if (app.arguments().at(1) == QLatin1String("-scanPlugin")) { + if (argc != 3) + return EXIT_FAILURE; + String pluginPath(app.arguments().at(2)); + if (!NetscapePluginModule::scanPlugin(pluginPath)) + return EXIT_FAILURE; + return EXIT_SUCCESS; + } + RunLoop::initializeMainRunLoop(); + // Create the connection. + bool isNumber = false; + int identifier = app.arguments().at(1).toInt(&isNumber, 10); + if (!isNumber) + return EXIT_FAILURE; + WebKit::PluginProcess::shared().initialize(identifier, RunLoop::main()); + RunLoop::run(); return 0; |
