Diff
Modified: trunk/Source/WebKit2/ChangeLog (162927 => 162928)
--- trunk/Source/WebKit2/ChangeLog 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/ChangeLog 2014-01-28 10:22:47 UTC (rev 162928)
@@ -1,3 +1,27 @@
+2014-01-28 Adrian Perez de Castro <ape...@igalia.com>
+
+ [GTK] Add API to allow setting the process model in WebKitWebContext
+ https://bugs.webkit.org/show_bug.cgi?id=125463
+
+ Reviewed by Carlos Garcia Campos.
+
+ Implements accessors in WebKitWebContext for the process model.
+ The default behavior is unchanged, and a single web process is
+ used. Using WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW
+ as the process model will make use one web process for each
+ WebKitWebView. This also enables the network process. Setting
+ the process model must be done as early as possible, before the
+ very first web process is spawned.
+
+ * UIProcess/API/gtk/WebKitWebContext.cpp:
+ Add accessors in the API to get/set the process model.
+ (webkit_web_context_set_process_model):
+ (webkit_web_context_get_process_model):
+ * UIProcess/API/gtk/WebKitWebContext.h:
+ Define the WebKitProcessModel enum.
+ * UIProcess/API/gtk/docs/webkit2gtk-sections.txt:
+ Add new public API bits to the documentation.
+
2014-01-27 Carlos Garcia Campos <cgar...@igalia.com>
[GTK] Make webkit_uri_scheme_request_get_web_view() work with CustomProtocols
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp (162927 => 162928)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.cpp 2014-01-28 10:22:47 UTC (rev 162928)
@@ -64,8 +64,9 @@
* The #WebKitWebContext manages all aspects common to all
* #WebKitWebView<!-- -->s.
*
- * You can define the #WebKitCacheModel with
- * webkit_web_context_set_cache_model(), depending on the needs of
+ * You can define the #WebKitCacheModel and #WebKitProcessModel with
+ * webkit_web_context_set_cache_model() and
+ * webkit_web_context_set_process_model(), depending on the needs of
* your application. You can access the #WebKitCookieManager or the
* #WebKitSecurityManager to specify the behaviour of your application
* regarding cookies and security, using
@@ -161,6 +162,9 @@
static guint signals[LAST_SIGNAL] = { 0, };
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS, ProcessModelSharedSecondaryProcess);
+COMPILE_ASSERT_MATCHING_ENUM(WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW, ProcessModelMultipleSecondaryProcesses);
+
WEBKIT_DEFINE_TYPE(WebKitWebContext, webkit_web_context, G_TYPE_OBJECT)
static void webkit_web_context_class_init(WebKitWebContextClass* webContextClass)
@@ -228,10 +232,6 @@
priv->context = WebContext::create(WebCore::filenameToString(injectedBundleFilename().data()));
priv->requestManager = webContext->priv->context->supplement<WebSoupCustomProtocolRequestManager>();
priv->context->setCacheModel(CacheModelPrimaryWebBrowser);
-#if ENABLE(NETWORK_PROCESS)
- // FIXME: Temporary use an env var until we have API to set the process model. See https://bugs.webkit.org/show_bug.cgi?id=125463.
- priv->context->setUsesNetworkProcess(g_getenv("WEBKIT_USE_NETWORK_PROCESS"));
-#endif
priv->tlsErrorsPolicy = WEBKIT_TLS_ERRORS_POLICY_IGNORE;
attachInjectedBundleClientToContext(webContext.get());
@@ -888,6 +888,56 @@
context->priv->context->allowSpecificHTTPSCertificateForHost(webCertificateInfo.get(), String::fromUTF8(host));
}
+/**
+ * webkit_web_context_set_process_model:
+ * @context: the #WebKitWebContext
+ * @process_model: a #WebKitProcessModel
+ *
+ * Specifies a process model for WebViews, which WebKit will use to
+ * determine how auxiliary processes are handled. The default setting
+ * (%WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS) is suitable for most
+ * applications which embed a small amount of WebViews, or are used to
+ * display documents which are considered safe -- like local files.
+ *
+ * Applications which may potentially use a large amount of WebViews --for
+ * example a multi-tabbed web browser-- may want to use
+ * %WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW to use one
+ * process per view. Using this model, when a WebView hangs or crashes,
+ * the rest of the WebViews in the application will still work normally.
+ *
+ * This method <strong>must be called before any other functions</strong>,
+ * as early as possible in your application. Calling it later will make
+ * your application crash.
+ *
+ * Since: 2.4
+ */
+void webkit_web_context_set_process_model(WebKitWebContext* context, WebKitProcessModel processModel)
+{
+ g_return_if_fail(WEBKIT_IS_WEB_CONTEXT(context));
+
+ if (processModel != context->priv->context->processModel()) {
+ context->priv->context->setUsesNetworkProcess(processModel == ProcessModelMultipleSecondaryProcesses);
+ context->priv->context->setProcessModel(static_cast<ProcessModel>(processModel));
+ }
+}
+
+/**
+ * webkit_web_context_get_process_model:
+ * @context: the #WebKitWebContext
+ *
+ * Returns the current process model. For more information about this value
+ * see webkit_web_context_set_process_model().
+ *
+ * Returns: the current #WebKitProcessModel
+ *
+ * Since: 2.4
+ */
+WebKitProcessModel webkit_web_context_get_process_model(WebKitWebContext* context)
+{
+ g_return_val_if_fail(WEBKIT_IS_WEB_CONTEXT(context), WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
+ return static_cast<WebKitProcessModel>(context->priv->context->processModel());
+}
+
WebKitDownload* webkitWebContextGetOrCreateDownload(DownloadProxy* downloadProxy)
{
GRefPtr<WebKitDownload> download = downloadsMap().get(downloadProxy);
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h (162927 => 162928)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebContext.h 2014-01-28 10:22:47 UTC (rev 162928)
@@ -63,6 +63,30 @@
} WebKitCacheModel;
/**
+ * WebKitProcessModel:
+ * @WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS: Use a single process to
+ * perform content rendering. The process is shared among all the
+ * #WebKitWebView instances created by the application: if the process
+ * hangs or crashes all the web views in the application will be affected.
+ * This is the default process model, and it should suffice for most cases.
+ * @WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW: Use one process
+ * for each #WebKitWebView. The main advantage of this process model is that
+ * the rendering process for a web view can crash while the rest of the
+ * views keep working normally. This process model is indicated for
+ * applications which may use a number of web views and the content of
+ * in each must not interfere with the rest -- for example a full-fledged
+ * web browser with support for multiple tabs.
+ *
+ * Enum values used for determining the #WebKitWebContext process model.
+ *
+ * Since: 2.4
+ */
+typedef enum {
+ WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS,
+ WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW,
+} WebKitProcessModel;
+
+/**
* WebKitTLSErrorsPolicy:
* @WEBKIT_TLS_ERRORS_POLICY_IGNORE: Ignore TLS errors.
* @WEBKIT_TLS_ERRORS_POLICY_FAIL: TLS errors will emit
@@ -213,6 +237,13 @@
WebKitCertificateInfo *info,
const gchar *host);
+WEBKIT_API void
+webkit_web_context_set_process_model (WebKitWebContext *context,
+ WebKitProcessModel process_model);
+
+WEBKIT_API WebKitProcessModel
+webkit_web_context_get_process_model (WebKitWebContext *context);
+
G_END_DECLS
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt (162927 => 162928)
--- trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt 2014-01-28 10:22:47 UTC (rev 162928)
@@ -24,6 +24,7 @@
<TITLE>WebKitWebContext</TITLE>
WebKitWebContext
WebKitCacheModel
+WebKitProcessModel
WebKitTLSErrorsPolicy
webkit_web_context_get_default
webkit_web_context_get_cache_model
@@ -50,6 +51,8 @@
webkit_web_context_prefetch_dns
webkit_web_context_set_disk_cache_directory
webkit_web_context_allow_tls_certificate_for_host
+webkit_web_context_get_process_model
+webkit_web_context_set_process_model
<SUBSECTION URI Scheme>
WebKitURISchemeRequestCallback
Modified: trunk/Tools/ChangeLog (162927 => 162928)
--- trunk/Tools/ChangeLog 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/ChangeLog 2014-01-28 10:22:47 UTC (rev 162928)
@@ -1,3 +1,41 @@
+2014-01-28 Adrian Perez de Castro <ape...@igalia.com>
+
+ [GTK] Add API to allow setting the process model in WebKitWebContext
+ https://bugs.webkit.org/show_bug.cgi?id=125463
+
+ Reviewed by Carlos Garcia Campos.
+
+ Implements accessors in WebKitWebContext for the process model.
+ The default behavior is unchanged, and a single web process is
+ used. Using WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW
+ as the process model will make use one web process for each
+ WebKitWebView. This also enables the network process. Setting
+ the process model must be done as early as possible, before the
+ very first web process is spawned.
+
+ * MiniBrowser/gtk/main.c:
+ (main):
+ Enable multiple process mode if the MINIBROWSER_MULTIPROCESS
+ environment variable is defined and not empty.
+ * TestWebKitAPI/GNUmakefile.am:
+ Add new TestMultiprocess test case.
+ * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt:
+ Add new TestMultiprocess test case.
+ * TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp: Added.
+ (loadChanged):
+ (testMultipleSecondaryProcesses):
+ (initializeWebExtensions):
+ (beforeAll):
+ (afterAll):
+ * TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
+ (methodCallCallback):
+ Implement the GetProcessIdentifier D-Bus method.
+ (makeBusName):
+ Choose a different bus name when the web extension is used
+ from TestMultiprocess.
+ (webkit_web_extension_initialize_with_user_data):
+ Use makeBusName() to choose the bus name.
+
2014-01-28 Carlos Garcia Campos <cgar...@igalia.com>
[SOUP] Remove soupURIToKURL
Modified: trunk/Tools/MiniBrowser/gtk/main.c (162927 => 162928)
--- trunk/Tools/MiniBrowser/gtk/main.c 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/MiniBrowser/gtk/main.c 2014-01-28 10:22:47 UTC (rev 162928)
@@ -241,6 +241,12 @@
{
gtk_init(&argc, &argv);
+ const gchar *multiprocess = g_getenv("MINIBROWSER_MULTIPROCESS");
+ if (multiprocess && *multiprocess) {
+ webkit_web_context_set_process_model(webkit_web_context_get_default(),
+ WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+ }
+
GOptionContext *context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, commandLineOptions, 0);
g_option_context_add_group(context, gtk_get_option_group(TRUE));
Modified: trunk/Tools/TestWebKitAPI/GNUmakefile.am (162927 => 162928)
--- trunk/Tools/TestWebKitAPI/GNUmakefile.am 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/GNUmakefile.am 2014-01-28 10:22:47 UTC (rev 162928)
@@ -161,6 +161,7 @@
Programs/TestWebKitAPI/WebKit2Gtk/TestInspector \
Programs/TestWebKitAPI/WebKit2Gtk/TestInspectorServer \
Programs/TestWebKitAPI/WebKit2Gtk/TestLoaderClient \
+ Programs/TestWebKitAPI/WebKit2Gtk/TestMultiprocess \
Programs/TestWebKitAPI/WebKit2Gtk/TestPrinting \
Programs/TestWebKitAPI/WebKit2Gtk/TestResources \
Programs/TestWebKitAPI/WebKit2Gtk/TestSSL \
@@ -769,6 +770,12 @@
Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDADD = $(webkit2gtk_tests_ldadd)
Programs_TestWebKitAPI_WebKit2Gtk_TestLoaderClient_LDFLAGS = $(webkit2gtk_tests_ldflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_SOURCES = \
+ Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_CPPFLAGS = $(webkit2gtk_tests_cppflags)
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_LDADD = $(webkit2gtk_tests_ldadd)
+Programs_TestWebKitAPI_WebKit2Gtk_TestMultiprocess_LDFLAGS = $(webkit2gtk_tests_ldflags)
+
Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_SOURCES = \
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestWebKitSettings.cpp
Programs_TestWebKitAPI_WebKit2Gtk_TestWebKitSettings_CPPFLAGS = $(webkit2gtk_tests_cppflags)
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt (162927 => 162928)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt 2014-01-28 10:22:47 UTC (rev 162928)
@@ -92,6 +92,7 @@
ADD_WK2_TEST(TestInspector TestInspector.cpp)
ADD_WK2_TEST(TestInspectorServer TestInspectorServer.cpp)
ADD_WK2_TEST(TestLoaderClient TestLoaderClient.cpp)
+ADD_WK2_TEST(TestMultiprocess TestMultiprocess.cpp)
ADD_WK2_TEST(TestPrinting TestPrinting.cpp)
ADD_WK2_TEST(TestSSL TestSSL.cpp)
ADD_WK2_TEST(TestWebExtensions TestWebExtensions.cpp)
Added: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp (0 => 162928)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestMultiprocess.cpp 2014-01-28 10:22:47 UTC (rev 162928)
@@ -0,0 +1,143 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2,1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "TestMain.h"
+#include "WebKitTestBus.h"
+#include <webkit2/webkit2.h>
+#include <wtf/Vector.h>
+
+static const unsigned numViews = 2;
+static guint32 nextInitializationId = 1;
+static unsigned initializeWebExtensionsSignalCount;
+static WebKitTestBus* bus;
+
+class MultiprocessTest: public Test {
+public:
+ MAKE_GLIB_TEST_FIXTURE(MultiprocessTest);
+
+ MultiprocessTest()
+ : m_mainLoop(g_main_loop_new(nullptr, TRUE))
+ , m_webViewBusNames(numViews)
+ , m_webViews(numViews) { }
+
+ static void loadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent, MultiprocessTest* test)
+ {
+ if (loadEvent != WEBKIT_LOAD_FINISHED)
+ return;
+ g_signal_handlers_disconnect_by_func(webView, reinterpret_cast<void*>(loadChanged), test);
+ g_main_loop_quit(test->m_mainLoop);
+ }
+
+ void loadWebViewAndWaitUntilLoaded(unsigned index)
+ {
+ g_assert_cmpuint(index, <, numViews);
+
+ m_webViewBusNames[index] = GUniquePtr<char>(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", nextInitializationId));
+
+ m_webViews[index] = WEBKIT_WEB_VIEW(webkit_web_view_new());
+ assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webViews[index].get()));
+
+ webkit_web_view_load_html(m_webViews[index].get(), "<html></html>", nullptr);
+ g_signal_connect(m_webViews[index].get(), "load-changed", G_CALLBACK(loadChanged), this);
+ g_main_loop_run(m_mainLoop);
+ }
+
+ unsigned webProcessPid(unsigned index)
+ {
+ g_assert_cmpuint(index, <, numViews);
+
+ GRefPtr<GDBusProxy> proxy = adoptGRef(bus->createProxy(m_webViewBusNames[index].get(),
+ "/org/webkit/gtk/WebExtensionTest", "org.webkit.gtk.WebExtensionTest", m_mainLoop));
+
+ GRefPtr<GVariant> result = adoptGRef(g_dbus_proxy_call_sync(
+ proxy.get(),
+ "GetProcessIdentifier",
+ nullptr,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1, nullptr, nullptr));
+ g_assert(result);
+
+ guint32 identifier = 0;
+ g_variant_get(result.get(), "(u)", &identifier);
+ return identifier;
+ }
+
+ GMainLoop* m_mainLoop;
+ Vector<GUniquePtr<char>, numViews> m_webViewBusNames;
+ Vector<GRefPtr<WebKitWebView>, numViews> m_webViews;
+};
+
+static void testProcessPerWebView(MultiprocessTest* test, gconstpointer)
+{
+ // Create two web views. As we are in multiprocess mode, there must be
+ // two web processes, running an instance of the web extension each.
+ // The initialize-web-extensions must have been called twice, and the
+ // identifiers generated for them must be different (and their reported
+ // process identifiers).
+
+ for (unsigned i = 0; i < numViews; i++) {
+ test->loadWebViewAndWaitUntilLoaded(i);
+ g_assert(WEBKIT_IS_WEB_VIEW(test->m_webViews[i].get()));
+ g_assert(test->m_webViewBusNames[i]);
+ }
+
+ g_assert_cmpuint(initializeWebExtensionsSignalCount, ==, numViews);
+ g_assert_cmpstr(test->m_webViewBusNames[0].get(), !=, test->m_webViewBusNames[1].get());
+ g_assert_cmpuint(test->webProcessPid(0), !=, test->webProcessPid(1));
+}
+
+static void initializeWebExtensions(WebKitWebContext* context, gpointer)
+{
+ initializeWebExtensionsSignalCount++;
+ webkit_web_context_set_web_extensions_directory(context, WEBKIT_TEST_WEB_EXTENSIONS_DIR);
+ webkit_web_context_set_web_extensions_initialization_user_data(context,
+ g_variant_new_uint32(nextInitializationId++));
+}
+
+void beforeAll()
+{
+ g_signal_connect(webkit_web_context_get_default(),
+ "initialize-web-extensions", G_CALLBACK(initializeWebExtensions), nullptr);
+
+ // Check that default setting is the one stated in the documentation
+ g_assert_cmpuint(webkit_web_context_get_process_model(webkit_web_context_get_default()),
+ ==, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
+
+ webkit_web_context_set_process_model(webkit_web_context_get_default(),
+ WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+
+ // Check that the getter returns the newly-set value
+ g_assert_cmpuint(webkit_web_context_get_process_model(webkit_web_context_get_default()),
+ ==, WEBKIT_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW);
+
+ bus = new WebKitTestBus();
+ if (!bus->run())
+ return;
+
+ MultiprocessTest::add("WebKitWebContext", "process-per-web-view", testProcessPerWebView);
+}
+
+void afterAll()
+{
+ delete bus;
+ g_signal_handlers_disconnect_by_func(webkit_web_context_get_default(),
+ reinterpret_cast<void*>(initializeWebExtensions), nullptr);
+}
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp (162927 => 162928)
--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp 2014-01-28 10:02:21 UTC (rev 162927)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp 2014-01-28 10:22:47 UTC (rev 162928)
@@ -28,6 +28,7 @@
#include <wtf/Deque.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/ProcessID.h>
#include <wtf/gobject/GOwnPtr.h>
#include <wtf/gobject/GRefPtr.h>
#include <wtf/gobject/GUniquePtr.h>
@@ -49,6 +50,9 @@
" <method name='GetInitializationUserData'>"
" <arg type='s' name='userData' direction='out'/>"
" </method>"
+ " <method name='GetProcessIdentifier'>"
+ " <arg type='u' name='identifier' direction='out'/>"
+ " </method>"
" <signal name='DocumentLoaded'/>"
" <signal name='URIChanged'>"
" <arg type='s' name='uri' direction='out'/>"
@@ -224,6 +228,9 @@
g_assert(g_variant_is_of_type(initializationUserData.get(), G_VARIANT_TYPE_STRING));
g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)",
g_variant_get_string(initializationUserData.get(), nullptr)));
+ } else if (!g_strcmp0(methodName, "GetProcessIdentifier")) {
+ g_dbus_method_invocation_return_value(invocation,
+ g_variant_new("(u)", static_cast<guint32>(getCurrentProcessID())));
}
}
@@ -263,6 +270,18 @@
}
}
+static GUniquePtr<char> makeBusName(GVariant* userData)
+{
+ // When the web extension is used by TestMultiprocess, an uint32
+ // identifier is passed as user data. It uniquely identifies
+ // the web process, and the UI side expects it added as suffix to
+ // the bus name.
+ if (userData && g_variant_is_of_type(userData, G_VARIANT_TYPE_UINT32))
+ return GUniquePtr<char>(g_strdup_printf("org.webkit.gtk.WebExtensionTest%u", g_variant_get_uint32(userData)));
+
+ return GUniquePtr<char>(g_strdup("org.webkit.gtk.WebExtensionTest"));
+}
+
extern "C" void webkit_web_extension_initialize_with_user_data(WebKitWebExtension* extension, GVariant* userData)
{
initializationUserData = userData;
@@ -270,9 +289,10 @@
g_signal_connect(extension, "page-created", G_CALLBACK(pageCreatedCallback), extension);
g_signal_connect(webkit_script_world_get_default(), "window-object-cleared", G_CALLBACK(windowObjectCleared), 0);
+ GUniquePtr<char> busName(makeBusName(userData));
g_bus_own_name(
G_BUS_TYPE_SESSION,
- "org.webkit.gtk.WebExtensionTest",
+ busName.get(),
G_BUS_NAME_OWNER_FLAGS_NONE,
busAcquiredCallback,
0, 0,