summaryrefslogtreecommitdiff
path: root/Source/WebKit2/PluginProcess
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebKit2/PluginProcess
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit2/PluginProcess')
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/Info.plist36
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm123
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist54
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/Info.plist49
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm81
-rw-r--r--Source/WebKit2/PluginProcess/EntryPoint/unix/PluginProcessMain.cpp (renamed from Source/WebKit2/PluginProcess/mac/PluginProcessShim.h)30
-rw-r--r--Source/WebKit2/PluginProcess/PluginControllerProxy.cpp143
-rw-r--r--Source/WebKit2/PluginProcess/PluginControllerProxy.h114
-rw-r--r--Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in46
-rw-r--r--Source/WebKit2/PluginProcess/PluginCreationParameters.cpp20
-rw-r--r--Source/WebKit2/PluginProcess/PluginCreationParameters.h15
-rw-r--r--Source/WebKit2/PluginProcess/PluginProcess.cpp155
-rw-r--r--Source/WebKit2/PluginProcess/PluginProcess.h80
-rw-r--r--Source/WebKit2/PluginProcess/PluginProcess.messages.in14
-rw-r--r--Source/WebKit2/PluginProcess/WebProcessConnection.cpp86
-rw-r--r--Source/WebKit2/PluginProcess/WebProcessConnection.h39
-rw-r--r--Source/WebKit2/PluginProcess/WebProcessConnection.messages.in8
-rw-r--r--Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm157
-rw-r--r--Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm471
-rw-r--r--Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm321
-rw-r--r--Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp85
-rw-r--r--Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.h10
-rw-r--r--Source/WebKit2/PluginProcess/unix/PluginProcessUnix.cpp2
23 files changed, 459 insertions, 1680 deletions
diff --git a/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/Info.plist b/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/Info.plist
deleted file mode 100644
index 9ca9563e2..000000000
--- a/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/Info.plist
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleExecutable</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleGetInfoString</key>
- <string>${BUNDLE_VERSION}, Copyright 2003-2013 Apple Inc.</string>
- <key>CFBundleIdentifier</key>
- <string>com.apple.WebKit.${PRODUCT_NAME}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>${SHORT_VERSION_STRING}</string>
- <key>CFBundleVersion</key>
- <string>${BUNDLE_VERSION}</string>
- <key>LSFileQuarantineEnabled</key>
- <true/>
- <key>LSMinimumSystemVersion</key>
- <string>${MACOSX_DEPLOYMENT_TARGET}</string>
- <key>LSUIElement</key>
- <true/>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>WebKitEntryPoint</key>
- <string>PluginProcessMain</string>
- <key>NSSupportsAutomaticGraphicsSwitching</key>
- <true/>
- <key>NSSupportsAppNap</key>
- <true/>
-</dict>
-</plist>
diff --git a/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm b/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm
deleted file mode 100644
index 73045d391..000000000
--- a/Source/WebKit2/PluginProcess/EntryPoint/mac/LegacyProcess/PluginProcessMain.mm
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2010, 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#if ENABLE(PLUGIN_PROCESS)
-
-#import "ChildProcessEntryPoint.h"
-#import "EnvironmentUtilities.h"
-#import "NetscapePluginModule.h"
-#import "PluginProcess.h"
-#import "WKBase.h"
-#import <WebCore/RunLoop.h>
-
-#if USE(APPKIT)
-@interface NSApplication (WebNSApplicationDetails)
--(void)_installAutoreleasePoolsOnCurrentThreadIfNecessary;
-@end
-#endif
-
-using namespace WebCore;
-
-namespace WebKit {
-
-class PluginProcessMainDelegate : public ChildProcessMainDelegate {
-public:
- PluginProcessMainDelegate(const CommandLine& commandLine)
- : ChildProcessMainDelegate(commandLine)
- {
- }
-
- virtual void doPreInitializationWork()
- {
- // Remove the PluginProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes
- // spawned by the PluginProcess don't try to insert the shim and crash.
- EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
-
-#if USE(APPKIT)
- RunLoop::setUseApplicationRunLoopOnMainRunLoop();
-
- // Initialize AppKit.
- [NSApplication sharedApplication];
-
- // Installs autorelease pools on the current runloop which prevents memory from accumulating between user events.
- // FIXME: Remove when <rdar://problem/8929426> is fixed.
- [NSApp _installAutoreleasePoolsOnCurrentThreadIfNecessary];
-#endif
-
- // Check if we're being spawned to write a MIME type preferences file.
- String pluginPath = m_commandLine["createPluginMIMETypesPreferences"];
- if (!pluginPath.isEmpty()) {
- // We are never going to get to the actual initialization, so initialize WebKit2 now.
- InitializeWebKit2();
-
- if (!NetscapePluginModule::createPluginMIMETypesPreferences(pluginPath))
- exit(EXIT_FAILURE);
- exit(EXIT_SUCCESS);
- }
- }
-
- virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData)
- {
- String pluginPath = m_commandLine["plugin-path"];
- if (pluginPath.isEmpty())
- return false;
- extraInitializationData.add("plugin-path", pluginPath);
-
- String disableSandbox = m_commandLine["disable-sandbox"];
- if (!disableSandbox.isEmpty())
- extraInitializationData.add("disable-sandbox", disableSandbox);
-
- return true;
- }
-
- virtual void doPostRunWork()
- {
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
- // If we have private temporary and cache directories, clean them up.
- if (getenv("DIRHELPER_USER_DIR_SUFFIX")) {
- char darwinDirectory[PATH_MAX];
- if (confstr(_CS_DARWIN_USER_TEMP_DIR, darwinDirectory, sizeof(darwinDirectory)))
- [[NSFileManager defaultManager] removeItemAtPath:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:darwinDirectory length:strlen(darwinDirectory)] error:nil];
- if (confstr(_CS_DARWIN_USER_CACHE_DIR, darwinDirectory, sizeof(darwinDirectory)))
- [[NSFileManager defaultManager] removeItemAtPath:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:darwinDirectory length:strlen(darwinDirectory)] error:nil];
- }
-#endif
- }
-};
-
-} // namespace WebKit
-
-using namespace WebKit;
-
-extern "C" WK_EXPORT int PluginProcessMain(int argc, char** argv);
-
-int PluginProcessMain(int argc, char** argv)
-{
- return ChildProcessMain<PluginProcess, PluginProcessMainDelegate>(argc, argv);
-}
-
-#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist b/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist
deleted file mode 100644
index 31e554130..000000000
--- a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.32-64.Info.plist
+++ /dev/null
@@ -1,54 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleGetInfoString</key>
- <string>${BUNDLE_VERSION}, Copyright 2003-2013 Apple Inc.</string>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIdentifier</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>XPC!</string>
- <key>CFBundleShortVersionString</key>
- <string>${SHORT_VERSION_STRING}</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>${BUNDLE_VERSION}</string>
- <key>LSFileQuarantineEnabled</key>
- <true/>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>WebKitEntryPoint</key>
- <string>PluginServiceInitializer</string>
- <key>LSUIElement</key>
- <true/>
- <key>NSSupportsAutomaticGraphicsSwitching</key>
- <true/>
- <key>NSSupportsAppNap</key>
- <true/>
- <key>XPCService</key>
- <dict>
- <key>ServiceType</key>
- <string>Application</string>
- <key>RunLoopType</key>
- <string>_NSApplicationMain</string>
- <key>JoinExistingSession</key>
- <true/>
- <key>_MultipleInstances</key>
- <true/>
- <key>EnvironmentVariables</key>
- <dict>
- <key>DYLD_INSERT_LIBRARIES</key>
- <string>$(WEBKIT2_FRAMEWORKS_DIR)/WebKit2.framework/PluginProcess.app/Contents/MacOS/PluginProcessShim.dylib</string>
- </dict>
- </dict>
-</dict>
-</plist>
diff --git a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/Info.plist b/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/Info.plist
deleted file mode 100644
index c220404eb..000000000
--- a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginService.Development/Info.plist
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleGetInfoString</key>
- <string>${BUNDLE_VERSION}, Copyright 2003-2013 Apple Inc.</string>
- <key>CFBundleDevelopmentRegion</key>
- <string>English</string>
- <key>CFBundleExecutable</key>
- <string>${EXECUTABLE_NAME}</string>
- <key>CFBundleIdentifier</key>
- <string>com.apple.WebKit.Plugin.Development</string>
- <key>CFBundleInfoDictionaryVersion</key>
- <string>6.0</string>
- <key>CFBundleName</key>
- <string>${PRODUCT_NAME}</string>
- <key>CFBundlePackageType</key>
- <string>XPC!</string>
- <key>CFBundleShortVersionString</key>
- <string>${SHORT_VERSION_STRING}</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>${BUNDLE_VERSION}</string>
- <key>LSFileQuarantineEnabled</key>
- <true/>
- <key>NSPrincipalClass</key>
- <string>NSApplication</string>
- <key>WebKitEntryPoint</key>
- <string>PluginServiceInitializer</string>
- <key>LSUIElement</key>
- <true/>
- <key>NSSupportsAutomaticGraphicsSwitching</key>
- <true/>
- <key>NSSupportsAppNap</key>
- <true/>
- <key>XPCService</key>
- <dict>
- <key>ServiceType</key>
- <string>Application</string>
- <key>RunLoopType</key>
- <string>_NSApplicationMain</string>
- <key>JoinExistingSession</key>
- <true/>
- <key>_MultipleInstances</key>
- <true/>
- </dict>
-</dict>
-</plist>
diff --git a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm b/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm
deleted file mode 100644
index 87fcc4fd3..000000000
--- a/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-
-#if HAVE(XPC)
-
-#import "EnvironmentUtilities.h"
-#import "PluginProcess.h"
-#import "WKBase.h"
-#import "XPCServiceEntryPoint.h"
-#import <WebCore/RunLoop.h>
-
-namespace WebKit {
-
-class PluginServiceInitializerDelegate : public XPCServiceInitializerDelegate {
-public:
- PluginServiceInitializerDelegate(xpc_connection_t connection, xpc_object_t initializerMessage)
- : XPCServiceInitializerDelegate(connection, initializerMessage)
- {
- }
-
- virtual bool getExtraInitializationData(HashMap<String, String>& extraInitializationData)
- {
- xpc_object_t extraDataInitializationDataObject = xpc_dictionary_get_value(m_initializerMessage, "extra-initialization-data");
-
- String pluginPath = xpc_dictionary_get_string(extraDataInitializationDataObject, "plugin-path");
- if (pluginPath.isEmpty())
- return false;
- extraInitializationData.add("plugin-path", pluginPath);
-
- String disableSandbox = xpc_dictionary_get_string(extraDataInitializationDataObject, "disable-sandbox");
- if (!disableSandbox.isEmpty())
- extraInitializationData.add("disable-sandbox", disableSandbox);
-
- return true;
- }
-};
-
-} // namespace WebKit
-
-using namespace WebCore;
-using namespace WebKit;
-
-extern "C" WK_EXPORT void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
-
-void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
-{
- // FIXME: Add support for teardown from PluginProcessMain.mm
-
- // Remove the PluginProcess shim from the DYLD_INSERT_LIBRARIES environment variable so any processes
- // spawned by the PluginProcess don't try to insert the shim and crash.
- EnvironmentUtilities::stripValuesEndingWithString("DYLD_INSERT_LIBRARIES", "/PluginProcessShim.dylib");
- RunLoop::setUseApplicationRunLoopOnMainRunLoop();
-
- XPCServiceInitializer<PluginProcess, PluginServiceInitializerDelegate>(connection, initializerMessage);
-}
-
-#endif // HAVE(XPC)
diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.h b/Source/WebKit2/PluginProcess/EntryPoint/unix/PluginProcessMain.cpp
index 5a788a312..3df509057 100644
--- a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.h
+++ b/Source/WebKit2/PluginProcess/EntryPoint/unix/PluginProcessMain.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Igalia S.L.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,29 +23,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PluginProcessShim_h
-#define PluginProcessShim_h
+#include "PluginProcessMainUnix.h"
-@class NSWindow;
-
-#include <Carbon/Carbon.h>
-
-namespace WebKit {
-
-struct PluginProcessShimCallbacks {
- bool (*shouldCallRealDebugger)();
- bool (*isWindowActive)(WindowRef, bool& result);
- UInt32 (*getCurrentEventButtonState)();
- void (*beginModal)();
- void (*endModal)();
- void (*carbonWindowShown)(WindowRef);
- void (*carbonWindowHidden)(WindowRef);
- void (*setModal)(bool);
- bool (*openCFURLRef)(CFURLRef, int32_t& returnValue, CFURLRef* launchedURL);
-};
-
-typedef void (*PluginProcessShimInitializeFunc)(const PluginProcessShimCallbacks&);
+using namespace WebKit;
+int main(int argc, char** argv)
+{
+ return PluginProcessMainUnix(argc, argv);
}
-
-#endif // PluginProcessShim_h
diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
index 74751b2a2..dc6d34326 100644
--- a/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
+++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "PluginControllerProxy.h"
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "DataReference.h"
#include "NPObjectProxy.h"
@@ -41,12 +41,13 @@
#include "WebCoreArgumentCoders.h"
#include "WebProcessConnection.h"
#include <WebCore/GraphicsContext.h>
+#include <WebCore/HTTPHeaderMap.h>
#include <WebCore/IdentifierRep.h>
#include <WebCore/NotImplemented.h>
#include <wtf/TemporaryChange.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include "LayerHostingContext.h"
#endif
@@ -54,31 +55,28 @@ using namespace WebCore;
namespace WebKit {
-PassOwnPtr<PluginControllerProxy> PluginControllerProxy::create(WebProcessConnection* connection, const PluginCreationParameters& creationParameters)
-{
- return adoptPtr(new PluginControllerProxy(connection, creationParameters));
-}
-
PluginControllerProxy::PluginControllerProxy(WebProcessConnection* connection, const PluginCreationParameters& creationParameters)
: m_connection(connection)
, m_pluginInstanceID(creationParameters.pluginInstanceID)
, m_userAgent(creationParameters.userAgent)
, m_isPrivateBrowsingEnabled(creationParameters.isPrivateBrowsingEnabled)
-#if USE(ACCELERATED_COMPOSITING)
+ , m_isMuted(creationParameters.isMuted)
, m_isAcceleratedCompositingEnabled(creationParameters.isAcceleratedCompositingEnabled)
-#endif
, m_isInitializing(false)
+ , m_isVisible(false)
+ , m_isWindowVisible(false)
, m_paintTimer(RunLoop::main(), this, &PluginControllerProxy::paint)
, m_pluginDestructionProtectCount(0)
, m_pluginDestroyTimer(RunLoop::main(), this, &PluginControllerProxy::destroy)
, m_waitingForDidUpdate(false)
, m_pluginCanceledManualStreamLoad(false)
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
, m_isComplexTextInputEnabled(false)
#endif
, m_contentsScaleFactor(creationParameters.contentsScaleFactor)
, m_windowNPObject(0)
, m_pluginElementNPObject(0)
+ , m_visiblityActivity("Plugin is visible.")
{
}
@@ -99,18 +97,19 @@ void PluginControllerProxy::setInitializationReply(PassRefPtr<Messages::WebProce
m_initializationReply = reply;
}
-PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> PluginControllerProxy::takeInitializationReply()
+RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> PluginControllerProxy::takeInitializationReply()
{
- return m_initializationReply.release();
+ return m_initializationReply;
}
bool PluginControllerProxy::initialize(const PluginCreationParameters& creationParameters)
{
ASSERT(!m_plugin);
-
- TemporaryChange<bool> initializing(m_isInitializing, true);
- m_plugin = NetscapePlugin::create(PluginProcess::shared().netscapePluginModule());
+ ASSERT(!m_isInitializing);
+ m_isInitializing = true; // Cannot use TemporaryChange here, because this object can be deleted before the function returns.
+
+ m_plugin = NetscapePlugin::create(PluginProcess::singleton().netscapePluginModule());
if (!m_plugin) {
// This will delete the plug-in controller proxy object.
m_connection->removePluginControllerProxy(this, 0);
@@ -127,7 +126,7 @@ bool PluginControllerProxy::initialize(const PluginCreationParameters& creationP
// used as an identifier so it's OK to just get a weak reference.
Plugin* plugin = m_plugin.get();
- m_plugin = 0;
+ m_plugin = nullptr;
// This will delete the plug-in controller proxy object.
m_connection->removePluginControllerProxy(this, plugin);
@@ -136,6 +135,7 @@ bool PluginControllerProxy::initialize(const PluginCreationParameters& creationP
platformInitialize(creationParameters);
+ m_isInitializing = false;
return true;
}
@@ -156,7 +156,7 @@ void PluginControllerProxy::destroy()
Plugin* plugin = m_plugin.get();
m_plugin->destroyPlugin();
- m_plugin = 0;
+ m_plugin = nullptr;
platformDestroy();
@@ -183,9 +183,9 @@ void PluginControllerProxy::paint()
ASSERT(m_plugin);
// Create a graphics context.
- OwnPtr<GraphicsContext> graphicsContext = m_backingStore->createGraphicsContext();
+ auto graphicsContext = m_backingStore->createGraphicsContext();
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
// FIXME: We should really call applyDeviceScaleFactor instead of scale, but that ends up calling into WKSI
// which we currently don't have initiated in the plug-in process.
graphicsContext->scale(FloatSize(m_contentsScaleFactor, m_contentsScaleFactor));
@@ -194,7 +194,7 @@ void PluginControllerProxy::paint()
if (m_plugin->isTransparent())
graphicsContext->clearRect(dirtyRect);
- m_plugin->paint(graphicsContext.get(), dirtyRect);
+ m_plugin->paint(*graphicsContext, dirtyRect);
m_connection->connection()->send(Messages::PluginProxy::Update(dirtyRect), m_pluginInstanceID);
}
@@ -220,13 +220,6 @@ void PluginControllerProxy::startPaintTimer()
m_waitingForDidUpdate = true;
}
-bool PluginControllerProxy::isPluginVisible()
-{
- // FIXME: Implement this.
- notImplemented();
- return false;
-}
-
void PluginControllerProxy::invalidate(const IntRect& rect)
{
IntRect dirtyRect = rect;
@@ -248,6 +241,11 @@ void PluginControllerProxy::loadURL(uint64_t requestID, const String& method, co
m_connection->connection()->send(Messages::PluginProxy::LoadURL(requestID, method, urlString, target, headerFields, httpBody, allowPopups), m_pluginInstanceID);
}
+void PluginControllerProxy::continueStreamLoad(uint64_t streamID)
+{
+ m_connection->connection()->send(Messages::PluginProxy::ContinueStreamLoad(streamID), m_pluginInstanceID);
+}
+
void PluginControllerProxy::cancelStreamLoad(uint64_t streamID)
{
m_connection->connection()->send(Messages::PluginProxy::CancelStreamLoad(streamID), m_pluginInstanceID);
@@ -311,6 +309,11 @@ bool PluginControllerProxy::evaluate(NPObject* npObject, const String& scriptStr
return true;
}
+void PluginControllerProxy::setPluginIsPlayingAudio(bool pluginIsPlayingAudio)
+{
+ m_connection->connection()->send(Messages::PluginProxy::SetPluginIsPlayingAudio(pluginIsPlayingAudio), m_pluginInstanceID);
+}
+
void PluginControllerProxy::setStatusbarText(const String& statusbarText)
{
m_connection->connection()->send(Messages::PluginProxy::SetStatusbarText(statusbarText), m_pluginInstanceID);
@@ -327,12 +330,6 @@ void PluginControllerProxy::pluginProcessCrashed()
ASSERT_NOT_REACHED();
}
-void PluginControllerProxy::willSendEventToPlugin()
-{
- // This is only used when running plugins in the web process.
- ASSERT_NOT_REACHED();
-}
-
void PluginControllerProxy::didInitializePlugin()
{
// This should only be called on the plugin in the web process.
@@ -432,17 +429,56 @@ void PluginControllerProxy::geometryDidChange(const IntSize& pluginSize, const I
m_plugin->geometryDidChange(pluginSize, clipRect, pluginToRootViewTransform);
}
+void PluginControllerProxy::visibilityDidChange(bool isVisible)
+{
+ m_isVisible = isVisible;
+
+ ASSERT(m_plugin);
+ m_plugin->visibilityDidChange(isVisible);
+
+ updateVisibilityActivity();
+}
+
+void PluginControllerProxy::windowFocusChanged(bool hasFocus)
+{
+ ASSERT(m_plugin);
+ m_plugin->windowFocusChanged(hasFocus);
+}
+
+void PluginControllerProxy::windowVisibilityChanged(bool isVisible)
+{
+ m_isWindowVisible = isVisible;
+
+ ASSERT(m_plugin);
+ m_plugin->windowVisibilityChanged(isVisible);
+
+ updateVisibilityActivity();
+}
+
+void PluginControllerProxy::updateVisibilityActivity()
+{
+ if (m_isVisible && m_isWindowVisible)
+ m_visiblityActivity.start();
+ else
+ m_visiblityActivity.stop();
+}
+
void PluginControllerProxy::didEvaluateJavaScript(uint64_t requestID, const String& result)
{
m_plugin->didEvaluateJavaScript(requestID, result);
}
+void PluginControllerProxy::streamWillSendRequest(uint64_t streamID, const String& requestURLString, const String& redirectResponseURLString, uint32_t redirectResponseStatusCode)
+{
+ m_plugin->streamWillSendRequest(streamID, URL(ParsedURLString, requestURLString), URL(ParsedURLString, redirectResponseURLString), redirectResponseStatusCode);
+}
+
void PluginControllerProxy::streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers)
{
- m_plugin->streamDidReceiveResponse(streamID, KURL(ParsedURLString, responseURLString), streamLength, lastModifiedTime, mimeType, headers, String());
+ m_plugin->streamDidReceiveResponse(streamID, URL(ParsedURLString, responseURLString), streamLength, lastModifiedTime, mimeType, headers, String());
}
-void PluginControllerProxy::streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data)
+void PluginControllerProxy::streamDidReceiveData(uint64_t streamID, const IPC::DataReference& data)
{
m_plugin->streamDidReceiveData(streamID, reinterpret_cast<const char*>(data.data()), data.size());
}
@@ -462,10 +498,10 @@ void PluginControllerProxy::manualStreamDidReceiveResponse(const String& respons
if (m_pluginCanceledManualStreamLoad)
return;
- m_plugin->manualStreamDidReceiveResponse(KURL(ParsedURLString, responseURLString), streamLength, lastModifiedTime, mimeType, headers, String());
+ m_plugin->manualStreamDidReceiveResponse(URL(ParsedURLString, responseURLString), streamLength, lastModifiedTime, mimeType, headers, String());
}
-void PluginControllerProxy::manualStreamDidReceiveData(const CoreIPC::DataReference& data)
+void PluginControllerProxy::manualStreamDidReceiveData(const IPC::DataReference& data)
{
if (m_pluginCanceledManualStreamLoad)
return;
@@ -488,17 +524,9 @@ void PluginControllerProxy::manualStreamDidFail(bool wasCancelled)
m_plugin->manualStreamDidFail(wasCancelled);
}
-
-void PluginControllerProxy::handleMouseEvent(const WebMouseEvent& mouseEvent, PassRefPtr<Messages::PluginControllerProxy::HandleMouseEvent::DelayedReply> reply)
-{
- // Always let the web process think that we've handled this mouse event, even before passing it along to the plug-in.
- // This is a workaround for
- // <rdar://problem/9299901> UI process thinks the page is unresponsive when a plug-in is showing a context menu.
- // The web process sends a synchronous HandleMouseEvent message and the plug-in process spawns a nested
- // run loop when showing the context menu, so eventually the unresponsiveness timer kicks in in the UI process.
- // FIXME: We should come up with a better way to do this.
- reply->send(true);
+void PluginControllerProxy::handleMouseEvent(const WebMouseEvent& mouseEvent)
+{
m_plugin->handleMouseEvent(mouseEvent);
}
@@ -537,6 +565,11 @@ void PluginControllerProxy::handlesPageScaleFactor(bool& isHandled)
isHandled = m_plugin->handlesPageScaleFactor();
}
+void PluginControllerProxy::requiresUnifiedScaleFactor(bool& required)
+{
+ required = m_plugin->requiresUnifiedScaleFactor();
+}
+
void PluginControllerProxy::paintEntirePlugin()
{
if (m_pluginSize.isEmpty())
@@ -599,6 +632,15 @@ void PluginControllerProxy::privateBrowsingStateChanged(bool isPrivateBrowsingEn
m_plugin->privateBrowsingStateChanged(isPrivateBrowsingEnabled);
}
+void PluginControllerProxy::mutedStateChanged(bool isMuted)
+{
+ if (m_isMuted == isMuted)
+ return;
+
+ m_isMuted = isMuted;
+ m_plugin->mutedStateChanged(isMuted);
+}
+
void PluginControllerProxy::getFormValue(bool& returnValue, String& formValue)
{
returnValue = m_plugin->getFormValue(formValue);
@@ -616,8 +658,13 @@ void PluginControllerProxy::windowedPluginGeometryDidChange(const IntRect& frame
{
m_connection->connection()->send(Messages::PluginProxy::WindowedPluginGeometryDidChange(frameRect, clipRect, windowID), m_pluginInstanceID);
}
+
+void PluginControllerProxy::windowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID)
+{
+ m_connection->connection()->send(Messages::PluginProxy::WindowedPluginVisibilityDidChange(isVisible, windowID), m_pluginInstanceID);
+}
#endif
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.h b/Source/WebKit2/PluginProcess/PluginControllerProxy.h
index 2e402b4d2..8b5fba9b0 100644
--- a/Source/WebKit2/PluginProcess/PluginControllerProxy.h
+++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.h
@@ -26,7 +26,7 @@
#ifndef PluginControllerProxy_h
#define PluginControllerProxy_h
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "Connection.h"
#include "Plugin.h"
@@ -34,11 +34,12 @@
#include "PluginControllerProxyMessages.h"
#include "ShareableBitmap.h"
#include "WebProcessConnectionMessages.h"
-#include <WebCore/RunLoop.h>
#include <WebCore/SecurityOrigin.h>
+#include <WebCore/UserActivity.h>
#include <wtf/Noncopyable.h>
+#include <wtf/RunLoop.h>
-namespace CoreIPC {
+namespace IPC {
class DataReference;
}
@@ -53,7 +54,7 @@ class PluginControllerProxy : PluginController {
WTF_MAKE_NONCOPYABLE(PluginControllerProxy);
public:
- static PassOwnPtr<PluginControllerProxy> create(WebProcessConnection*, const PluginCreationParameters&);
+ PluginControllerProxy(WebProcessConnection*, const PluginCreationParameters&);
~PluginControllerProxy();
uint64_t pluginInstanceID() const { return m_pluginInstanceID; }
@@ -61,12 +62,12 @@ public:
bool initialize(const PluginCreationParameters&);
void destroy();
- void didReceivePluginControllerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
- void didReceiveSyncPluginControllerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
+ void didReceivePluginControllerProxyMessage(IPC::Connection&, IPC::MessageDecoder&);
+ void didReceiveSyncPluginControllerProxyMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
bool wantsWheelEvents() const;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
uint32_t remoteLayerClientID() const;
#endif
@@ -75,65 +76,66 @@ public:
bool isInitializing() const { return m_isInitializing; }
void setInitializationReply(PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>);
- PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> takeInitializationReply();
+ RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> takeInitializationReply();
private:
- PluginControllerProxy(WebProcessConnection*, const PluginCreationParameters&);
-
void startPaintTimer();
void paint();
// PluginController
- virtual bool isPluginVisible();
- virtual void invalidate(const WebCore::IntRect&);
- virtual String userAgent();
- virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups);
- virtual void cancelStreamLoad(uint64_t streamID);
- virtual void cancelManualStreamLoad();
- virtual NPObject* windowScriptNPObject();
- virtual NPObject* pluginElementNPObject();
- virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups);
- virtual void setStatusbarText(const String&);
- virtual bool isAcceleratedCompositingEnabled();
- virtual void pluginProcessCrashed();
- virtual void willSendEventToPlugin();
- virtual void didInitializePlugin() OVERRIDE;
- virtual void didFailToInitializePlugin() OVERRIDE;
-
-#if PLATFORM(MAC)
- virtual void pluginFocusOrWindowFocusChanged(bool) OVERRIDE;
- virtual void setComplexTextInputState(PluginComplexTextInputState) OVERRIDE;
- virtual mach_port_t compositingRenderServerPort() OVERRIDE;
- virtual void openPluginPreferencePane() OVERRIDE;
+ virtual void invalidate(const WebCore::IntRect&) override;
+ virtual String userAgent() override;
+ virtual void loadURL(uint64_t requestID, const String& method, const String& urlString, const String& target, const WebCore::HTTPHeaderMap& headerFields, const Vector<uint8_t>& httpBody, bool allowPopups) override;
+ virtual void continueStreamLoad(uint64_t streamID) override;
+ virtual void cancelStreamLoad(uint64_t streamID) override;
+ virtual void cancelManualStreamLoad() override;
+ virtual NPObject* windowScriptNPObject() override;
+ virtual NPObject* pluginElementNPObject() override;
+ virtual bool evaluate(NPObject*, const String& scriptString, NPVariant* result, bool allowPopups) override;
+ virtual void setPluginIsPlayingAudio(bool) override;
+ virtual void setStatusbarText(const String&) override;
+ virtual bool isAcceleratedCompositingEnabled() override;
+ virtual void pluginProcessCrashed() override;
+ virtual void didInitializePlugin() override;
+ virtual void didFailToInitializePlugin() override;
+
+#if PLATFORM(COCOA)
+ virtual void pluginFocusOrWindowFocusChanged(bool) override;
+ virtual void setComplexTextInputState(PluginComplexTextInputState) override;
+ virtual const WebCore::MachSendRight& compositingRenderServerPort() override;
#endif
- virtual float contentsScaleFactor();
- virtual String proxiesForURL(const String&);
- virtual String cookiesForURL(const String&);
- virtual void setCookiesForURL(const String& urlString, const String& cookieString);
- virtual bool isPrivateBrowsingEnabled();
- virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password);
- virtual void protectPluginFromDestruction();
- virtual void unprotectPluginFromDestruction();
+ virtual float contentsScaleFactor() override;
+ virtual String proxiesForURL(const String&) override;
+ virtual String cookiesForURL(const String&) override;
+ virtual void setCookiesForURL(const String& urlString, const String& cookieString) override;
+ virtual bool isPrivateBrowsingEnabled() override;
+ virtual bool isMuted() const override { return m_isMuted; }
+ virtual bool getAuthenticationInfo(const WebCore::ProtectionSpace&, String& username, String& password) override;
+ virtual void protectPluginFromDestruction() override;
+ virtual void unprotectPluginFromDestruction() override;
#if PLUGIN_ARCHITECTURE(X11)
- virtual uint64_t createPluginContainer();
- virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID);
+ virtual uint64_t createPluginContainer() override;
+ virtual void windowedPluginGeometryDidChange(const WebCore::IntRect& frameRect, const WebCore::IntRect& clipRect, uint64_t windowID) override;
+ virtual void windowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID) override;
#endif
// Message handlers.
void frameDidFinishLoading(uint64_t requestID);
void frameDidFail(uint64_t requestID, bool wasCancelled);
void geometryDidChange(const WebCore::IntSize& pluginSize, const WebCore::IntRect& clipRect, const WebCore::AffineTransform& pluginToRootViewTransform, float contentsScaleFactor, const ShareableBitmap::Handle& backingStoreHandle);
+ void visibilityDidChange(bool isVisible);
void didEvaluateJavaScript(uint64_t requestID, const String& result);
+ void streamWillSendRequest(uint64_t streamID, const String& requestURLString, const String& redirectResponseURLString, uint32_t redirectResponseStatusCode);
void streamDidReceiveResponse(uint64_t streamID, const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
- void streamDidReceiveData(uint64_t streamID, const CoreIPC::DataReference& data);
+ void streamDidReceiveData(uint64_t streamID, const IPC::DataReference& data);
void streamDidFinishLoading(uint64_t streamID);
void streamDidFail(uint64_t streamID, bool wasCancelled);
void manualStreamDidReceiveResponse(const String& responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, const String& mimeType, const String& headers);
- void manualStreamDidReceiveData(const CoreIPC::DataReference& data);
+ void manualStreamDidReceiveData(const IPC::DataReference& data);
void manualStreamDidFinishLoading();
void manualStreamDidFail(bool wasCancelled);
- void handleMouseEvent(const WebMouseEvent&, PassRefPtr<Messages::PluginControllerProxy::HandleMouseEvent::DelayedReply>);
+ void handleMouseEvent(const WebMouseEvent&);
void handleWheelEvent(const WebWheelEvent&, bool& handled);
void handleMouseEnterEvent(const WebMouseEvent&, bool& handled);
void handleMouseLeaveEvent(const WebMouseEvent&, bool& handled);
@@ -141,6 +143,7 @@ private:
void handleEditingCommand(const String&, const String&, bool&);
void isEditingCommandEnabled(const String&, bool&);
void handlesPageScaleFactor(bool&);
+ void requiresUnifiedScaleFactor(bool&);
void paintEntirePlugin();
void supportsSnapshotting(bool&);
void snapshot(ShareableBitmap::Handle& backingStoreHandle);
@@ -148,10 +151,12 @@ private:
void didUpdate();
void getPluginScriptableNPObject(uint64_t& pluginScriptableNPObjectID);
-#if PLATFORM(MAC)
void windowFocusChanged(bool);
- void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
void windowVisibilityChanged(bool);
+ void updateVisibilityActivity();
+
+#if PLATFORM(COCOA)
+ void windowAndViewFramesChanged(const WebCore::IntRect& windowFrameInScreenCoordinates, const WebCore::IntRect& viewFrameInWindowCoordinates);
void sendComplexTextInput(const String& textInput);
void setLayerHostingMode(uint32_t);
@@ -160,6 +165,7 @@ private:
void storageBlockingStateChanged(bool);
void privateBrowsingStateChanged(bool);
+ void mutedStateChanged(bool);
void getFormValue(bool& returnValue, String& formValue);
void platformInitialize(const PluginCreationParameters&);
@@ -172,8 +178,11 @@ private:
String m_userAgent;
bool m_storageBlockingEnabled;
bool m_isPrivateBrowsingEnabled;
+ bool m_isMuted;
bool m_isAcceleratedCompositingEnabled;
bool m_isInitializing;
+ bool m_isVisible;
+ bool m_isWindowVisible;
RefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> m_initializationReply;
@@ -185,14 +194,14 @@ private:
WebCore::IntRect m_dirtyRect;
// The paint timer, used for coalescing painting.
- WebCore::RunLoop::Timer<PluginControllerProxy> m_paintTimer;
+ RunLoop::Timer<PluginControllerProxy> m_paintTimer;
// A counter used to prevent the plug-in from being destroyed.
unsigned m_pluginDestructionProtectCount;
// A timer that we use to prevent destruction of the plug-in while plug-in
// code is on the stack.
- WebCore::RunLoop::Timer<PluginControllerProxy> m_pluginDestroyTimer;
+ RunLoop::Timer<PluginControllerProxy> m_pluginDestroyTimer;
// 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.
@@ -201,12 +210,12 @@ private:
// Whether the plug-in has canceled the manual stream load.
bool m_pluginCanceledManualStreamLoad;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
// Whether complex text input is enabled for this plug-in.
bool m_isComplexTextInputEnabled;
// For CA plug-ins, this holds the information needed to export the layer hierarchy to the UI process.
- OwnPtr<LayerHostingContext> m_layerHostingContext;
+ std::unique_ptr<LayerHostingContext> m_layerHostingContext;
#endif
// The contents scale factor of this plug-in.
@@ -220,10 +229,13 @@ private:
// The plug-in element NPObject.
NPObject* m_pluginElementNPObject;
+
+ // Hold an activity when the plugin is visible to prevent throttling.
+ UserActivity m_visiblityActivity;
};
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif // PluginControllerProxy_h
diff --git a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
index 400899d56..18e8c80b6 100644
--- a/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
+++ b/Source/WebKit2/PluginProcess/PluginControllerProxy.messages.in
@@ -20,12 +20,15 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
messages -> PluginControllerProxy LegacyReceiver {
# Sent when the plug-in geometry changes.
GeometryDidChange(WebCore::IntSize pluginSize, WebCore::IntRect clipRect, WebCore::AffineTransform pluginToRootViewTransform, float scaleFactor, WebKit::ShareableBitmap::Handle backingStoreHandle)
+ # Sent when the plug-in visibility changes.
+ VisibilityDidChange(bool isVisible)
+
# Sent when a frame has finished loading.
FrameDidFinishLoading(uint64_t requestID)
@@ -33,13 +36,16 @@ messages -> PluginControllerProxy LegacyReceiver {
FrameDidFail(uint64_t requestID, bool wasCancelled)
# Sent when JavaScript that the plug-in asked to be evaluated has been evaluated.
- DidEvaluateJavaScript(uint64_t requestID, WTF::String result)
+ DidEvaluateJavaScript(uint64_t requestID, String result)
+
+ # Sent when the plug-in receives will send a request for a stream.
+ StreamWillSendRequest(uint64_t streamID, String requestURLString, String redirectResponseURLString, uint32_t redirectResponseStatusCode)
# Sent when the plug-in receives a response for a stream.
- StreamDidReceiveResponse(uint64_t streamID, WTF::String responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, WTF::String mimeType, WTF::String headers)
+ StreamDidReceiveResponse(uint64_t streamID, String responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, String mimeType, String headers)
# Sent when the plug-in receives data for a stream.
- StreamDidReceiveData(uint64_t streamID, CoreIPC::DataReference data)
+ StreamDidReceiveData(uint64_t streamID, IPC::DataReference data)
# Sent when a plug-in stream has finishes loading.
StreamDidFinishLoading(uint64_t streamID)
@@ -48,10 +54,10 @@ messages -> PluginControllerProxy LegacyReceiver {
StreamDidFail(uint64_t streamID, bool wasCancelled)
# Sent when the plug-in receives a response for the manual stream.
- ManualStreamDidReceiveResponse(WTF::String responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, WTF::String mimeType, WTF::String headers)
+ ManualStreamDidReceiveResponse(String responseURLString, uint32_t streamLength, uint32_t lastModifiedTime, String mimeType, String headers)
# Sent when the plug-in receives data for the manual stream.
- ManualStreamDidReceiveData(CoreIPC::DataReference data)
+ ManualStreamDidReceiveData(IPC::DataReference data)
# Sent when the plug-in manual stream has finishes loading.
ManualStreamDidFinishLoading()
@@ -60,7 +66,7 @@ messages -> PluginControllerProxy LegacyReceiver {
ManualStreamDidFail(bool wasCancelled)
# Sent when a mouse event (that isn't a mouse enter/leave event or a wheel event) should be processed.
- HandleMouseEvent(WebKit::WebMouseEvent mouseEvent) -> (bool handled) Delayed
+ HandleMouseEvent(WebKit::WebMouseEvent mouseEvent)
# Sent when a mouse wheel event should be processed.
HandleWheelEvent(WebKit::WebWheelEvent wheelEvent) -> (bool handled)
@@ -75,14 +81,17 @@ messages -> PluginControllerProxy LegacyReceiver {
HandleKeyboardEvent(WebKit::WebKeyboardEvent keyboardEvent) -> (bool handled)
# Sent when an editing command should be processed.
- HandleEditingCommand(WTF::String commandName, WTF::String argument) -> (bool handled);
+ HandleEditingCommand(String commandName, String argument) -> (bool handled);
# Return whether or not a plugin wants to enable the given editing command.
- IsEditingCommandEnabled(WTF::String commandName) -> (bool enabled);
+ IsEditingCommandEnabled(String commandName) -> (bool enabled);
# Return whether or not a plugin wants to handle page scale factor itself.
HandlesPageScaleFactor() -> (bool enabled);
+ # Return whether or not a plugin wants page scale, page zoom, and text zoom all to affect page scale.
+ RequiresUnifiedScaleFactor() -> (bool required);
+
# Sent when the plug-in focus changes.
SetFocus(bool isFocused)
@@ -95,19 +104,19 @@ messages -> PluginControllerProxy LegacyReceiver {
# Get a reference to the plug-in's scriptable NPObject.
GetPluginScriptableNPObject() -> (uint64_t pluginScriptableNPObjectID)
-#if PLATFORM(MAC)
- # Send the complex text input to the plug-in.
- SendComplexTextInput(WTF::String textInput)
-
# Sent when the containing NSWindow's focus changes
WindowFocusChanged(bool hasFocus)
- # Sent when the containing NSWindow or NSView frame changes
- WindowAndViewFramesChanged(WebCore::IntRect windowFrameInScreenCoordinates, WebCore::IntRect viewFrameInWindowCoordinates)
-
# Sent when the containing NSWindow's visibility changes
WindowVisibilityChanged(bool isVisible)
+#if PLATFORM(COCOA)
+ # Send the complex text input to the plug-in.
+ SendComplexTextInput(String textInput)
+
+ # Sent when the containing NSWindow or NSView frame changes
+ WindowAndViewFramesChanged(WebCore::IntRect windowFrameInScreenCoordinates, WebCore::IntRect viewFrameInWindowCoordinates)
+
# Sent when the containing window's layer hosting mode changes
SetLayerHostingMode(uint32_t layerHostingMode)
#endif
@@ -125,7 +134,10 @@ messages -> PluginControllerProxy LegacyReceiver {
PrivateBrowsingStateChanged(bool isPrivateBrowsingEnabled)
# Gets the string representating the form value of the plug-in
- GetFormValue() -> (bool returnValue, WTF::String formValue)
+ GetFormValue() -> (bool returnValue, String formValue)
+
+ # Sent when the browser wants to mute or unmute the plugin.
+ MutedStateChanged(bool muted)
}
#endif
diff --git a/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp b/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp
index 409106a49..96a6166cc 100644
--- a/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp
+++ b/Source/WebKit2/PluginProcess/PluginCreationParameters.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "PluginCreationParameters.h"
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "ArgumentCoders.h"
@@ -37,15 +37,14 @@ PluginCreationParameters::PluginCreationParameters()
, windowNPObjectID(0)
, contentsScaleFactor(1)
, isPrivateBrowsingEnabled(false)
+ , isMuted(false)
, asynchronousCreationIncomplete(false)
, artificialPluginInitializationDelayEnabled(false)
-#if USE(ACCELERATED_COMPOSITING)
, isAcceleratedCompositingEnabled(false)
-#endif
{
}
-void PluginCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
+void PluginCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
{
encoder << pluginInstanceID;
encoder << windowNPObjectID;
@@ -53,15 +52,13 @@ void PluginCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) const
encoder << userAgent;
encoder << contentsScaleFactor;
encoder << isPrivateBrowsingEnabled;
+ encoder << isMuted;
encoder << asynchronousCreationIncomplete;
encoder << artificialPluginInitializationDelayEnabled;
-
-#if USE(ACCELERATED_COMPOSITING)
encoder << isAcceleratedCompositingEnabled;
-#endif
}
-bool PluginCreationParameters::decode(CoreIPC::ArgumentDecoder& decoder, PluginCreationParameters& result)
+bool PluginCreationParameters::decode(IPC::ArgumentDecoder& decoder, PluginCreationParameters& result)
{
if (!decoder.decode(result.pluginInstanceID) || !result.pluginInstanceID)
return false;
@@ -81,16 +78,17 @@ bool PluginCreationParameters::decode(CoreIPC::ArgumentDecoder& decoder, PluginC
if (!decoder.decode(result.isPrivateBrowsingEnabled))
return false;
+ if (!decoder.decode(result.isMuted))
+ return false;
+
if (!decoder.decode(result.asynchronousCreationIncomplete))
return false;
if (!decoder.decode(result.artificialPluginInitializationDelayEnabled))
return false;
-#if USE(ACCELERATED_COMPOSITING)
if (!decoder.decode(result.isAcceleratedCompositingEnabled))
return false;
-#endif
return true;
}
@@ -98,4 +96,4 @@ bool PluginCreationParameters::decode(CoreIPC::ArgumentDecoder& decoder, PluginC
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/Source/WebKit2/PluginProcess/PluginCreationParameters.h b/Source/WebKit2/PluginProcess/PluginCreationParameters.h
index 33f384b65..8f05a33a0 100644
--- a/Source/WebKit2/PluginProcess/PluginCreationParameters.h
+++ b/Source/WebKit2/PluginProcess/PluginCreationParameters.h
@@ -26,11 +26,11 @@
#ifndef PluginCreationParameters_h
#define PluginCreationParameters_h
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "Plugin.h"
-namespace CoreIPC {
+namespace IPC {
class ArgumentDecoder;
class ArgumentEncoder;
}
@@ -40,8 +40,8 @@ namespace WebKit {
struct PluginCreationParameters {
PluginCreationParameters();
- void encode(CoreIPC::ArgumentEncoder&) const;
- static bool decode(CoreIPC::ArgumentDecoder&, PluginCreationParameters&);
+ void encode(IPC::ArgumentEncoder&) const;
+ static bool decode(IPC::ArgumentDecoder&, PluginCreationParameters&);
// The unique ID of this plug-in instance.
uint64_t pluginInstanceID;
@@ -60,6 +60,9 @@ struct PluginCreationParameters {
// Whether private browsing is enabled at the time of instantiation.
bool isPrivateBrowsingEnabled;
+
+ // Whether the plugin should be muted.
+ bool isMuted;
// If requesting synchronous initialization, whether this plugin had previously been requested asynchronously
bool asynchronousCreationIncomplete;
@@ -67,14 +70,12 @@ struct PluginCreationParameters {
// Simulated initialization delay test asynchronous plugin initialization
bool artificialPluginInitializationDelayEnabled;
-#if USE(ACCELERATED_COMPOSITING)
// Whether accelerated compositing is enabled.
bool isAcceleratedCompositingEnabled;
-#endif
};
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif // PluginCreationParameters_h
diff --git a/Source/WebKit2/PluginProcess/PluginProcess.cpp b/Source/WebKit2/PluginProcess/PluginProcess.cpp
index 31305aa9b..2700ca225 100644
--- a/Source/WebKit2/PluginProcess/PluginProcess.cpp
+++ b/Source/WebKit2/PluginProcess/PluginProcess.cpp
@@ -26,7 +26,7 @@
#include "config.h"
#include "PluginProcess.h"
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "ArgumentCoders.h"
#include "Attachment.h"
@@ -38,69 +38,46 @@
#include "WebProcessConnection.h"
#include <WebCore/MemoryPressureHandler.h>
#include <WebCore/NotImplemented.h>
-#include <WebCore/RunLoop.h>
+#include <wtf/RunLoop.h>
#if PLATFORM(MAC)
#include <crt_externs.h>
#endif
-#if USE(UNIX_DOMAIN_SOCKETS)
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/resource.h>
-#include <sys/socket.h>
-#include <unistd.h>
-#include <wtf/UniStdExtras.h>
-
-#ifdef SOCK_SEQPACKET
-#define SOCKET_TYPE SOCK_SEQPACKET
-#else
-#if PLATFORM(GTK)
-#define SOCKET_TYPE SOCK_STREAM
-#else
-#define SOCKET_TYPE SOCK_DGRAM
-#endif
-#endif // SOCK_SEQPACKET
-#endif // USE(UNIX_DOMAIN_SOCKETS)
-
using namespace WebCore;
namespace WebKit {
-PluginProcess& PluginProcess::shared()
+PluginProcess& PluginProcess::singleton()
{
- DEFINE_STATIC_LOCAL(PluginProcess, pluginProcess, ());
+ static NeverDestroyed<PluginProcess> pluginProcess;
return pluginProcess;
}
PluginProcess::PluginProcess()
: m_supportsAsynchronousPluginInitialization(false)
, m_minimumLifetimeTimer(RunLoop::main(), this, &PluginProcess::minimumLifetimeTimerFired)
-#if PLATFORM(MAC)
- , m_compositingRenderServerPort(MACH_PORT_NULL)
-#endif
+ , m_connectionActivity("PluginProcess connection activity.")
{
NetscapePlugin::setSetExceptionFunction(WebProcessConnection::setGlobalException);
+ m_audioHardwareListener = AudioHardwareListener::create(*this);
}
PluginProcess::~PluginProcess()
{
}
-void PluginProcess::lowMemoryHandler(bool critical)
-{
- UNUSED_PARAM(critical);
- if (shared().shouldTerminate())
- shared().terminate();
-}
-
void PluginProcess::initializeProcess(const ChildProcessInitializationParameters& parameters)
{
m_pluginPath = parameters.extraInitializationData.get("plugin-path");
platformInitializeProcess(parameters);
- memoryPressureHandler().setLowMemoryHandler(lowMemoryHandler);
- memoryPressureHandler().install();
+ auto& memoryPressureHandler = MemoryPressureHandler::singleton();
+ memoryPressureHandler.setLowMemoryHandler([this] (Critical, Synchronous) {
+ if (shouldTerminate())
+ terminate();
+ });
+ memoryPressureHandler.install();
}
void PluginProcess::removeWebProcessConnection(WebProcessConnection* webProcessConnection)
@@ -140,23 +117,23 @@ bool PluginProcess::shouldTerminate()
return m_webProcessConnections.isEmpty();
}
-void PluginProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)
+void PluginProcess::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
didReceivePluginProcessMessage(connection, decoder);
}
-void PluginProcess::didClose(CoreIPC::Connection*)
+void PluginProcess::didClose(IPC::Connection&)
{
- // The UI process has crashed, just go ahead and quit.
+ // The UI process has crashed, just quit.
// FIXME: If the plug-in is spinning in the main loop, we'll never get this message.
- RunLoop::current()->stop();
+ stopRunLoop();
}
-void PluginProcess::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference, CoreIPC::StringReference)
+void PluginProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
{
}
-void PluginProcess::initializePluginProcess(const PluginProcessCreationParameters& parameters)
+void PluginProcess::initializePluginProcess(PluginProcessCreationParameters&& parameters)
{
ASSERT(!m_pluginModule);
@@ -164,56 +141,40 @@ void PluginProcess::initializePluginProcess(const PluginProcessCreationParameter
setMinimumLifetime(parameters.minimumLifetime);
setTerminationTimeout(parameters.terminationTimeout);
- platformInitializePluginProcess(parameters);
+ platformInitializePluginProcess(WTFMove(parameters));
}
void PluginProcess::createWebProcessConnection()
{
bool didHaveAnyWebProcessConnections = !m_webProcessConnections.isEmpty();
-#if PLATFORM(MAC)
+#if USE(UNIX_DOMAIN_SOCKETS)
+ IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
+
+ RefPtr<WebProcessConnection> connection = WebProcessConnection::create(socketPair.server);
+ m_webProcessConnections.append(connection.release());
+
+ IPC::Attachment clientSocket(socketPair.client);
+ parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientSocket, m_supportsAsynchronousPluginInitialization), 0);
+#elif OS(DARWIN)
// Create the listening port.
mach_port_t listeningPort;
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
// Create a listening connection.
- RefPtr<WebProcessConnection> connection = WebProcessConnection::create(CoreIPC::Connection::Identifier(listeningPort));
- m_webProcessConnections.append(connection.release());
+ RefPtr<WebProcessConnection> connection = WebProcessConnection::create(IPC::Connection::Identifier(listeningPort));
- CoreIPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
- parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientPort, m_supportsAsynchronousPluginInitialization), 0);
-#elif USE(UNIX_DOMAIN_SOCKETS)
- int sockets[2];
- if (socketpair(AF_UNIX, SOCKET_TYPE, 0, sockets) == -1) {
- ASSERT_NOT_REACHED();
- return;
+ if (m_audioHardwareListener) {
+ if (m_audioHardwareListener->hardwareActivity() == WebCore::AudioHardwareActivityType::IsActive)
+ connection->audioHardwareDidBecomeActive();
+ else if (m_audioHardwareListener->hardwareActivity() == WebCore::AudioHardwareActivityType::IsInactive)
+ connection->audioHardwareDidBecomeInactive();
}
- // Don't expose the plugin process socket to the web process.
- while (fcntl(sockets[1], F_SETFD, FD_CLOEXEC) == -1) {
- if (errno != EINTR) {
- ASSERT_NOT_REACHED();
- closeWithRetry(sockets[0]);
- closeWithRetry(sockets[1]);
- return;
- }
- }
-
- // Don't expose the web process socket to possible future web processes.
- while (fcntl(sockets[0], F_SETFD, FD_CLOEXEC) == -1) {
- if (errno != EINTR) {
- ASSERT_NOT_REACHED();
- closeWithRetry(sockets[0]);
- closeWithRetry(sockets[1]);
- return;
- }
- }
-
- RefPtr<WebProcessConnection> connection = WebProcessConnection::create(sockets[1]);
m_webProcessConnections.append(connection.release());
- CoreIPC::Attachment clientSocket(sockets[0]);
- parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientSocket, m_supportsAsynchronousPluginInitialization), 0);
+ IPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
+ parentProcessConnection()->send(Messages::PluginProcessProxy::DidCreateWebProcessConnection(clientPort, m_supportsAsynchronousPluginInitialization), 0);
#else
notImplemented();
#endif
@@ -238,19 +199,29 @@ void PluginProcess::getSitesWithData(uint64_t callbackID)
parentProcessConnection()->send(Messages::PluginProcessProxy::DidGetSitesWithData(sites, callbackID), 0);
}
-void PluginProcess::clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
+void PluginProcess::deleteWebsiteData(std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
{
- if (NetscapePluginModule* module = netscapePluginModule()) {
- if (sites.isEmpty()) {
- // Clear everything.
- module->clearSiteData(String(), flags, maxAgeInSeconds);
- } else {
- for (size_t i = 0; i < sites.size(); ++i)
- module->clearSiteData(sites[i], flags, maxAgeInSeconds);
+ if (auto* module = netscapePluginModule()) {
+ auto currentTime = std::chrono::system_clock::now();
+
+ if (currentTime > modifiedSince) {
+ uint64_t maximumAge = std::chrono::duration_cast<std::chrono::seconds>(currentTime - modifiedSince).count();
+
+ module->clearSiteData(String(), NP_CLEAR_ALL, maximumAge);
}
}
- parentProcessConnection()->send(Messages::PluginProcessProxy::DidClearSiteData(callbackID), 0);
+ parentProcessConnection()->send(Messages::PluginProcessProxy::DidDeleteWebsiteData(callbackID), 0);
+}
+
+void PluginProcess::deleteWebsiteDataForHostNames(const Vector<String>& hostNames, uint64_t callbackID)
+{
+ if (auto* module = netscapePluginModule()) {
+ for (auto& hostName : hostNames)
+ module->clearSiteData(hostName, NP_CLEAR_ALL, std::numeric_limits<uint64_t>::max());
+ }
+
+ parentProcessConnection()->send(Messages::PluginProcessProxy::DidDeleteWebsiteDataForHostNames(callbackID), 0);
}
void PluginProcess::setMinimumLifetime(double lifetime)
@@ -268,7 +239,7 @@ void PluginProcess::minimumLifetimeTimerFired()
enableTermination();
}
-#if !PLATFORM(MAC)
+#if !PLATFORM(COCOA)
void PluginProcess::initializeProcessName(const ChildProcessInitializationParameters&)
{
}
@@ -278,7 +249,19 @@ void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters
}
#endif
+void PluginProcess::audioHardwareDidBecomeActive()
+{
+ for (auto& connection : m_webProcessConnections)
+ connection->audioHardwareDidBecomeActive();
+}
+
+void PluginProcess::audioHardwareDidBecomeInactive()
+{
+ for (auto& connection : m_webProcessConnections)
+ connection->audioHardwareDidBecomeInactive();
+}
+
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/Source/WebKit2/PluginProcess/PluginProcess.h b/Source/WebKit2/PluginProcess/PluginProcess.h
index b8163bd1f..1cc4bf71a 100644
--- a/Source/WebKit2/PluginProcess/PluginProcess.h
+++ b/Source/WebKit2/PluginProcess/PluginProcess.h
@@ -26,22 +26,31 @@
#ifndef PluginProcess_h
#define PluginProcess_h
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "ChildProcess.h"
+#include <WebCore/CountedUserActivity.h>
+#include <WebCore/AudioHardwareListener.h>
#include <wtf/Forward.h>
+#include <wtf/NeverDestroyed.h>
#include <wtf/text/WTFString.h>
+#if PLATFORM(COCOA)
+#include <WebCore/MachSendRight.h>
+#endif
+
namespace WebKit {
class NetscapePluginModule;
class WebProcessConnection;
struct PluginProcessCreationParameters;
-class PluginProcess : public ChildProcess {
+class PluginProcess : public ChildProcess, private WebCore::AudioHardwareListener::Client
+{
WTF_MAKE_NONCOPYABLE(PluginProcess);
+ friend class NeverDestroyed<PluginProcess>;
public:
- static PluginProcess& shared();
+ static PluginProcess& singleton();
void removeWebProcessConnection(WebProcessConnection*);
@@ -49,54 +58,67 @@ public:
const String& pluginPath() const { return m_pluginPath; }
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
void setModalWindowIsShowing(bool);
void setFullscreenWindowIsShowing(bool);
-#if USE(ACCELERATED_COMPOSITING)
- mach_port_t compositingRenderServerPort() const { return m_compositingRenderServerPort; }
-#endif
+ const WebCore::MachSendRight& compositingRenderServerPort() const { return m_compositingRenderServerPort; }
bool launchProcess(const String& launchPath, const Vector<String>& arguments);
bool launchApplicationAtURL(const String& urlString, const Vector<String>& arguments);
bool openURL(const String& urlString, int32_t& status, String& launchedURLString);
-
+ bool openFile(const String& urlString);
#endif
+ CountedUserActivity& connectionActivity() { return m_connectionActivity; }
+
private:
PluginProcess();
~PluginProcess();
// ChildProcess
- virtual void initializeProcess(const ChildProcessInitializationParameters&) OVERRIDE;
- virtual void initializeProcessName(const ChildProcessInitializationParameters&) OVERRIDE;
- virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) OVERRIDE;
- virtual bool shouldTerminate() OVERRIDE;
+ virtual void initializeProcess(const ChildProcessInitializationParameters&) override;
+ virtual void initializeProcessName(const ChildProcessInitializationParameters&) override;
+ virtual void initializeSandbox(const ChildProcessInitializationParameters&, SandboxInitializationParameters&) override;
+ virtual bool shouldTerminate() override;
void platformInitializeProcess(const ChildProcessInitializationParameters&);
- // CoreIPC::Connection::Client
- virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
- virtual void didClose(CoreIPC::Connection*) OVERRIDE;
- virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName) OVERRIDE;
+#if USE(APPKIT)
+ virtual void stopRunLoop() override;
+#endif
+
+ // IPC::Connection::Client
+ virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
+ virtual void didClose(IPC::Connection&) override;
+ virtual void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+ virtual IPC::ProcessType localProcessType() override { return IPC::ProcessType::Plugin; }
+ virtual IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::UI; }
// Message handlers.
- void didReceivePluginProcessMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
- void initializePluginProcess(const PluginProcessCreationParameters&);
+ void didReceivePluginProcessMessage(IPC::Connection&, IPC::MessageDecoder&);
+ void initializePluginProcess(PluginProcessCreationParameters&&);
void createWebProcessConnection();
+
void getSitesWithData(uint64_t callbackID);
- void clearSiteData(const Vector<String>& sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID);
+ void deleteWebsiteData(std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID);
+ void deleteWebsiteDataForHostNames(const Vector<String>& hostNames, uint64_t callbackID);
+
+ // AudioHardwareListenerClient
+ virtual void audioHardwareDidBecomeActive() override;
+ virtual void audioHardwareDidBecomeInactive() override;
+ virtual void audioOutputDeviceChanged() override { }
- void platformInitializePluginProcess(const PluginProcessCreationParameters&);
+ void platformInitializePluginProcess(PluginProcessCreationParameters&&);
void setMinimumLifetime(double);
void minimumLifetimeTimerFired();
// Our web process connections.
- Vector<RefPtr<WebProcessConnection> > m_webProcessConnections;
+ Vector<RefPtr<WebProcessConnection>> m_webProcessConnections;
// The plug-in path.
String m_pluginPath;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
String m_pluginBundleIdentifier;
#endif
@@ -105,18 +127,22 @@ private:
bool m_supportsAsynchronousPluginInitialization;
- WebCore::RunLoop::Timer<PluginProcess> m_minimumLifetimeTimer;
+ RunLoop::Timer<PluginProcess> m_minimumLifetimeTimer;
-#if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
+#if PLATFORM(COCOA)
// The Mach port used for accelerated compositing.
- mach_port_t m_compositingRenderServerPort;
+ WebCore::MachSendRight m_compositingRenderServerPort;
+
+ String m_nsurlCacheDirectory;
#endif
- static void lowMemoryHandler(bool critical);
+ CountedUserActivity m_connectionActivity;
+
+ RefPtr<WebCore::AudioHardwareListener> m_audioHardwareListener;
};
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif // PluginProcess_h
diff --git a/Source/WebKit2/PluginProcess/PluginProcess.messages.in b/Source/WebKit2/PluginProcess/PluginProcess.messages.in
index df58ddadd..070e9400c 100644
--- a/Source/WebKit2/PluginProcess/PluginProcess.messages.in
+++ b/Source/WebKit2/PluginProcess/PluginProcess.messages.in
@@ -20,11 +20,11 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
messages -> PluginProcess LegacyReceiver {
# Initializes the plug-in process.
- InitializePluginProcess(WebKit::PluginProcessCreationParameters processCreationParameters)
+ InitializePluginProcess(struct WebKit::PluginProcessCreationParameters processCreationParameters)
# Creates a web process connection. When the connection has been created,
# The plug-in process sends back a DidCreateWebProcessConnection message with
@@ -35,12 +35,12 @@ messages -> PluginProcess LegacyReceiver {
# DidGetSitesWithData message with the sites.
GetSitesWithData(uint64_t callbackID)
- # Asks the plug-in to clear data for the given sites. The plug-in process sends back
- # a DidClearSiteData message when done.
- ClearSiteData(Vector<WTF::String> sites, uint64_t flags, uint64_t maxAgeInSeconds, uint64_t callbackID)
+ DeleteWebsiteData(std::chrono::system_clock::time_point modifiedSince, uint64_t callbackID)
+ DeleteWebsiteDataForHostNames(Vector<String> hostNames, uint64_t callbackID)
-#if PLATFORM(MAC)
- SetProcessSuppressionEnabled(bool flag);
+ SetProcessSuppressionEnabled(bool flag)
+#if PLATFORM(COCOA)
+ SetQOS(int latencyQOS, int throughputQOS)
#endif
}
diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp
index 94cdcf5e0..bb858d0a0 100644
--- a/Source/WebKit2/PluginProcess/WebProcessConnection.cpp
+++ b/Source/WebKit2/PluginProcess/WebProcessConnection.cpp
@@ -26,11 +26,10 @@
#include "config.h"
#include "WebProcessConnection.h"
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "ActivityAssertion.h"
#include "ArgumentCoders.h"
-#include "ConnectionStack.h"
#include "NPObjectMessageReceiverMessages.h"
#include "NPRemoteObjectMap.h"
#include "PluginControllerProxy.h"
@@ -39,16 +38,19 @@
#include "PluginProcessConnectionMessages.h"
#include "PluginProxyMessages.h"
#include "WebProcessConnectionMessages.h"
-#include <WebCore/RunLoop.h>
#include <unistd.h>
+#include <wtf/RunLoop.h>
+#include <wtf/TemporaryChange.h>
using namespace WebCore;
namespace WebKit {
-PassRefPtr<WebProcessConnection> WebProcessConnection::create(CoreIPC::Connection::Identifier connectionIdentifier)
+static IPC::Connection* currentConnection;
+
+RefPtr<WebProcessConnection> WebProcessConnection::create(IPC::Connection::Identifier connectionIdentifier)
{
- return adoptRef(new WebProcessConnection(connectionIdentifier));
+ return adoptRef(*new WebProcessConnection(connectionIdentifier));
}
WebProcessConnection::~WebProcessConnection()
@@ -58,21 +60,21 @@ WebProcessConnection::~WebProcessConnection()
ASSERT(!m_connection);
}
-WebProcessConnection::WebProcessConnection(CoreIPC::Connection::Identifier connectionIdentifier)
+WebProcessConnection::WebProcessConnection(IPC::Connection::Identifier connectionIdentifier)
{
- m_connection = CoreIPC::Connection::createServerConnection(connectionIdentifier, this, RunLoop::main());
+ m_connection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
m_npRemoteObjectMap = NPRemoteObjectMap::create(m_connection.get());
m_connection->setOnlySendMessagesAsDispatchWhenWaitingForSyncReplyWhenProcessingSuchAMessage(true);
m_connection->open();
}
-void WebProcessConnection::addPluginControllerProxy(PassOwnPtr<PluginControllerProxy> pluginController)
+void WebProcessConnection::addPluginControllerProxy(std::unique_ptr<PluginControllerProxy> pluginController)
{
uint64_t pluginInstanceID = pluginController->pluginInstanceID();
ASSERT(!m_pluginControllers.contains(pluginInstanceID));
- m_pluginControllers.set(pluginInstanceID, pluginController);
+ m_pluginControllers.set(pluginInstanceID, WTFMove(pluginController));
}
void WebProcessConnection::destroyPluginControllerProxy(PluginControllerProxy* pluginController)
@@ -84,11 +86,12 @@ void WebProcessConnection::destroyPluginControllerProxy(PluginControllerProxy* p
void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pluginController, Plugin* plugin)
{
+ unsigned pluginInstanceID = pluginController->pluginInstanceID();
{
- ASSERT(m_pluginControllers.contains(pluginController->pluginInstanceID()));
+ ASSERT(m_pluginControllers.contains(pluginInstanceID));
- OwnPtr<PluginControllerProxy> pluginControllerOwnPtr = m_pluginControllers.take(pluginController->pluginInstanceID());
- ASSERT(pluginControllerOwnPtr == pluginController);
+ std::unique_ptr<PluginControllerProxy> pluginControllerUniquePtr = m_pluginControllers.take(pluginInstanceID);
+ ASSERT(pluginControllerUniquePtr.get() == pluginController);
}
// Invalidate all objects related to this plug-in.
@@ -105,21 +108,20 @@ void WebProcessConnection::removePluginControllerProxy(PluginControllerProxy* pl
m_connection = nullptr;
// This will cause us to be deleted.
- PluginProcess::shared().removeWebProcessConnection(this);
+ PluginProcess::singleton().removeWebProcessConnection(this);
}
void WebProcessConnection::setGlobalException(const String& exceptionString)
{
- CoreIPC::Connection* connection = ConnectionStack::shared().current();
- if (!connection)
+ if (!currentConnection)
return;
- connection->sendSync(Messages::PluginProcessConnection::SetException(exceptionString), Messages::PluginProcessConnection::SetException::Reply(), 0);
+ currentConnection->sendSync(Messages::PluginProcessConnection::SetException(exceptionString), Messages::PluginProcessConnection::SetException::Reply(), 0);
}
-void WebProcessConnection::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder)
+void WebProcessConnection::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
{
- ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection);
+ TemporaryChange<IPC::Connection*> currentConnectionChange(currentConnection, &connection);
if (decoder.messageReceiverName() == Messages::WebProcessConnection::messageReceiverName()) {
didReceiveWebProcessConnectionMessage(connection, decoder);
@@ -139,12 +141,9 @@ void WebProcessConnection::didReceiveMessage(CoreIPC::Connection* connection, Co
pluginControllerProxy->didReceivePluginControllerProxyMessage(connection, decoder);
}
-void WebProcessConnection::didReceiveSyncMessage(CoreIPC::Connection* connection, CoreIPC::MessageDecoder& decoder, OwnPtr<CoreIPC::MessageEncoder>& replyEncoder)
+void WebProcessConnection::didReceiveSyncMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
{
- // Force all timers to run at full speed when processing a synchronous message
- ActivityAssertion activityAssertion(PluginProcess::shared());
-
- ConnectionStack::CurrentConnectionPusher currentConnection(ConnectionStack::shared(), connection);
+ TemporaryChange<IPC::Connection*> currentConnectionChange(currentConnection, &connection);
uint64_t destinationID = decoder.destinationID();
@@ -166,25 +165,26 @@ void WebProcessConnection::didReceiveSyncMessage(CoreIPC::Connection* connection
pluginControllerProxy->didReceiveSyncPluginControllerProxyMessage(connection, decoder, replyEncoder);
}
-void WebProcessConnection::didClose(CoreIPC::Connection*)
+void WebProcessConnection::didClose(IPC::Connection&)
{
// The web process crashed. Destroy all the plug-in controllers. Destroying the last plug-in controller
// will cause the web process connection itself to be destroyed.
Vector<PluginControllerProxy*> pluginControllers;
- HashMap<uint64_t, OwnPtr<PluginControllerProxy> >::iterator::Values it = m_pluginControllers.values().begin();
- HashMap<uint64_t, OwnPtr<PluginControllerProxy> >::iterator::Values end = m_pluginControllers.values().end();
-
- for (; it != end; ++it)
+ for (auto it = m_pluginControllers.values().begin(), end = m_pluginControllers.values().end(); it != end; ++it)
pluginControllers.append(it->get());
for (size_t i = 0; i < pluginControllers.size(); ++i)
destroyPluginControllerProxy(pluginControllers[i]);
}
-void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete)
+void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete, PassRefPtr<Messages::WebProcessConnection::DestroyPlugin::DelayedReply> reply)
{
+ // We return immediately from this synchronous IPC. We want to make sure the plugin destruction is just about to start so audio playback
+ // will finish soon after returning. However we don't want to wait for destruction to complete fully as that may take a while.
+ reply->send();
+
// Ensure we don't clamp any timers during destruction
- ActivityAssertion activityAssertion(PluginProcess::shared());
+ ActivityAssertion activityAssertion(PluginProcess::singleton().connectionActivity());
PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(pluginInstanceID);
@@ -201,20 +201,20 @@ void WebProcessConnection::destroyPlugin(uint64_t pluginInstanceID, bool asynchr
destroyPluginControllerProxy(pluginControllerProxy);
}
-void WebProcessConnection::didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference, CoreIPC::StringReference)
+void WebProcessConnection::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
{
// FIXME: Implement.
}
void WebProcessConnection::createPluginInternal(const PluginCreationParameters& creationParameters, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID)
{
- OwnPtr<PluginControllerProxy> pluginControllerProxy = PluginControllerProxy::create(this, creationParameters);
+ auto pluginControllerProxy = std::make_unique<PluginControllerProxy>(this, creationParameters);
PluginControllerProxy* pluginControllerProxyPtr = pluginControllerProxy.get();
// Make sure to add the proxy to the map before initializing it, since the plug-in might call out to the web process from
// its NPP_New function. This will hand over ownership of the proxy to the web process connection.
- addPluginControllerProxy(pluginControllerProxy.release());
+ addPluginControllerProxy(WTFMove(pluginControllerProxy));
// Now try to initialize the plug-in.
result = pluginControllerProxyPtr->initialize(creationParameters);
@@ -223,7 +223,7 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters&
return;
wantsWheelEvents = pluginControllerProxyPtr->wantsWheelEvents();
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
remoteLayerClientID = pluginControllerProxyPtr->remoteLayerClientID();
#else
UNUSED_PARAM(remoteLayerClientID);
@@ -233,7 +233,7 @@ void WebProcessConnection::createPluginInternal(const PluginCreationParameters&
void WebProcessConnection::createPlugin(const PluginCreationParameters& creationParameters, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply> reply)
{
// Ensure we don't clamp any timers during initialization
- ActivityAssertion activityAssertion(PluginProcess::shared());
+ ActivityAssertion activityAssertion(PluginProcess::singleton().connectionActivity());
PluginControllerProxy* pluginControllerProxy = m_pluginControllers.get(creationParameters.pluginInstanceID);
@@ -246,7 +246,7 @@ void WebProcessConnection::createPlugin(const PluginCreationParameters& creation
}
// If its initialization is complete then we need to respond to this message with the correct information about its creation.
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
reply->send(true, pluginControllerProxy->wantsWheelEvents(), pluginControllerProxy->remoteLayerClientID());
#else
reply->send(true, pluginControllerProxy->wantsWheelEvents(), 0);
@@ -295,7 +295,7 @@ void WebProcessConnection::createPluginAsynchronously(const PluginCreationParame
// The call to createPluginInternal can potentially cause the plug-in to be destroyed and
// thus free the WebProcessConnection object. Protect it.
- RefPtr<WebProcessConnection> protect(this);
+ Ref<WebProcessConnection> protect(*this);
createPluginInternal(creationParameters, result, wantsWheelEvents, remoteLayerClientID);
if (!m_connection) {
@@ -322,7 +322,17 @@ void WebProcessConnection::createPluginAsynchronously(const PluginCreationParame
m_connection->sendSync(Messages::PluginProxy::DidCreatePlugin(wantsWheelEvents, remoteLayerClientID), Messages::PluginProxy::DidCreatePlugin::Reply(), creationParameters.pluginInstanceID);
}
+
+void WebProcessConnection::audioHardwareDidBecomeActive()
+{
+ m_connection->send(Messages::PluginProcessConnection::AudioHardwareDidBecomeActive(), 0);
+}
+void WebProcessConnection::audioHardwareDidBecomeInactive()
+{
+ m_connection->send(Messages::PluginProcessConnection::AudioHardwareDidBecomeInactive(), 0);
+}
+
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.h b/Source/WebKit2/PluginProcess/WebProcessConnection.h
index c00b04668..bb3317c93 100644
--- a/Source/WebKit2/PluginProcess/WebProcessConnection.h
+++ b/Source/WebKit2/PluginProcess/WebProcessConnection.h
@@ -26,7 +26,7 @@
#ifndef WebProcessConnection_h
#define WebProcessConnection_h
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
#include "Connection.h"
#include "Plugin.h"
@@ -42,50 +42,55 @@ struct PluginCreationParameters;
// A connection from a plug-in process to a web process.
-class WebProcessConnection : public RefCounted<WebProcessConnection>, CoreIPC::Connection::Client {
+class WebProcessConnection : public RefCounted<WebProcessConnection>, IPC::Connection::Client {
public:
- static PassRefPtr<WebProcessConnection> create(CoreIPC::Connection::Identifier);
+ static RefPtr<WebProcessConnection> create(IPC::Connection::Identifier);
virtual ~WebProcessConnection();
- CoreIPC::Connection* connection() const { return m_connection.get(); }
+ IPC::Connection* connection() const { return m_connection.get(); }
NPRemoteObjectMap* npRemoteObjectMap() const { return m_npRemoteObjectMap.get(); }
void removePluginControllerProxy(PluginControllerProxy*, Plugin*);
static void setGlobalException(const String&);
+
+ void audioHardwareDidBecomeActive();
+ void audioHardwareDidBecomeInactive();
private:
- WebProcessConnection(CoreIPC::Connection::Identifier);
+ WebProcessConnection(IPC::Connection::Identifier);
- void addPluginControllerProxy(PassOwnPtr<PluginControllerProxy>);
+ void addPluginControllerProxy(std::unique_ptr<PluginControllerProxy>);
void destroyPluginControllerProxy(PluginControllerProxy*);
- // CoreIPC::Connection::Client
- virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&) OVERRIDE;
- virtual void didReceiveSyncMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&) OVERRIDE;
- virtual void didClose(CoreIPC::Connection*);
- virtual void didReceiveInvalidMessage(CoreIPC::Connection*, CoreIPC::StringReference messageReceiverName, CoreIPC::StringReference messageName);
+ // IPC::Connection::Client
+ virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
+ virtual void didReceiveSyncMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
+ virtual void didClose(IPC::Connection&) override;
+ virtual void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+ virtual IPC::ProcessType localProcessType() override { return IPC::ProcessType::Plugin; }
+ virtual IPC::ProcessType remoteProcessType() override { return IPC::ProcessType::Web; }
// Message handlers.
- void didReceiveWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&);
- void didReceiveSyncWebProcessConnectionMessage(CoreIPC::Connection*, CoreIPC::MessageDecoder&, OwnPtr<CoreIPC::MessageEncoder>&);
+ void didReceiveWebProcessConnectionMessage(IPC::Connection&, IPC::MessageDecoder&);
+ void didReceiveSyncWebProcessConnectionMessage(IPC::Connection&, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&);
void createPlugin(const PluginCreationParameters&, PassRefPtr<Messages::WebProcessConnection::CreatePlugin::DelayedReply>);
void createPluginAsynchronously(const PluginCreationParameters&);
- void destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete);
+ void destroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete, PassRefPtr<Messages::WebProcessConnection::DestroyPlugin::DelayedReply>);
void createPluginInternal(const PluginCreationParameters&, bool& result, bool& wantsWheelEvents, uint32_t& remoteLayerClientID);
- RefPtr<CoreIPC::Connection> m_connection;
+ RefPtr<IPC::Connection> m_connection;
- HashMap<uint64_t, OwnPtr<PluginControllerProxy> > m_pluginControllers;
+ HashMap<uint64_t, std::unique_ptr<PluginControllerProxy>> m_pluginControllers;
RefPtr<NPRemoteObjectMap> m_npRemoteObjectMap;
HashSet<uint64_t> m_asynchronousInstanceIDsToIgnore;
};
} // namespace WebKit
-#endif // ENABLE(PLUGIN_PROCESS)
+#endif // ENABLE(NETSCAPE_PLUGIN_API)
#endif // WebProcessConnection_h
diff --git a/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in b/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in
index b4801cf76..ece24e844 100644
--- a/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in
+++ b/Source/WebKit2/PluginProcess/WebProcessConnection.messages.in
@@ -20,17 +20,17 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if ENABLE(PLUGIN_PROCESS)
+#if ENABLE(NETSCAPE_PLUGIN_API)
messages -> WebProcessConnection LegacyReceiver {
# Creates a plug-in instance using the given creation parameters.
- CreatePlugin(WebKit::PluginCreationParameters pluginCreationParameters) -> (bool creationResult, bool wantsWheelEvents, uint32_t remoteLayerClientID) Delayed
+ CreatePlugin(struct WebKit::PluginCreationParameters pluginCreationParameters) -> (bool creationResult, bool wantsWheelEvents, uint32_t remoteLayerClientID) Delayed
# Creates a plug-in instance asynchronously using the given creation parameters.
- CreatePluginAsynchronously(WebKit::PluginCreationParameters pluginCreationParameters)
+ CreatePluginAsynchronously(struct WebKit::PluginCreationParameters pluginCreationParameters)
# Destroys the plug-in instance with the given instance ID.
- DestroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete) -> ()
+ DestroyPlugin(uint64_t pluginInstanceID, bool asynchronousCreationIncomplete) -> () Delayed
}
#endif
diff --git a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm b/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm
deleted file mode 100644
index 19c2cf25b..000000000
--- a/Source/WebKit2/PluginProcess/mac/PluginControllerProxyMac.mm
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PluginControllerProxy.h"
-
-#if ENABLE(PLUGIN_PROCESS)
-
-#import "LayerHostingContext.h"
-#import "PluginCreationParameters.h"
-#import "PluginProcess.h"
-#import "PluginProcessProxyMessages.h"
-#import "PluginProxyMessages.h"
-#import "WebProcessConnection.h"
-#import <QuartzCore/QuartzCore.h>
-
-using namespace WebCore;
-
-namespace WebKit {
-
-void PluginControllerProxy::pluginFocusOrWindowFocusChanged(bool pluginHasFocusAndWindowHasFocus)
-{
- m_connection->connection()->send(Messages::PluginProxy::PluginFocusOrWindowFocusChanged(pluginHasFocusAndWindowHasFocus), m_pluginInstanceID);
-}
-
-void PluginControllerProxy::setComplexTextInputState(PluginComplexTextInputState pluginComplexTextInputState)
-{
- m_connection->connection()->send(Messages::PluginProxy::SetComplexTextInputState(pluginComplexTextInputState), m_pluginInstanceID, CoreIPC::DispatchMessageEvenWhenWaitingForSyncReply);
-}
-
-mach_port_t PluginControllerProxy::compositingRenderServerPort()
-{
- return PluginProcess::shared().compositingRenderServerPort();
-}
-
-void PluginControllerProxy::openPluginPreferencePane()
-{
- PluginProcess::shared().parentProcessConnection()->send(Messages::PluginProcessProxy::OpenPluginPreferencePane(), 0);
-}
-
-void PluginControllerProxy::platformInitialize(const PluginCreationParameters& creationParameters)
-{
- ASSERT(!m_layerHostingContext);
- updateLayerHostingContext(creationParameters.parameters.layerHostingMode);
-}
-
-void PluginControllerProxy::platformDestroy()
-{
- if (!m_layerHostingContext)
- return;
-
- m_layerHostingContext->invalidate();
- m_layerHostingContext = nullptr;
-}
-
-uint32_t PluginControllerProxy::remoteLayerClientID() const
-{
- if (!m_layerHostingContext)
- return 0;
-
- return m_layerHostingContext->contextID();
-}
-
-void PluginControllerProxy::platformGeometryDidChange()
-{
- CALayer *pluginLayer = m_plugin->pluginLayer();
-
- // We don't want to animate to the new size so we disable actions for this transaction.
- [CATransaction begin];
- [CATransaction setValue:[NSNumber numberWithBool:YES] forKey:kCATransactionDisableActions];
- [pluginLayer setFrame:CGRectMake(0, 0, m_pluginSize.width(), m_pluginSize.height())];
- [CATransaction commit];
-}
-
-void PluginControllerProxy::windowFocusChanged(bool hasFocus)
-{
- m_plugin->windowFocusChanged(hasFocus);
-}
-
-void PluginControllerProxy::windowAndViewFramesChanged(const IntRect& windowFrameInScreenCoordinates, const IntRect& viewFrameInWindowCoordinates)
-{
- m_plugin->windowAndViewFramesChanged(windowFrameInScreenCoordinates, viewFrameInWindowCoordinates);
-}
-
-void PluginControllerProxy::windowVisibilityChanged(bool isVisible)
-{
- m_plugin->windowVisibilityChanged(isVisible);
-}
-
-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/PluginProcessMac.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
deleted file mode 100644
index 5bc29299d..000000000
--- a/Source/WebKit2/PluginProcess/mac/PluginProcessMac.mm
+++ /dev/null
@@ -1,471 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "PluginProcess.h"
-
-#if ENABLE(PLUGIN_PROCESS)
-
-#import "ArgumentCoders.h"
-#import "NetscapePlugin.h"
-#import "PluginProcessCreationParameters.h"
-#import "PluginProcessProxyMessages.h"
-#import "PluginProcessShim.h"
-#import "PluginSandboxProfile.h"
-#import "SandboxInitializationParameters.h"
-#import <CoreAudio/AudioHardware.h>
-#import <WebCore/LocalizedStrings.h>
-#import <WebKitSystemInterface.h>
-#import <dlfcn.h>
-#import <objc/runtime.h>
-#import <sysexits.h>
-#import <wtf/HashSet.h>
-
-using namespace WebCore;
-
-const CFStringRef kLSPlugInBundleIdentifierKey = CFSTR("LSPlugInBundleIdentifierKey");
-
-namespace WebKit {
-
-class FullscreenWindowTracker {
- WTF_MAKE_NONCOPYABLE(FullscreenWindowTracker);
-
-public:
- FullscreenWindowTracker() { }
-
- template<typename T> void windowShown(T window);
- template<typename T> void windowHidden(T window);
-
-private:
- typedef HashSet<void*> WindowSet;
- WindowSet m_windows;
-};
-
-static bool rectCoversAnyScreen(NSRect rect)
-{
- for (NSScreen *screen in [NSScreen screens]) {
- if (NSContainsRect(rect, [screen frame]))
- return YES;
- }
- return NO;
-}
-
-#ifndef NP_NO_CARBON
-static bool windowCoversAnyScreen(WindowRef window)
-{
- HIRect bounds;
- HIWindowGetBounds(window, kWindowStructureRgn, kHICoordSpaceScreenPixel, &bounds);
-
- // Convert to Cocoa-style screen coordinates that use a Y offset relative to the zeroth screen's origin.
- bounds.origin.y = NSHeight([(NSScreen *)[[NSScreen screens] objectAtIndex:0] frame]) - CGRectGetMaxY(bounds);
-
- return rectCoversAnyScreen(NSRectFromCGRect(bounds));
-}
-#endif
-
-static bool windowCoversAnyScreen(NSWindow* window)
-{
- return rectCoversAnyScreen([window frame]);
-}
-
-template<typename T> void FullscreenWindowTracker::windowShown(T window)
-{
- // If this window is already visible then there is nothing to do.
- WindowSet::iterator it = m_windows.find(window);
- if (it != m_windows.end())
- return;
-
- // If the window is not full-screen then we're not interested in it.
- if (!windowCoversAnyScreen(window))
- return;
-
- bool windowSetWasEmpty = m_windows.isEmpty();
-
- m_windows.add(window);
-
- // If this is the first full screen window to be shown, notify the UI process.
- if (windowSetWasEmpty)
- PluginProcess::shared().setFullscreenWindowIsShowing(true);
-}
-
-template<typename T> void FullscreenWindowTracker::windowHidden(T window)
-{
- // If this is not a window that we're tracking then there is nothing to do.
- WindowSet::iterator it = m_windows.find(window);
- if (it == m_windows.end())
- return;
-
- m_windows.remove(it);
-
- // If this was the last full screen window that was visible, notify the UI process.
- if (m_windows.isEmpty())
- PluginProcess::shared().setFullscreenWindowIsShowing(false);
-}
-
-static FullscreenWindowTracker& fullscreenWindowTracker()
-{
- DEFINE_STATIC_LOCAL(FullscreenWindowTracker, fullscreenWindowTracker, ());
- return fullscreenWindowTracker;
-}
-
-#if defined(__i386__)
-
-static pthread_once_t shouldCallRealDebuggerOnce = PTHREAD_ONCE_INIT;
-static bool isUserbreakSet = false;
-
-static void initShouldCallRealDebugger()
-{
- char* var = getenv("USERBREAK");
-
- if (var)
- isUserbreakSet = atoi(var);
-}
-
-static bool shouldCallRealDebugger()
-{
- pthread_once(&shouldCallRealDebuggerOnce, initShouldCallRealDebugger);
-
- return isUserbreakSet;
-}
-
-static bool isWindowActive(WindowRef windowRef, bool& result)
-{
-#ifndef NP_NO_CARBON
- if (NetscapePlugin* plugin = NetscapePlugin::netscapePluginFromWindow(windowRef)) {
- result = plugin->isWindowActive();
- return true;
- }
-#endif
- return false;
-}
-
-static UInt32 getCurrentEventButtonState()
-{
-#ifndef NP_NO_CARBON
- return NetscapePlugin::buttonState();
-#else
- ASSERT_NOT_REACHED();
- return 0;
-#endif
-}
-
-static void carbonWindowShown(WindowRef window)
-{
-#ifndef NP_NO_CARBON
- fullscreenWindowTracker().windowShown(window);
-#endif
-}
-
-static void carbonWindowHidden(WindowRef window)
-{
-#ifndef NP_NO_CARBON
- fullscreenWindowTracker().windowHidden(window);
-#endif
-}
-
-static bool openCFURLRef(CFURLRef url, int32_t& status, CFURLRef* launchedURL)
-{
- String launchedURLString;
- if (!PluginProcess::shared().openURL(KURL(url).string(), status, launchedURLString))
- return false;
-
- if (!launchedURLString.isNull() && launchedURL)
- *launchedURL = KURL(ParsedURLString, launchedURLString).createCFURL().leakRef();
- return true;
-}
-
-#endif
-
-static void setModal(bool modalWindowIsShowing)
-{
- PluginProcess::shared().setModalWindowIsShowing(modalWindowIsShowing);
-}
-
-static unsigned modalCount = 0;
-
-static void beginModal()
-{
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#endif
- // Make sure to make ourselves the front process
- ProcessSerialNumber psn;
- GetCurrentProcess(&psn);
- SetFrontProcess(&psn);
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-
- if (!modalCount++)
- setModal(true);
-}
-
-static void endModal()
-{
- if (!--modalCount)
- setModal(false);
-}
-
-static IMP NSApplication_RunModalForWindow;
-
-static NSInteger replacedRunModalForWindow(id self, SEL _cmd, NSWindow* window)
-{
- beginModal();
- NSInteger result = ((NSInteger (*)(id, SEL, NSWindow *))NSApplication_RunModalForWindow)(self, _cmd, window);
- endModal();
-
- return result;
-}
-
-#if defined(__i386__)
-static void initializeShim()
-{
- // Initialize the shim for 32-bit only.
- const PluginProcessShimCallbacks callbacks = {
- shouldCallRealDebugger,
- isWindowActive,
- getCurrentEventButtonState,
- beginModal,
- endModal,
- carbonWindowShown,
- carbonWindowHidden,
- setModal,
- openCFURLRef,
- };
-
- PluginProcessShimInitializeFunc initFunc = reinterpret_cast<PluginProcessShimInitializeFunc>(dlsym(RTLD_DEFAULT, "WebKitPluginProcessShimInitialize"));
- initFunc(callbacks);
-}
-#endif
-
-static IMP NSConcreteTask_launch;
-
-static void replacedNSConcreteTask_launch(NSTask *self, SEL _cmd)
-{
- String launchPath = self.launchPath;
-
- Vector<String> arguments;
- arguments.reserveInitialCapacity(self.arguments.count);
- for (NSString *argument in self.arguments)
- arguments.uncheckedAppend(argument);
-
- if (PluginProcess::shared().launchProcess(launchPath, arguments))
- return;
-
- NSConcreteTask_launch(self, _cmd);
-}
-
-static NSRunningApplication *(*NSWorkspace_launchApplicationAtURL_options_configuration_error)(NSWorkspace *, SEL, NSURL *, NSWorkspaceLaunchOptions, NSDictionary *, NSError **);
-
-static NSRunningApplication *replacedNSWorkspace_launchApplicationAtURL_options_configuration_error(NSWorkspace *self, SEL _cmd, NSURL *url, NSWorkspaceLaunchOptions options, NSDictionary *configuration, NSError **error)
-{
- Vector<String> arguments;
- if (NSArray *argumentsArray = [configuration objectForKey:NSWorkspaceLaunchConfigurationArguments]) {
- if ([argumentsArray isKindOfClass:[NSArray array]]) {
- for (NSString *argument in argumentsArray) {
- if ([argument isKindOfClass:[NSString class]])
- arguments.append(argument);
- }
- }
- }
-
- if (PluginProcess::shared().launchApplicationAtURL(KURL(url).string(), arguments)) {
- if (error)
- *error = nil;
- return nil;
- }
-
- return NSWorkspace_launchApplicationAtURL_options_configuration_error(self, _cmd, url, options, configuration, error);
-}
-
-static void initializeCocoaOverrides()
-{
- // Override -[NSConcreteTask launch:]
- Method launchMethod = class_getInstanceMethod(objc_getClass("NSConcreteTask"), @selector(launch));
- NSConcreteTask_launch = method_setImplementation(launchMethod, reinterpret_cast<IMP>(replacedNSConcreteTask_launch));
-
- // Override -[NSWorkspace launchApplicationAtURL:options:configuration:error:]
- Method launchApplicationAtURLOptionsConfigurationErrorMethod = class_getInstanceMethod(objc_getClass("NSWorkspace"), @selector(launchApplicationAtURL:options:configuration:error:));
- NSWorkspace_launchApplicationAtURL_options_configuration_error = reinterpret_cast<NSRunningApplication *(*)(NSWorkspace *, SEL, NSURL *, NSWorkspaceLaunchOptions, NSDictionary *, NSError **)>(method_setImplementation(launchApplicationAtURLOptionsConfigurationErrorMethod, reinterpret_cast<IMP>(replacedNSWorkspace_launchApplicationAtURL_options_configuration_error)));
-
- // Override -[NSApplication runModalForWindow:]
- Method runModalForWindowMethod = class_getInstanceMethod(objc_getClass("NSApplication"), @selector(runModalForWindow:));
- NSApplication_RunModalForWindow = method_setImplementation(runModalForWindowMethod, reinterpret_cast<IMP>(replacedRunModalForWindow));
-
- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
-
- // Track when any Cocoa window is about to be be shown.
- id orderOnScreenObserver = [defaultCenter addObserverForName:WKWindowWillOrderOnScreenNotification()
- object:nil
- queue:nil
- usingBlock:^(NSNotification *notification) { fullscreenWindowTracker().windowShown([notification object]); }];
- // Track when any Cocoa window is about to be hidden.
- id orderOffScreenObserver = [defaultCenter addObserverForName:WKWindowWillOrderOffScreenNotification()
- object:nil
- queue:nil
- usingBlock:^(NSNotification *notification) { fullscreenWindowTracker().windowHidden([notification object]); }];
-
- // Leak the two observers so that they observe notifications for the lifetime of the process.
- CFRetain(orderOnScreenObserver);
- CFRetain(orderOffScreenObserver);
-}
-
-void PluginProcess::setModalWindowIsShowing(bool modalWindowIsShowing)
-{
- parentProcessConnection()->send(Messages::PluginProcessProxy::SetModalWindowIsShowing(modalWindowIsShowing), 0);
-}
-
-void PluginProcess::setFullscreenWindowIsShowing(bool fullscreenWindowIsShowing)
-{
- parentProcessConnection()->send(Messages::PluginProcessProxy::SetFullscreenWindowIsShowing(fullscreenWindowIsShowing), 0);
-}
-
-bool PluginProcess::launchProcess(const String& launchPath, const Vector<String>& arguments)
-{
- bool result;
- if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::LaunchProcess(launchPath, arguments), Messages::PluginProcessProxy::LaunchProcess::Reply(result), 0))
- return false;
-
- return result;
-}
-
-bool PluginProcess::launchApplicationAtURL(const String& urlString, const Vector<String>& arguments)
-{
- bool result = false;
- if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::LaunchApplicationAtURL(urlString, arguments), Messages::PluginProcessProxy::LaunchProcess::Reply(result), 0))
- return false;
-
- return result;
-}
-
-bool PluginProcess::openURL(const String& urlString, int32_t& status, String& launchedURLString)
-{
- bool result;
- if (!parentProcessConnection()->sendSync(Messages::PluginProcessProxy::OpenURL(urlString), Messages::PluginProcessProxy::OpenURL::Reply(result, status, launchedURLString), 0))
- return false;
-
- return result;
-}
-
-static void muteAudio(void)
-{
- AudioObjectPropertyAddress propertyAddress = { kAudioHardwarePropertyProcessIsAudible, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster };
- UInt32 propertyData = 0;
- OSStatus result = AudioObjectSetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, 0, sizeof(UInt32), &propertyData);
- ASSERT_UNUSED(result, result == noErr);
-}
-
-void PluginProcess::platformInitializePluginProcess(const PluginProcessCreationParameters& parameters)
-{
- m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
- if (parameters.processType == PluginProcessTypeSnapshot)
- muteAudio();
-}
-
-void PluginProcess::platformInitializeProcess(const ChildProcessInitializationParameters& parameters)
-{
-#if defined(__i386__)
- // Initialize the shim.
- initializeShim();
-#endif
-
- // Initialize Cocoa overrides.
- initializeCocoaOverrides();
-
- // FIXME: It would be better to proxy SetCursor calls over to the UI process instead of
- // allowing plug-ins to change the mouse cursor at any time.
- WKEnableSettingCursorWhenInBackground();
-
-#if defined(__i386__)
- NSDictionary *defaults = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"AppleMagnifiedMode", nil];
- [[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
- [defaults release];
-#endif
-
- RetainPtr<CFURLRef> pluginURL = adoptCF(CFURLCreateWithFileSystemPath(0, m_pluginPath.createCFString().get(), kCFURLPOSIXPathStyle, false));
- if (!pluginURL)
- return;
-
- RetainPtr<CFBundleRef> pluginBundle = adoptCF(CFBundleCreate(kCFAllocatorDefault, pluginURL.get()));
- if (!pluginBundle)
- return;
-
- m_pluginBundleIdentifier = CFBundleGetIdentifier(pluginBundle.get());
-}
-
-void PluginProcess::initializeProcessName(const ChildProcessInitializationParameters& parameters)
-{
- NSString *applicationName = [NSString stringWithFormat:WEB_UI_STRING("%@ (%@ Internet plug-in)", "visible name of the plug-in host process. The first argument is the plug-in name and the second argument is the application name."), [[(NSString *)m_pluginPath lastPathComponent] stringByDeletingPathExtension], (NSString *)parameters.uiProcessName];
- WKSetVisibleApplicationName((CFStringRef)applicationName);
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
- if (!m_pluginBundleIdentifier.isEmpty())
- WKSetApplicationInformationItem(kLSPlugInBundleIdentifierKey, m_pluginBundleIdentifier.createCFString().get());
-#endif
-}
-
-void PluginProcess::initializeSandbox(const ChildProcessInitializationParameters& parameters, SandboxInitializationParameters& sandboxParameters)
-{
- if (parameters.extraInitializationData.get("disable-sandbox") == "1")
- return;
-
- String sandboxProfile = pluginSandboxProfile(m_pluginBundleIdentifier);
- if (sandboxProfile.isEmpty())
- return;
-
- sandboxParameters.setSandboxProfile(sandboxProfile);
-
-#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1080
- // Use private temporary and cache directories.
- char temporaryDirectory[PATH_MAX];
- if (!confstr(_CS_DARWIN_USER_TEMP_DIR, temporaryDirectory, sizeof(temporaryDirectory))) {
- WTFLogAlways("PluginProcess: couldn't retrieve system temporary directory path: %d\n", errno);
- exit(EX_OSERR);
- }
-
- if (strlcpy(temporaryDirectory, [[[[NSFileManager defaultManager] stringWithFileSystemRepresentation:temporaryDirectory length:strlen(temporaryDirectory)] stringByAppendingPathComponent:@"WebKitPlugin-XXXXXX"] fileSystemRepresentation], sizeof(temporaryDirectory)) >= sizeof(temporaryDirectory)
- || !mkdtemp(temporaryDirectory)) {
- WTFLogAlways("PluginProcess: couldn't create private temporary directory '%s'\n", temporaryDirectory);
- exit(EX_OSERR);
- }
-
- sandboxParameters.setSystemDirectorySuffix([[[[NSFileManager defaultManager] stringWithFileSystemRepresentation:temporaryDirectory length:strlen(temporaryDirectory)] lastPathComponent] fileSystemRepresentation]);
-#endif
-
- sandboxParameters.addPathParameter("PLUGIN_PATH", m_pluginPath);
-
- RetainPtr<CFStringRef> cachePath = adoptCF(WKCopyFoundationCacheDirectory());
- sandboxParameters.addPathParameter("NSURL_CACHE_DIR", (NSString *)cachePath.get());
-
- RetainPtr<NSDictionary> defaults = adoptNS([[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithBool:YES], @"NSUseRemoteSavePanel", nil]);
- [[NSUserDefaults standardUserDefaults] registerDefaults:defaults.get()];
-
- ChildProcess::initializeSandbox(parameters, sandboxParameters);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(PLUGIN_PROCESS)
diff --git a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm b/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm
deleted file mode 100644
index 0c4b7fca2..000000000
--- a/Source/WebKit2/PluginProcess/mac/PluginProcessShim.mm
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <wtf/Platform.h>
-#import "PluginProcessShim.h"
-
-#import <AppKit/AppKit.h>
-#import <Carbon/Carbon.h>
-#import <WebCore/DynamicLinkerInterposing.h>
-#import <WebKitSystemInterface.h>
-#import <stdio.h>
-#import <objc/message.h>
-
-#include <sys/shm.h>
-#include <sys/ipc.h>
-#include <sys/mman.h>
-
-namespace WebKit {
-
-extern "C" void WebKitPluginProcessShimInitialize(const PluginProcessShimCallbacks& callbacks);
-
-static PluginProcessShimCallbacks pluginProcessShimCallbacks;
-
-#ifndef __LP64__
-
-#if COMPILER(CLANG)
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
-#endif
-
-static void shimDebugger(void)
-{
- if (!pluginProcessShimCallbacks.shouldCallRealDebugger())
- return;
-
- Debugger();
-}
-
-static UInt32 shimGetCurrentEventButtonState()
-{
- return pluginProcessShimCallbacks.getCurrentEventButtonState();
-}
-
-static Boolean shimIsWindowActive(WindowRef window)
-{
- bool result;
- if (pluginProcessShimCallbacks.isWindowActive(window, result))
- return result;
-
- return IsWindowActive(window);
-}
-
-static void shimModalDialog(ModalFilterUPP modalFilter, DialogItemIndex *itemHit)
-{
- pluginProcessShimCallbacks.beginModal();
- ModalDialog(modalFilter, itemHit);
- pluginProcessShimCallbacks.endModal();
-}
-
-static DialogItemIndex shimAlert(SInt16 alertID, ModalFilterUPP modalFilter)
-{
- pluginProcessShimCallbacks.beginModal();
- DialogItemIndex index = Alert(alertID, modalFilter);
- pluginProcessShimCallbacks.endModal();
-
- return index;
-}
-
-static void shimShowWindow(WindowRef window)
-{
- pluginProcessShimCallbacks.carbonWindowShown(window);
- ShowWindow(window);
-}
-
-static void shimHideWindow(WindowRef window)
-{
- pluginProcessShimCallbacks.carbonWindowHidden(window);
- HideWindow(window);
-}
-
-static OSStatus
-shimLSOpenCFURLRef(CFURLRef url, CFURLRef* launchedURL)
-{
- int32_t returnValue;
- if (pluginProcessShimCallbacks.openCFURLRef(url, returnValue, launchedURL))
- return returnValue;
-
- return LSOpenCFURLRef(url, launchedURL);
-}
-
-DYLD_INTERPOSE(shimDebugger, Debugger);
-DYLD_INTERPOSE(shimGetCurrentEventButtonState, GetCurrentEventButtonState);
-DYLD_INTERPOSE(shimIsWindowActive, IsWindowActive);
-DYLD_INTERPOSE(shimModalDialog, ModalDialog);
-DYLD_INTERPOSE(shimAlert, Alert);
-DYLD_INTERPOSE(shimShowWindow, ShowWindow);
-DYLD_INTERPOSE(shimHideWindow, HideWindow);
-DYLD_INTERPOSE(shimLSOpenCFURLRef, LSOpenCFURLRef);
-
-#if COMPILER(CLANG)
-#pragma clang diagnostic pop
-#endif
-
-#endif
-
-// Simple Fake System V shared memory. This replacement API implements
-// usable system V shared memory for use within a single process. The memory
-// is not shared outside of the scope of the process.
-struct FakeSharedMemoryDescriptor {
- FakeSharedMemoryDescriptor* next;
- int referenceCount;
- key_t key;
- size_t requestedSize;
- size_t mmapedSize;
- int sharedMemoryFlags;
- int sharedMemoryIdentifier;
- void* mmapedAddress;
-};
-
-static FakeSharedMemoryDescriptor* shmDescriptorList = 0;
-static int fakeSharedMemoryIdentifier = 0;
-
-static FakeSharedMemoryDescriptor* findBySharedMemoryIdentifier(int sharedMemoryIdentifier)
-{
- FakeSharedMemoryDescriptor* descriptorPtr = shmDescriptorList;
-
- while (descriptorPtr) {
- if (descriptorPtr->sharedMemoryIdentifier == sharedMemoryIdentifier)
- break;
- descriptorPtr = descriptorPtr->next;
- }
- return descriptorPtr;
-}
-
-static FakeSharedMemoryDescriptor* findBySharedMemoryAddress(const void* mmapedAddress)
-{
- FakeSharedMemoryDescriptor* descriptorPtr = shmDescriptorList;
-
- while (descriptorPtr) {
- if (descriptorPtr->mmapedAddress == mmapedAddress)
- break;
-
- descriptorPtr = descriptorPtr->next;
- }
- return descriptorPtr;
-}
-
-static Boolean shim_disabled(void)
-{
- static Boolean isFakeSHMDisabled;
-
- static dispatch_once_t once;
- dispatch_once(&once, ^() {
- Boolean keyExistsAndHasValidFormat = false;
- Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitDisableFakeSYSVSHM"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat);
-
- if (keyExistsAndHasValidFormat && prefValue)
- isFakeSHMDisabled = true;
- else
- isFakeSHMDisabled = false;
- });
-
- return isFakeSHMDisabled;
-}
-
-static int shim_shmdt(const void* sharedAddress)
-{
- if (shim_disabled())
- return shmdt(sharedAddress);
-
- FakeSharedMemoryDescriptor* descriptorPtr = findBySharedMemoryAddress(sharedAddress);
- if (!descriptorPtr) {
- errno = EINVAL;
- return -1;
- }
-
- descriptorPtr->referenceCount--;
- if (!descriptorPtr->referenceCount) {
- munmap(descriptorPtr->mmapedAddress, descriptorPtr->mmapedSize);
- descriptorPtr->mmapedAddress = 0;
- }
-
- return 0;
-}
-
-static void* shim_shmat(int sharedMemoryIdentifier, const void* requestedSharedAddress, int shmflg)
-{
- if (shim_disabled())
- return shmat(sharedMemoryIdentifier, requestedSharedAddress, shmflg);
-
- FakeSharedMemoryDescriptor* descriptorPtr = findBySharedMemoryIdentifier(sharedMemoryIdentifier);
- void* mappedAddress = (void*)-1;
-
- if (!descriptorPtr) {
- errno = EINVAL;
- return mappedAddress;
- }
-
- if (descriptorPtr->mmapedAddress) {
- if (!requestedSharedAddress || requestedSharedAddress == descriptorPtr->mmapedAddress) {
- mappedAddress = descriptorPtr->mmapedAddress;
- descriptorPtr->referenceCount++;
- }
- } else {
- descriptorPtr->mmapedSize = (descriptorPtr->requestedSize + PAGE_SIZE) & ~(PAGE_SIZE - 1);
- mappedAddress = descriptorPtr->mmapedAddress = mmap((void*)requestedSharedAddress,
- descriptorPtr->mmapedSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
- descriptorPtr->referenceCount++;
- }
-
- return mappedAddress;
-}
-
-static int shim_shmget(key_t key, size_t requestedSizeOfSharedMemory, int sharedMemoryFlags)
-{
- if (shim_disabled())
- return shmget(key, requestedSizeOfSharedMemory, sharedMemoryFlags);
-
- FakeSharedMemoryDescriptor* descriptorPtr = shmDescriptorList;
-
- while (descriptorPtr) {
- // Are we looking for something we've already created?
- if (descriptorPtr->key == key
- && descriptorPtr->requestedSize == requestedSizeOfSharedMemory
- && !((descriptorPtr->sharedMemoryFlags ^ sharedMemoryFlags) & 0777))
- break;
- descriptorPtr = descriptorPtr->next;
- }
-
- if (!descriptorPtr) {
- descriptorPtr = (FakeSharedMemoryDescriptor*)malloc(sizeof(FakeSharedMemoryDescriptor));
- if (!descriptorPtr) {
- errno = ENOMEM;
- return -1;
- }
- descriptorPtr->key = key;
- descriptorPtr->requestedSize = requestedSizeOfSharedMemory;
- descriptorPtr->sharedMemoryFlags = sharedMemoryFlags;
- descriptorPtr->sharedMemoryIdentifier = ++fakeSharedMemoryIdentifier;
- descriptorPtr->referenceCount = 0;
- descriptorPtr->mmapedAddress = 0;
- descriptorPtr->mmapedSize = 0;
- descriptorPtr->next = shmDescriptorList;
- shmDescriptorList = descriptorPtr;
- }
- return descriptorPtr->sharedMemoryIdentifier;
-}
-
-static int shim_shmctl(int sharedMemoryIdentifier, int cmd, struct shmid_ds* outputDescriptor)
-{
- if (shim_disabled())
- return shmctl(sharedMemoryIdentifier, cmd, outputDescriptor);
-
- FakeSharedMemoryDescriptor* descriptorPtr = findBySharedMemoryIdentifier(sharedMemoryIdentifier);
-
- if (!descriptorPtr) {
- errno = EINVAL;
- return -1;
- }
-
- switch (cmd) {
- case IPC_SET:
- case IPC_RMID:
- errno = EPERM;
- return -1;
-
- case IPC_STAT:
- outputDescriptor->shm_perm.cuid = outputDescriptor->shm_perm.uid = getuid();
- outputDescriptor->shm_perm.cgid = outputDescriptor->shm_perm.gid = getgid();
- outputDescriptor->shm_perm.mode = descriptorPtr->sharedMemoryFlags & 0777;
-
- outputDescriptor->shm_segsz = descriptorPtr->requestedSize;
-
- outputDescriptor->shm_cpid = outputDescriptor->shm_lpid = getpid();
-
- outputDescriptor->shm_nattch = descriptorPtr->referenceCount;
-
- outputDescriptor->shm_ctime = outputDescriptor->shm_atime = outputDescriptor->shm_dtime = time(0);
-
- return 0;
- }
-
- errno = EINVAL;
- return -1;
-}
-
-DYLD_INTERPOSE(shim_shmat, shmat);
-DYLD_INTERPOSE(shim_shmdt, shmdt);
-DYLD_INTERPOSE(shim_shmget, shmget);
-DYLD_INTERPOSE(shim_shmctl, shmctl);
-
-__attribute__((visibility("default")))
-void WebKitPluginProcessShimInitialize(const PluginProcessShimCallbacks& callbacks)
-{
- pluginProcessShimCallbacks = callbacks;
-}
-
-} // namespace WebKit
-
diff --git a/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp b/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp
index 73faf0a33..98b1dbf52 100644
--- a/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp
+++ b/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Igalia S.L.
+ * Copyright (C) 2011, 2014 Igalia S.L.
* Copyright (C) 2011 Apple Inc.
* Copyright (C) 2012 Samsung Electronics
*
@@ -30,89 +30,86 @@
#if ENABLE(PLUGIN_PROCESS)
+#include "ChildProcessMain.h"
#include "Logging.h"
#include "NetscapePlugin.h"
#include "PluginProcess.h"
-#include "WebKit2Initialize.h"
-#include <WebCore/RunLoop.h>
+#include <WebCore/FileSystem.h>
+#include <stdlib.h>
+#include <wtf/text/CString.h>
+
#if PLATFORM(GTK)
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#elif PLATFORM(EFL) && HAVE_ECORE_X
#include <Ecore_X.h>
#endif
-using namespace WebCore;
-
namespace WebKit {
-#ifdef XP_UNIX
+#if defined(XP_UNIX)
#if !LOG_DISABLED
static const char xErrorString[] = "The program '%s' received an X Window System error.\n"
"This probably reflects a bug in a browser plugin.\n"
"The error was '%s'.\n"
" (Details: serial %ld error_code %d request_code %d minor_code %d)\n";
-#endif /* !LOG_DISABLED */
+#endif // !LOG_DISABLED
-static char* programName = 0;
+static CString programName;
static int webkitXError(Display* xdisplay, XErrorEvent* error)
{
char errorMessage[64];
XGetErrorText(xdisplay, error->error_code, errorMessage, 63);
- LOG(Plugins, xErrorString,
- programName, errorMessage,
- error->serial, error->error_code,
- error->request_code, error->minor_code);
+ LOG(Plugins, xErrorString, programName.data(), errorMessage, error->serial, error->error_code, error->request_code, error->minor_code);
return 0;
}
-#endif
-
-WK_EXPORT int PluginProcessMainUnix(int argc, char* argv[])
-{
- bool scanPlugin = !strcmp(argv[1], "-scanPlugin");
- ASSERT_UNUSED(argc, argc == 3);
+#endif // XP_UNIX
+class PluginProcessMain final: public ChildProcessMainBase {
+public:
+ bool platformInitialize() override
+ {
#if PLATFORM(GTK)
- gtk_init(&argc, &argv);
+ gtk_init(nullptr, nullptr);
#elif PLATFORM(EFL)
#ifdef HAVE_ECORE_X
- if (!ecore_x_init(0))
+ if (!ecore_x_init(0))
#endif
- return 1;
+ return false;
#endif
- InitializeWebKit2();
-
- if (scanPlugin) {
- String pluginPath(argv[2]);
- if (!NetscapePluginModule::scanPlugin(pluginPath))
- return EXIT_FAILURE;
- return EXIT_SUCCESS;
+ return true;
}
- // Plugins can produce X errors that are handled by the GDK X error handler, which
- // exits the process. Since we don't want to crash due to plugin bugs, we install a
- // custom error handler to show a warning when a X error happens without aborting.
-#if defined(XP_UNIX)
- programName = basename(argv[0]);
- XSetErrorHandler(webkitXError);
+ bool parseCommandLine(int argc, char** argv) override
+ {
+ ASSERT(argc == 3);
+ if (argc != 3)
+ return false;
+
+ if (!strcmp(argv[1], "-scanPlugin"))
+#if PLUGIN_ARCHITECTURE(X11)
+ exit(NetscapePluginModule::scanPlugin(argv[2]) ? EXIT_SUCCESS : EXIT_FAILURE);
+#else
+ exit(EXIT_FAILURE);
#endif
- int socket = atoi(argv[1]);
-
- WebKit::ChildProcessInitializationParameters parameters;
- parameters.connectionIdentifier = socket;
- parameters.extraInitializationData.add("plugin-path", argv[2]);
-
- WebKit::PluginProcess::shared().initialize(parameters);
+#if defined(XP_UNIX)
+ programName = WebCore::pathGetFileName(argv[0]).utf8();
+ XSetErrorHandler(webkitXError);
+#endif
- RunLoop::run();
+ m_parameters.extraInitializationData.add("plugin-path", argv[2]);
+ return ChildProcessMainBase::parseCommandLine(argc, argv);
+ }
+};
- return 0;
+int PluginProcessMainUnix(int argc, char** argv)
+{
+ return ChildProcessMain<PluginProcess, PluginProcessMain>(argc, argv);
}
} // namespace WebKit
diff --git a/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.h b/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.h
index 540c596aa..f79c1d26c 100644
--- a/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.h
+++ b/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.h
@@ -27,16 +27,14 @@
#ifndef PluginProcessMainUnix_h
#define PluginProcessMainUnix_h
-#include <WebKit2/WKBase.h>
+#include <WebKit/WKBase.h>
namespace WebKit {
-#ifdef __cplusplus
extern "C" {
-WK_EXPORT int PluginProcessMainUnix(int argc, char* argv[]);
-} // extern "C"
-#endif // __cplusplus
+WK_EXPORT int PluginProcessMainUnix(int argc, char** argv);
+}
} // namespace WebKit
-#endif // PluginProcessMain_h
+#endif // PluginProcessMainUnix_h
diff --git a/Source/WebKit2/PluginProcess/unix/PluginProcessUnix.cpp b/Source/WebKit2/PluginProcess/unix/PluginProcessUnix.cpp
index 43eb8848b..c6eb49df4 100644
--- a/Source/WebKit2/PluginProcess/unix/PluginProcessUnix.cpp
+++ b/Source/WebKit2/PluginProcess/unix/PluginProcessUnix.cpp
@@ -37,7 +37,7 @@ void PluginProcess::platformInitializeProcess(const ChildProcessInitializationPa
{
}
-void PluginProcess::platformInitializePluginProcess(const PluginProcessCreationParameters&)
+void PluginProcess::platformInitializePluginProcess(PluginProcessCreationParameters&&)
{
notImplemented();
}