Commit aaf6422a authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos

web-extension: Use initialize-web-extensions signal to pass user data to the web extension

Instead of using environment variables.

https://bugzilla.gnome.org/show_bug.cgi?id=723087
parent 84300034
......@@ -69,7 +69,7 @@ GLIB_REQUIRED=2.35.6
GTK_REQUIRED=3.11.4
LIBXML_REQUIRED=2.6.12
LIBXSLT_REQUIRED=1.1.7
WEBKIT_GTK_REQUIRED=2.3.4
WEBKIT_GTK_REQUIRED=2.3.5
LIBSOUP_REQUIRED=2.42.1
GNOME_DESKTOP_REQUIRED=2.91.2
LIBSECRET_REQUIRED=0.14
......
......@@ -292,24 +292,25 @@ ephy_embed_shell_restored_window (EphyEmbedShell *shell)
}
static void
ephy_embed_shell_setup_environment (EphyEmbedShell *shell)
about_request_cb (WebKitURISchemeRequest *request,
EphyEmbedShell *shell)
{
EphyEmbedShellMode mode = shell->priv->mode;
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);
ephy_about_handler_handle_request (shell->priv->about_handler, request);
}
static void
about_request_cb (WebKitURISchemeRequest *request,
EphyEmbedShell *shell)
initialize_web_extensions (WebKitWebContext* web_context,
EphyEmbedShell *shell)
{
ephy_about_handler_handle_request (shell->priv->about_handler, request);
GVariant *user_data;
gboolean private_profile;
webkit_web_context_set_web_extensions_directory (web_context, EPHY_WEB_EXTENSIONS_DIR);
ephy_embed_shell_watch_web_extension (shell);
private_profile = EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (shell->priv->mode);
user_data = g_variant_new ("(usb)", getpid (), ephy_dot_dir (), private_profile);
webkit_web_context_set_web_extensions_initialization_user_data (web_context, user_data);
}
static void
......@@ -328,12 +329,9 @@ ephy_embed_shell_startup (GApplication* application)
/* We're not remoting, setup the Web Context. */
mode = shell->priv->mode;
web_context = webkit_web_context_get_default ();
ephy_embed_shell_setup_environment (shell);
/* 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);
g_signal_connect (web_context, "initialize-web-extensions",
G_CALLBACK (initialize_web_extensions),
shell);
/* Disk Cache */
disk_cache_dir = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode) ?
......
......@@ -1094,20 +1094,26 @@ bus_acquired_cb (GDBusConnection *connection,
}
G_MODULE_EXPORT void
webkit_web_extension_initialize (WebKitWebExtension *extension)
webkit_web_extension_initialize_with_user_data (WebKitWebExtension *extension,
GVariant *user_data)
{
char *service_name;
guint extension_id;
const char *dot_dir;
gboolean private_profile;
g_variant_get (user_data, "(u&sb)", &extension_id, &dot_dir, &private_profile);
ephy_debug_init ();
uri_tester = uri_tester_new (g_getenv ("EPHY_DOT_DIR"));
if (!g_getenv ("EPHY_PRIVATE_PROFILE"))
uri_tester = uri_tester_new (dot_dir);
if (!private_profile)
form_auth_data_cache = ephy_form_auth_data_cache_new ();
g_signal_connect (extension, "page-created",
G_CALLBACK (web_page_created_callback),
NULL);
service_name = g_strdup_printf ("%s-%s", EPHY_WEB_EXTENSION_SERVICE_NAME, g_getenv ("EPHY_WEB_EXTENSION_ID"));
service_name = g_strdup_printf ("%s-%u", EPHY_WEB_EXTENSION_SERVICE_NAME, extension_id);
g_bus_own_name (G_BUS_TYPE_SESSION,
service_name,
G_BUS_NAME_OWNER_FLAGS_NONE,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment