summaryrefslogtreecommitdiff
path: root/Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp
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/unix/PluginProcessMainUnix.cpp
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/unix/PluginProcessMainUnix.cpp')
-rw-r--r--Source/WebKit2/PluginProcess/unix/PluginProcessMainUnix.cpp85
1 files changed, 41 insertions, 44 deletions
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