aboutsummaryrefslogtreecommitdiffstats
path: root/src/ephy-shell.c
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2013-03-20 02:02:12 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2013-03-20 22:50:07 +0800
commitf65b0e0ef8322139d230c0b5ba60e569ee1f390c (patch)
tree9a3a884801a0449aa02b31dfa91b700681a98626 /src/ephy-shell.c
parent8ffda1baa20998c9a1b8be29a3900f5941fb2601 (diff)
downloadgsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar.gz
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar.bz2
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar.lz
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar.xz
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.tar.zst
gsoc2013-epiphany-f65b0e0ef8322139d230c0b5ba60e569ee1f390c.zip
Move code to initialize preferences from ephy-main to ephy-shell
As well as the code the prepare the environment for the wen process and web context initialization. This allows to only run that initializations only for the primary instance. It fixes a crash in web process when the ui process finishes too early and makes secondary instances to run faster, since they don't spawn a web process anymore. https://bugzilla.gnome.org/show_bug.cgi?id=696020
Diffstat (limited to 'src/ephy-shell.c')
-rw-r--r--src/ephy-shell.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 3d8fc523f..252a4cbaf 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -30,6 +30,7 @@
#include "ephy-bookmarks-import.h"
#include "ephy-debug.h"
#include "ephy-embed-container.h"
+#include "ephy-embed-prefs.h"
#include "ephy-embed-single.h"
#include "ephy-embed-utils.h"
#include "ephy-file-helpers.h"
@@ -226,16 +227,52 @@ 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;
@@ -266,6 +303,14 @@ 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)
@@ -500,6 +545,7 @@ 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;