diff options
author | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-10-23 22:29:36 -0500 |
---|---|---|
committer | Michael Catanzaro <mcatanzaro@gnome.org> | 2016-10-24 18:57:51 -0500 |
commit | cfab395a9749b3bde1ec267f081a7a87ce3eaf14 (patch) | |
tree | f905fb5f795652df63367150a4f9ce76d0348be8 /embed/ephy-embed-shell.c | |
parent | a31c3b53a15a1e36aca8ac4fa42f2f8ff24e8ff4 (diff) | |
download | epiphany-cfab395a9749b3bde1ec267f081a7a87ce3eaf14.tar.gz |
Move EphyUriTester to the UI process and make it a D-Bus interface
For one thing, it's silly to have n different EphyUriTesters in n
different web processes, each one loading up adblock filters separately.
Once upon a time, this used to cause big problems when the different web
processes would stomp on the global filters file. For us to ever
implement a real filters configuration dialog, this needs to be handled
in one place, by the UI process, and web extensions must just query the
UI process when they want to use the URI tester.
For another: it's basically required to use libhttpseverywhere
effectively. We're going to have to set up almost this same exact
interface for libhttpseverywhere, so might as well do it for adblock
too. Why is it needed? Because loading HTTPS Everywhere rulesets takes
~2 seconds apiece. It's much too long to do each time we open a new
browser tab, so we should do it in the UI process instead.
An unfortunate consequence of this is that our GDBusConnection use in
the web process can no longer be asynchronous. This is because we must
have an EphyUriTesterProxy completely ready to be used before the first
URI request is ready. We must handle each URI request synchronously as a
consequence of WebKit's signal-based API. What a shame!
Diffstat (limited to 'embed/ephy-embed-shell.c')
-rw-r--r-- | embed/ephy-embed-shell.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c index 732f4b661..e1886e56f 100644 --- a/embed/ephy-embed-shell.c +++ b/embed/ephy-embed-shell.c @@ -35,10 +35,10 @@ #include "ephy-profile-utils.h" #include "ephy-settings.h" #include "ephy-snapshot-service.h" +#include "ephy-uri-tester.h" #include "ephy-view-source-handler.h" #include "ephy-web-app-utils.h" #include "ephy-web-extension-proxy.h" -#include "ephy-web-extension-names.h" #include <glib/gi18n.h> #include <gtk/gtk.h> @@ -62,6 +62,7 @@ typedef struct { EphyViewSourceHandler *source_handler; guint update_overview_timeout_id; guint hiding_overview_item; + EphyUriTester *uri_tester; GDBusServer *dbus_server; GList *web_extensions; } EphyEmbedShellPrivate; @@ -110,6 +111,7 @@ ephy_embed_shell_dispose (GObject *object) g_clear_object (&priv->downloads_manager); g_clear_object (&priv->hosts_manager); g_clear_object (&priv->web_context); + g_clear_object (&priv->uri_tester); g_clear_object (&priv->dbus_server); G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object); @@ -605,9 +607,12 @@ new_connection_cb (GDBusServer *server, GDBusConnection *connection, EphyEmbedShell *shell) { + EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell); EphyWebExtensionProxy *extension = ephy_web_extension_proxy_new (connection); ephy_embed_shell_watch_web_extension (shell, extension); + ephy_uri_tester_register_dbus_object (priv->uri_tester, connection); + g_signal_connect_object (extension, "page-created", G_CALLBACK (web_extension_page_created), shell, 0); @@ -883,19 +888,25 @@ ephy_embed_shell_constructed (GObject *object) { EphyEmbedShell *shell; EphyEmbedShellPrivate *priv; + EphyEmbedShellMode mode; G_OBJECT_CLASS (ephy_embed_shell_parent_class)->constructed (object); shell = EPHY_EMBED_SHELL (object); priv = ephy_embed_shell_get_instance_private (shell); + mode = ephy_embed_shell_get_mode (shell); + /* These do not run the EmbedShell application instance, so make sure that there is a web context and a user content manager for them. */ - if (ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_TEST || - ephy_embed_shell_get_mode (shell) == EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) { + if (mode == EPHY_EMBED_SHELL_MODE_TEST || + mode == EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) { ephy_embed_shell_create_web_context (shell); priv->user_content = webkit_user_content_manager_new (); } + if (mode != EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) + priv->uri_tester = ephy_uri_tester_new (); + g_signal_connect_object (ephy_snapshot_service_get_default (), "snapshot-saved", G_CALLBACK (snapshot_saved_cb), shell, 0); |