[epiphany/carlosgc/wk-user-messages: 1/2] Enable Process Swap On Navigation
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/carlosgc/wk-user-messages: 1/2] Enable Process Swap On Navigation
- Date: Mon, 14 Oct 2019 15:45:52 +0000 (UTC)
commit 208a500ec351cbfe38c42f56b2e39949d0bfcc24
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Fri Oct 4 16:26:02 2019 +0200
Enable Process Swap On Navigation
Bump the dependency opf WebKitGTK to 2.27.1 and use the new API to
enable PSON. We no longer need to keep the web process extension as a
member of the web view, since it's only required by EphyShell that now
keeps a hash table with the proxy of every known page id.
embed/ephy-embed-shell.c | 71 ++++++++++++++++++++++++------------------------
embed/ephy-embed-shell.h | 1 +
embed/ephy-web-view.c | 34 -----------------------
embed/ephy-web-view.h | 3 --
meson.build | 2 +-
5 files changed, 38 insertions(+), 73 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 811796553..f9dca716e 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -43,7 +43,6 @@
#include "ephy-uri-helpers.h"
#include "ephy-view-source-handler.h"
#include "ephy-web-app-utils.h"
-#include "ephy-web-process-extension-proxy.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -69,6 +68,7 @@ typedef struct {
char *guid;
GDBusServer *dbus_server;
GList *web_process_extensions;
+ GHashTable *web_process_extension_page_map;
EphyFiltersManager *filters_manager;
EphySearchEngineManager *search_engine_manager;
GCancellable *cancellable;
@@ -77,7 +77,6 @@ typedef struct {
enum {
RESTORED_WINDOW,
WEB_VIEW_CREATED,
- PAGE_CREATED,
ALLOW_TLS_CERTIFICATE,
ALLOW_UNSAFE_BROWSING,
PASSWORD_FORM_FOCUSED,
@@ -141,8 +140,15 @@ ephy_embed_shell_get_extension_proxy_for_page_id (EphyEmbedShell *self,
guint64 page_id,
const char *origin)
{
- EphyWebView *view = ephy_embed_shell_get_view_for_page_id (self, page_id, origin);
- return view ? ephy_web_view_get_web_process_extension_proxy (view) : NULL;
+ EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (self);
+
+ if (!priv->web_process_extension_page_map)
+ return NULL;
+
+ if (!ephy_embed_shell_get_view_for_page_id (self, page_id, origin))
+ return NULL;
+
+ return g_hash_table_lookup (priv->web_process_extension_page_map, GSIZE_TO_POINTER (page_id));
}
static GList *
@@ -217,6 +223,7 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->dbus_server);
g_clear_object (&priv->filters_manager);
g_clear_object (&priv->search_engine_manager);
+ g_clear_pointer (&priv->web_process_extension_page_map, g_hash_table_destroy);
G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
}
@@ -982,8 +989,18 @@ web_process_extension_page_created (EphyWebProcessExtensionProxy *extension,
guint64 page_id,
EphyEmbedShell *shell)
{
+ EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
+
g_object_set_data (G_OBJECT (extension), "initialized", GINT_TO_POINTER (TRUE));
- g_signal_emit (shell, signals[PAGE_CREATED], 0, page_id, extension);
+ g_hash_table_insert (priv->web_process_extension_page_map, GSIZE_TO_POINTER (page_id), extension);
+}
+
+static gboolean
+find_extension (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ return value == user_data;
}
static void
@@ -993,6 +1010,7 @@ web_process_extension_connection_closed (EphyWebProcessExtensionProxy *extension
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
priv->web_process_extensions = g_list_remove (priv->web_process_extensions, extension);
+ g_hash_table_foreach_remove (priv->web_process_extension_page_map, find_extension, extension);
g_object_unref (extension);
}
@@ -1070,22 +1088,21 @@ ephy_embed_shell_create_web_context (EphyEmbedShell *shell)
EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
g_autoptr (WebKitWebsiteDataManager) manager = NULL;
- if (priv->mode == EPHY_EMBED_SHELL_MODE_INCOGNITO) {
- priv->web_context = webkit_web_context_new_ephemeral ();
- return;
- }
-
- if (priv->mode == EPHY_EMBED_SHELL_MODE_AUTOMATION) {
- priv->web_context = webkit_web_context_new_ephemeral ();
- webkit_web_context_set_automation_allowed (priv->web_context, TRUE);
- return;
+ if (priv->mode == EPHY_EMBED_SHELL_MODE_INCOGNITO || priv->mode == EPHY_EMBED_SHELL_MODE_AUTOMATION) {
+ manager = webkit_website_data_manager_new_ephemeral ();
+ } else {
+ manager = webkit_website_data_manager_new ("base-data-directory", ephy_profile_dir (),
+ "base-cache-directory", ephy_cache_dir (),
+ NULL);
}
- manager = webkit_website_data_manager_new ("base-data-directory", ephy_profile_dir (),
- "base-cache-directory", ephy_cache_dir (),
- NULL);
+ priv->web_context = g_object_new (WEBKIT_TYPE_WEB_CONTEXT,
+ "website-data-manager", manager,
+ "process-swap-on-cross-site-navigation-enabled", TRUE,
+ NULL);
- priv->web_context = webkit_web_context_new_with_website_data_manager (manager);
+ if (priv->mode == EPHY_EMBED_SHELL_MODE_AUTOMATION)
+ webkit_web_context_set_automation_allowed (priv->web_context, TRUE);
}
static void
@@ -1209,6 +1226,7 @@ ephy_embed_shell_startup (GApplication *application)
webkit_web_context_add_path_to_sandbox (priv->web_context, BUILD_ROOT, TRUE);
#endif
+ priv->web_process_extension_page_map = g_hash_table_new (g_direct_hash, g_direct_equal);
g_signal_connect_object (priv->web_context, "initialize-web-extensions",
G_CALLBACK (initialize_web_process_extensions),
shell, 0);
@@ -1452,23 +1470,6 @@ ephy_embed_shell_class_init (EphyEmbedShellClass *klass)
G_TYPE_NONE, 1,
EPHY_TYPE_WEB_VIEW);
- /**
- * EphyEmbedShell::page-created:
- * @shell: the #EphyEmbedShell
- * @page_id: the identifier of the web page created
- * @web_process_extension: the #EphyWebProcessExtensionProxy
- *
- * Emitted when a web page is created in the web process.
- */
- signals[PAGE_CREATED] =
- g_signal_new ("page-created",
- EPHY_TYPE_EMBED_SHELL,
- G_SIGNAL_RUN_FIRST,
- 0, NULL, NULL, NULL,
- G_TYPE_NONE, 2,
- G_TYPE_UINT64,
- EPHY_TYPE_WEB_PROCESS_EXTENSION_PROXY);
-
/**
* EphyEmbedShell::allow-tls-certificate:
* @shell: the #EphyEmbedShell
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 6abfddbc0..0d46b4264 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -31,6 +31,7 @@
#include "ephy-password-manager.h"
#include "ephy-permissions-manager.h"
#include "ephy-search-engine-manager.h"
+#include "ephy-web-process-extension-proxy.h"
G_BEGIN_DECLS
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index aeedd254c..e2c2f2a54 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -133,9 +133,6 @@ struct _EphyWebView {
char *tls_error_failing_uri;
EphyWebViewErrorPage error_page;
-
- /* Web Process Extension */
- EphyWebProcessExtensionProxy *web_process_extension;
};
typedef struct {
@@ -905,32 +902,11 @@ allow_unsafe_browsing_cb (EphyEmbedShell *shell,
ephy_web_view_load_url (view, ephy_web_view_get_address (view));
}
-static void
-page_created_cb (EphyEmbedShell *shell,
- guint64 page_id,
- EphyWebProcessExtensionProxy *web_process_extension,
- EphyWebView *view)
-{
- if (webkit_web_view_get_page_id (WEBKIT_WEB_VIEW (view)) != page_id)
- return;
-
- if (view->web_process_extension)
- g_object_remove_weak_pointer (G_OBJECT (view->web_process_extension), (gpointer
*)&view->web_process_extension);
-
- view->web_process_extension = web_process_extension;
- g_object_add_weak_pointer (G_OBJECT (view->web_process_extension), (gpointer
*)&view->web_process_extension);
-}
-
static void
ephy_web_view_dispose (GObject *object)
{
EphyWebView *view = EPHY_WEB_VIEW (object);
- if (view->web_process_extension) {
- g_object_remove_weak_pointer (G_OBJECT (view->web_process_extension), (gpointer
*)&view->web_process_extension);
- view->web_process_extension = NULL;
- }
-
untrack_info_bar (&view->geolocation_info_bar);
untrack_info_bar (&view->notification_info_bar);
untrack_info_bar (&view->microphone_info_bar);
@@ -3000,10 +2976,6 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (authenticate_cb),
NULL);
- g_signal_connect_object (shell, "page-created",
- G_CALLBACK (page_created_cb),
- web_view, 0);
-
g_signal_connect_object (shell, "password-form-focused",
G_CALLBACK (password_form_focused_cb),
web_view, 0);
@@ -3978,12 +3950,6 @@ ephy_web_view_get_reader_mode_state (EphyWebView *view)
return view->reader_active;
}
-EphyWebProcessExtensionProxy *
-ephy_web_view_get_web_process_extension_proxy (EphyWebView *view)
-{
- return view->web_process_extension;
-}
-
gboolean
ephy_web_view_is_in_auth_dialog (EphyWebView *view)
{
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 751166547..5cacb9099 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -26,7 +26,6 @@
#include "ephy-embed-shell.h"
#include "ephy-history-types.h"
#include "ephy-security-levels.h"
-#include "ephy-web-process-extension-proxy.h"
G_BEGIN_DECLS
@@ -165,8 +164,6 @@ gboolean ephy_web_view_get_reader_mode_state (EphyWebView
gboolean ephy_web_view_is_in_auth_dialog (EphyWebView *view);
-EphyWebProcessExtensionProxy *ephy_web_view_get_web_process_extension_proxy (EphyWebView
*view);
-
void ephy_web_view_show_auth_form_save_request (EphyWebView
*web_view,
const char *origin,
const char
*username,
diff --git a/meson.build b/meson.build
index 08e9787b4..5b91f1bab 100644
--- a/meson.build
+++ b/meson.build
@@ -76,7 +76,7 @@ config_h = declare_dependency(
glib_requirement = '>= 2.61.2'
gtk_requirement = '>= 3.24.0'
nettle_requirement = '>= 3.4'
-webkitgtk_requirement = '>= 2.26.0'
+webkitgtk_requirement = '>= 2.27.1'
cairo_dep = dependency('cairo', version: '>= 1.2')
gcr_dep = dependency('gcr-3', version: '>= 3.5.5')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]