aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2013-03-28 22:56:23 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2013-04-05 17:43:21 +0800
commitefccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6 (patch)
tree0c77cd96faff179f977cf25ff375c241a7320414
parent921cc71d8092e41f5d8cec0c652d14059c9fb6a8 (diff)
downloadgsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar.gz
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar.bz2
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar.lz
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar.xz
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.tar.zst
gsoc2013-epiphany-efccc1eac4ac4e15fd4f5695d27a85c7d25c3cc6.zip
Unify all web context setup in EphyEmbedShell on primary instance startup
Cookies, web extension and custom URI handlers were initialized in ephy_embed_shell_init(), so they were always called even for secondary instances. All other initializations were in ephy_shell_startup so that it only happens for the primary instance. Move all the code to ephy_embed_shell_startup to make sure everything happens at the same time and only for the primary instance. https://bugzilla.gnome.org/show_bug.cgi?id=696020
-rw-r--r--embed/Makefile.am1
-rw-r--r--embed/ephy-embed-shell.c169
-rw-r--r--src/Makefile.am1
-rw-r--r--src/ephy-shell.c46
4 files changed, 112 insertions, 105 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index 44aa8b11b..1de594330 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -62,6 +62,7 @@ libephyembed_la_CPPFLAGS = \
libephyembed_la_CFLAGS = \
-DSHARE_DIR=\"$(pkgdatadir)\" \
+ -DEPHY_WEB_EXTENSIONS_DIR=\""$(libdir)/epiphany/$(EPIPHANY_MAJOR)/web-extensions"\" \
$(DEPENDENCIES_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(AM_CFLAGS)
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 3e3057996..e27105991 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -99,19 +99,6 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->frecent_store);
g_clear_object (&priv->global_history_service);
- if (priv->web_extension_watch_name_id > 0) {
- g_bus_unwatch_name (priv->web_extension_watch_name_id);
- priv->web_extension_watch_name_id = 0;
- }
-
- if (priv->web_extension_form_auth_save_signal_id > 0) {
- g_dbus_connection_signal_unsubscribe (g_dbus_proxy_get_connection (priv->web_extension),
- priv->web_extension_form_auth_save_signal_id);
- priv->web_extension_form_auth_save_signal_id = 0;
- }
-
- g_clear_object (&priv->web_extension);
-
if (priv->downloads != NULL) {
LOG ("Destroying downloads list");
g_list_free_full (priv->downloads, (GDestroyNotify)g_object_unref);
@@ -315,37 +302,17 @@ ephy_embed_shell_restored_window (EphyEmbedShell *shell)
}
static void
-ephy_embed_shell_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
+ephy_embed_shell_setup_environment (EphyEmbedShell *shell)
{
- EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (object);
+ EphyEmbedShellMode mode = shell->priv->mode;
+ char *pid_str;
- switch (prop_id) {
- case PROP_MODE:
- embed_shell->priv->mode = g_value_get_enum (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
-}
-
-static void
-ephy_embed_shell_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (object);
-
- switch (prop_id) {
- case PROP_MODE:
- g_value_set_enum (value, embed_shell->priv->mode);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- }
+ pid_str = g_strdup_printf ("%u", getpid ());
+ g_setenv ("EPHY_WEB_EXTENSION_ID", pid_str, TRUE);
+ g_setenv ("EPHY_DOT_DIR", ephy_dot_dir (), TRUE);
+ if (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode))
+ g_setenv ("EPHY_PRIVATE_PROFILE", "1", TRUE);
+ g_free (pid_str);
}
static void
@@ -403,26 +370,40 @@ about_request_cb (WebKitURISchemeRequest *request,
}
static void
-ephy_embed_shell_init (EphyEmbedShell *shell)
+ephy_embed_shell_startup (GApplication* application)
{
+ EphyEmbedShell *shell = EPHY_EMBED_SHELL (application);
+ EphyEmbedShellMode mode;
+ char *disk_cache_dir;
WebKitWebContext *web_context;
WebKitCookieManager *cookie_manager;
char *filename;
char *cookie_policy;
- shell->priv = EPHY_EMBED_SHELL_GET_PRIVATE (shell);
+ G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application);
- /* globally accessible singleton */
- g_assert (embed_shell == NULL);
- embed_shell = shell;
+ /* We're not remoting, setup the Web Context. */
+ mode = shell->priv->mode;
+ web_context = webkit_web_context_get_default ();
- shell->priv->downloads = NULL;
+ ephy_embed_shell_setup_environment (shell);
- /* Initialise nspluginwrapper's plugins if available. */
- if (g_file_test (NSPLUGINWRAPPER_SETUP, G_FILE_TEST_EXISTS) != FALSE)
- g_spawn_command_line_sync (NSPLUGINWRAPPER_SETUP, NULL, NULL, NULL, NULL);
+ /* Set the web extensions dir ASAP before the process is launched. */
+ webkit_web_context_set_web_extensions_directory (web_context, EPHY_WEB_EXTENSIONS_DIR);
+ ephy_embed_shell_watch_web_extension (shell);
- web_context = webkit_web_context_get_default ();
+ /* Disk Cache */
+ disk_cache_dir = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode) ?
+ ephy_dot_dir () : g_get_user_cache_dir (),
+ g_get_prgname (), NULL);
+ webkit_web_context_set_disk_cache_directory (web_context, disk_cache_dir);
+ g_free (disk_cache_dir);
+
+ /* about: URIs handler */
+ webkit_web_context_register_uri_scheme (web_context,
+ EPHY_ABOUT_SCHEME,
+ (WebKitURISchemeRequestCallback)about_request_cb,
+ shell, NULL);
/* Store cookies in moz-compatible SQLite format */
cookie_manager = webkit_web_context_get_cookie_manager (web_context);
@@ -436,24 +417,96 @@ ephy_embed_shell_init (EphyEmbedShell *shell)
ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
g_free (cookie_policy);
- /* about: URIs handler */
- webkit_web_context_register_uri_scheme (web_context,
- EPHY_ABOUT_SCHEME,
- about_request_cb,
- NULL, NULL);
- ephy_embed_shell_watch_web_extension (shell);
+ ephy_embed_prefs_init ();
+}
+
+static void
+ephy_embed_shell_shutdown (GApplication* application)
+{
+ EphyEmbedShellPrivate *priv = EPHY_EMBED_SHELL (application)->priv;
+
+ G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->shutdown (application);
+
+ if (priv->web_extension_watch_name_id > 0) {
+ g_bus_unwatch_name (priv->web_extension_watch_name_id);
+ priv->web_extension_watch_name_id = 0;
+ }
+
+ if (priv->web_extension_form_auth_save_signal_id > 0) {
+ g_dbus_connection_signal_unsubscribe (g_dbus_proxy_get_connection (priv->web_extension),
+ priv->web_extension_form_auth_save_signal_id);
+ priv->web_extension_form_auth_save_signal_id = 0;
+ }
+
+ g_clear_object (&priv->web_extension);
+
+ ephy_embed_prefs_shutdown ();
+}
+
+static void
+ephy_embed_shell_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (object);
+
+ switch (prop_id) {
+ case PROP_MODE:
+ embed_shell->priv->mode = g_value_get_enum (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ephy_embed_shell_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (object);
+
+ switch (prop_id) {
+ case PROP_MODE:
+ g_value_set_enum (value, embed_shell->priv->mode);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+ephy_embed_shell_init (EphyEmbedShell *shell)
+{
+ shell->priv = EPHY_EMBED_SHELL_GET_PRIVATE (shell);
+
+ /* globally accessible singleton */
+ g_assert (embed_shell == NULL);
+ embed_shell = shell;
+
+ shell->priv->downloads = NULL;
+
+ /* Initialise nspluginwrapper's plugins if available. */
+ if (g_file_test (NSPLUGINWRAPPER_SETUP, G_FILE_TEST_EXISTS) != FALSE)
+ g_spawn_command_line_sync (NSPLUGINWRAPPER_SETUP, NULL, NULL, NULL, NULL);
}
static void
ephy_embed_shell_class_init (EphyEmbedShellClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GApplicationClass *application_class = G_APPLICATION_CLASS (klass);
object_class->dispose = ephy_embed_shell_dispose;
object_class->set_property = ephy_embed_shell_set_property;
object_class->get_property = ephy_embed_shell_get_property;
+ application_class->startup = ephy_embed_shell_startup;
+ application_class->shutdown = ephy_embed_shell_shutdown;
+
object_properties[PROP_MODE] =
g_param_spec_enum ("mode",
"Mode",
diff --git a/src/Makefile.am b/src/Makefile.am
index 0b38aa816..290ca0fb0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -86,7 +86,6 @@ libephymain_la_CPPFLAGS = \
-DLOADER_DIR=\""$(pkglibdir)/$(EPIPHANY_MAJOR)/loaders"\" \
-DDATADIR=\""$(pkgdatadir)"\" \
-DGNOMELOCALEDIR=\"$(datadir)/locale\" \
- -DEPHY_WEB_EXTENSIONS_DIR=\""$(libdir)/epiphany/$(EPIPHANY_MAJOR)/web-extensions"\" \
$(AM_CPPFLAGS)
if WITH_WEBKIT2
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 9b3a9012e..bfb6d7a4a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -27,7 +27,6 @@
#include "ephy-bookmarks-import.h"
#include "ephy-debug.h"
#include "ephy-embed-container.h"
-#include "ephy-embed-prefs.h"
#include "ephy-embed-utils.h"
#include "ephy-file-helpers.h"
#include "ephy-gui.h"
@@ -223,52 +222,16 @@ static GActionEntry app_normal_mode_entries[] = {
{ "reopen-closed-tab", reopen_closed_tab, NULL, NULL, NULL },
};
-#ifdef HAVE_WEBKIT2
-static void
-ephy_shell_setup_environment (EphyShell *shell)
-{
- EphyEmbedShellMode mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell));
- char *pid_str;
-
- pid_str = g_strdup_printf ("%u", getpid ());
- g_setenv ("EPHY_WEB_EXTENSION_ID", pid_str, TRUE);
- g_setenv ("EPHY_DOT_DIR", ephy_dot_dir (), TRUE);
- if (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode))
- g_setenv ("EPHY_PRIVATE_PROFILE", "1", TRUE);
- g_free (pid_str);
-}
-#endif
-
static void
ephy_shell_startup (GApplication* application)
{
EphyEmbedShellMode mode;
-#ifdef HAVE_WEBKIT2
- char *disk_cache_dir;
-#endif
G_APPLICATION_CLASS (ephy_shell_parent_class)->startup (application);
/* We're not remoting; start our services */
mode = ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (application));
-#ifdef HAVE_WEBKIT2
- ephy_shell_setup_environment (EPHY_SHELL (application));
- /* Set the web extensions dir ASAP before the process is launched */
- webkit_web_context_set_web_extensions_directory (webkit_web_context_get_default (),
- EPHY_WEB_EXTENSIONS_DIR);
-
- /* Disk Cache */
- disk_cache_dir = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode) ?
- ephy_dot_dir () : g_get_user_cache_dir (),
- g_get_prgname (), NULL);
- webkit_web_context_set_disk_cache_directory (webkit_web_context_get_default (),
- disk_cache_dir);
- g_free (disk_cache_dir);
-#endif
-
- ephy_embed_prefs_init ();
-
if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION) {
GtkBuilder *builder;
@@ -299,14 +262,6 @@ ephy_shell_startup (GApplication* application)
}
static void
-ephy_shell_shutdown (GApplication* application)
-{
- G_APPLICATION_CLASS (ephy_shell_parent_class)->shutdown (application);
-
- ephy_embed_prefs_shutdown ();
-}
-
-static void
session_load_cb (GObject *object,
GAsyncResult *result,
gpointer user_data)
@@ -536,7 +491,6 @@ ephy_shell_class_init (EphyShellClass *klass)
object_class->constructed = ephy_shell_constructed;
application_class->startup = ephy_shell_startup;
- application_class->shutdown = ephy_shell_shutdown;
application_class->activate = ephy_shell_activate;
application_class->before_emit = ephy_shell_before_emit;
application_class->add_platform_data = ephy_shell_add_platform_data;