[epiphany] Do not use the default WebKitWebContext
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Do not use the default WebKitWebContext
- Date: Tue, 25 Nov 2014 13:27:23 +0000 (UTC)
commit 3806c195d631cc55f2cef64c4be6bc733745e730
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Nov 24 11:09:12 2014 +0100
Do not use the default WebKitWebContext
Create a global WebKitWebContext in EphyEmbedShell and use it everywhere
as the default web context. This is required to provide constructor
properties to the web context.
embed/ephy-about-handler.c | 4 +-
embed/ephy-download.c | 3 +-
embed/ephy-embed-prefs.c | 12 +++-
embed/ephy-embed-shell.c | 57 +++++++++++------
embed/ephy-embed-shell.h | 1 +
embed/ephy-web-view.c | 7 ++-
lib/widgets/ephy-location-entry.c | 15 ++++-
src/Makefile.am | 2 +
src/bookmarks/ephy-bookmark-action.c | 6 +-
src/bookmarks/ephy-bookmarks.c | 6 +-
src/clear-data-dialog.c | 5 +-
src/cookies-dialog.c | 4 +-
src/ephy-completion-model.c | 3 +-
src/ephy-navigation-history-action.c | 3 +-
src/ephy-shell.c | 115 +++++++++++++++-------------------
src/window-commands.c | 3 +-
16 files changed, 141 insertions(+), 105 deletions(-)
---
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index c14f816..fcab90f 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -190,7 +190,9 @@ static gboolean
ephy_about_handler_handle_plugins (EphyAboutHandler *handler,
WebKitURISchemeRequest *request)
{
- webkit_web_context_get_plugins (webkit_web_context_get_default (),
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
+ webkit_web_context_get_plugins (ephy_embed_shell_get_web_context (shell),
NULL,
(GAsyncReadyCallback)get_plugins_cb,
ephy_about_request_new (handler, request));
diff --git a/embed/ephy-download.c b/embed/ephy-download.c
index 33c33a2..60a8111 100644
--- a/embed/ephy-download.c
+++ b/embed/ephy-download.c
@@ -863,10 +863,11 @@ ephy_download_new_for_uri (const char *uri,
{
EphyDownload *ephy_download;
WebKitDownload *download;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
g_return_val_if_fail (uri != NULL, NULL);
- download = webkit_web_context_download_uri (webkit_web_context_get_default (), uri);
+ download = webkit_web_context_download_uri (ephy_embed_shell_get_web_context (shell), uri);
ephy_download = ephy_download_new (download, parent);
g_object_unref (download);
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index dcd2b81..6d4536a 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -319,6 +319,7 @@ webkit_pref_callback_accept_languages (GSettings *settings,
GArray *array;
char **languages;
int i;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
languages = g_settings_get_strv (settings, key);
@@ -335,7 +336,7 @@ webkit_pref_callback_accept_languages (GSettings *settings,
ephy_langs_sanitise (array);
- webkit_web_context_set_preferred_languages (webkit_web_context_get_default (),
+ webkit_web_context_set_preferred_languages (ephy_embed_shell_get_web_context (shell),
(const char * const *)array->data);
g_strfreev (languages);
@@ -370,12 +371,14 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings,
{
WebKitCookieManager *cookie_manager;
char *value;
+ EphyEmbedShell *shell;
value = g_settings_get_string (settings, key);
if (!value)
return;
- cookie_manager = webkit_web_context_get_cookie_manager (webkit_web_context_get_default ());
+ shell = ephy_embed_shell_get_default ();
+ cookie_manager = webkit_web_context_get_cookie_manager (ephy_embed_shell_get_web_context (shell));
ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, value);
g_free (value);
}
@@ -446,10 +449,11 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings,
char *key,
gpointer data)
{
- WebKitWebContext *web_context = NULL;
+ WebKitWebContext *web_context;
gboolean value = FALSE;
char **languages = NULL;
char *langs = NULL;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
value = g_settings_get_boolean (settings, key);
@@ -464,7 +468,7 @@ webkit_pref_callback_enable_spell_checking (GSettings *settings,
langs = g_strjoinv (",", languages);
}
- web_context = webkit_web_context_get_default ();
+ web_context = ephy_embed_shell_get_web_context (shell);
webkit_web_context_set_spell_checking_enabled (web_context, value);
webkit_web_context_set_spell_checking_languages (web_context, (const char* const *)languages);
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index c726b23..1057733 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -50,6 +50,7 @@
struct _EphyEmbedShellPrivate
{
+ WebKitWebContext *web_context;
EphyHistoryService *global_history_service;
EphyEncodings *encodings;
GtkPageSetup *page_setup;
@@ -107,6 +108,7 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->global_history_service);
g_clear_object (&priv->about_handler);
g_clear_object (&priv->user_content);
+ g_clear_object (&priv->web_context);
G_OBJECT_CLASS (ephy_embed_shell_parent_class)->dispose (object);
}
@@ -548,8 +550,7 @@ ephy_embed_shell_setup_web_extensions_connection (EphyEmbedShell *shell)
}
static void
-ephy_embed_shell_setup_process_model (EphyEmbedShell *shell,
- WebKitWebContext *web_context)
+ephy_embed_shell_setup_process_model (EphyEmbedShell *shell)
{
EphyPrefsProcessModel process_model;
@@ -560,10 +561,12 @@ ephy_embed_shell_setup_process_model (EphyEmbedShell *shell,
switch (process_model) {
case EPHY_PREFS_PROCESS_MODEL_SHARED_SECONDARY_PROCESS:
- webkit_web_context_set_process_model (web_context, WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
+ webkit_web_context_set_process_model (shell->priv->web_context,
+ WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS);
break;
case EPHY_PREFS_PROCESS_MODEL_ONE_SECONDARY_PROCESS_PER_WEB_VIEW:
- webkit_web_context_set_process_model (web_context, WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
+ webkit_web_context_set_process_model (shell->priv->web_context,
+ WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
break;
}
}
@@ -572,9 +575,10 @@ static void
ephy_embed_shell_startup (GApplication* application)
{
EphyEmbedShell *shell = EPHY_EMBED_SHELL (application);
- EphyEmbedShellMode mode;
- char *disk_cache_dir;
- WebKitWebContext *web_context;
+ EphyEmbedShellPrivate *priv = shell->priv;
+ char *base_cache_dir;
+ char *favicon_db_path;
+ char *local_storage_path;
WebKitCookieManager *cookie_manager;
char *filename;
char *cookie_policy;
@@ -582,7 +586,7 @@ ephy_embed_shell_startup (GApplication* application)
G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application);
/* We're not remoting, setup the Web Context. */
- mode = shell->priv->mode;
+ priv->web_context = webkit_web_context_new ();
ephy_embed_shell_setup_web_extensions_connection (shell);
@@ -613,37 +617,46 @@ ephy_embed_shell_startup (GApplication* application)
G_CALLBACK (web_extension_about_apps_message_received_cb),
shell);
- web_context = webkit_web_context_get_default ();
- ephy_embed_shell_setup_process_model (shell, web_context);
- g_signal_connect (web_context, "initialize-web-extensions",
+ ephy_embed_shell_setup_process_model (shell);
+ g_signal_connect (priv->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) ?
+ base_cache_dir = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (priv->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);
+ webkit_web_context_set_disk_cache_directory (priv->web_context, base_cache_dir);
+
+ /* Favicon Database */
+ favicon_db_path = g_build_filename (base_cache_dir, "icondatabase", NULL);
+ webkit_web_context_set_favicon_database_directory (priv->web_context, favicon_db_path);
+ g_free (favicon_db_path);
+
+ g_free (base_cache_dir);
+
+ /* Do not ignore TLS errors. */
+ webkit_web_context_set_tls_errors_policy (priv->web_context, WEBKIT_TLS_ERRORS_POLICY_FAIL);
+
/* about: URIs handler */
shell->priv->about_handler = ephy_about_handler_new ();
- webkit_web_context_register_uri_scheme (web_context,
+ webkit_web_context_register_uri_scheme (priv->web_context,
EPHY_ABOUT_SCHEME,
(WebKitURISchemeRequestCallback)about_request_cb,
shell, NULL);
/* Register about scheme as local so that it can contain file resources */
- webkit_security_manager_register_uri_scheme_as_local (webkit_web_context_get_security_manager
(web_context),
+ webkit_security_manager_register_uri_scheme_as_local (webkit_web_context_get_security_manager
(priv->web_context),
EPHY_ABOUT_SCHEME);
/* ephy-resource handler */
- webkit_web_context_register_uri_scheme (web_context, "ephy-resource",
+ webkit_web_context_register_uri_scheme (priv->web_context, "ephy-resource",
(WebKitURISchemeRequestCallback)ephy_resource_request_cb,
NULL, NULL);
/* Store cookies in moz-compatible SQLite format */
- cookie_manager = webkit_web_context_get_cookie_manager (web_context);
+ cookie_manager = webkit_web_context_get_cookie_manager (priv->web_context);
filename = g_build_filename (ephy_dot_dir (), "cookies.sqlite", NULL);
webkit_cookie_manager_set_persistent_storage (cookie_manager, filename,
WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
@@ -1065,7 +1078,7 @@ ephy_embed_shell_launch_handler (EphyEmbedShell *shell,
void
ephy_embed_shell_clear_cache (EphyEmbedShell *shell)
{
- webkit_web_context_clear_cache (webkit_web_context_get_default ());
+ webkit_web_context_clear_cache (shell->priv->web_context);
}
WebKitUserContentManager *
@@ -1073,3 +1086,9 @@ ephy_embed_shell_get_user_content_manager (EphyEmbedShell *shell)
{
return shell->priv->user_content;
}
+
+WebKitWebContext *
+ephy_embed_shell_get_web_context (EphyEmbedShell *shell)
+{
+ return shell->priv->web_context;
+}
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index e536c61..e9734a2 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -73,6 +73,7 @@ struct _EphyEmbedShellClass
GType ephy_embed_shell_get_type (void);
EphyEmbedShell *ephy_embed_shell_get_default (void);
+WebKitWebContext *ephy_embed_shell_get_web_context (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_global_history_service (EphyEmbedShell *shell);
GObject *ephy_embed_shell_get_encodings (EphyEmbedShell *shell);
void ephy_embed_shell_prepare_close (EphyEmbedShell *shell);
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 615b786..61dcd08 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -713,7 +713,7 @@ allow_tls_certificate_cb (EphyEmbedShell *shell,
g_return_if_fail (priv->tls_error_failing_uri != NULL);
uri = soup_uri_new (priv->tls_error_failing_uri);
- webkit_web_context_allow_tls_certificate_for_host (webkit_web_context_get_default (),
+ webkit_web_context_allow_tls_certificate_for_host (ephy_embed_shell_get_web_context (shell),
priv->certificate,
uri->host);
ephy_web_view_load_url (web_view, ephy_web_view_get_address (web_view));
@@ -2180,8 +2180,11 @@ ephy_web_view_init (EphyWebView *web_view)
GtkWidget *
ephy_web_view_new (void)
{
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+
return g_object_new (EPHY_TYPE_WEB_VIEW,
- "user-content-manager", ephy_embed_shell_get_user_content_manager
(ephy_embed_shell_get_default ()),
+ "web-context", ephy_embed_shell_get_web_context (shell),
+ "user-content-manager", ephy_embed_shell_get_user_content_manager (shell),
"settings", ephy_embed_prefs_get_settings (),
NULL);
}
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 412f782..4d3ad89 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -32,12 +32,15 @@
#include "ephy-lib-type-builtins.h"
#include "ephy-signal-accumulator.h"
-#include <libsoup/soup.h>
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <string.h>
+#if 0
+/* FIXME: Refactor the DNS prefetch, this is a layering violation */
+#include <libsoup/soup.h>
#include <webkit2/webkit2.h>
+#endif
/**
* SECTION:ephy-location-entry
@@ -957,6 +960,8 @@ ephy_location_entry_new (void)
return GTK_WIDGET (g_object_new (EPHY_TYPE_LOCATION_ENTRY, NULL));
}
+#if 0
+/* FIXME: Refactor the DNS prefetch, this is a layering violation */
typedef struct {
SoupURI *uri;
EphyLocationEntry *entry;
@@ -973,10 +978,10 @@ free_prefetch_helper (PrefetchHelper *helper)
static gboolean
do_dns_prefetch (PrefetchHelper *helper)
{
- WebKitWebContext *context = webkit_web_context_get_default ();
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
if (helper->uri)
- webkit_web_context_prefetch_dns (context, helper->uri->host);
+ webkit_web_context_prefetch_dns (ephy_embed_shell_get_web_context (shell), helper->uri->host);
helper->entry->priv->dns_prefetch_handler = 0;
@@ -1008,6 +1013,7 @@ schedule_dns_prefetch (EphyLocationEntry *entry, guint interval, const gchar *ur
(GDestroyNotify) free_prefetch_helper);
g_source_set_name_by_id (entry->priv->dns_prefetch_handler, "[epiphany] do_dns_prefetch");
}
+#endif
static gboolean
cursor_on_match_cb (GtkEntryCompletion *completion,
@@ -1031,7 +1037,10 @@ cursor_on_match_cb (GtkEntryCompletion *completion,
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
le->priv->block_update = FALSE;
+#if 0
+/* FIXME: Refactor the DNS prefetch, this is a layering violation */
schedule_dns_prefetch (le, 250, (const gchar*) url);
+#endif
g_free (url);
diff --git a/src/Makefile.am b/src/Makefile.am
index 6faebf4..5e48363 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -194,6 +194,8 @@ epiphany_search_provider_CFLAGS = $(epiphany_CFLAGS)
epiphany_search_provider_LDADD = \
libephymain.la \
$(top_builddir)/src/bookmarks/libephybookmarks.la \
+ $(top_builddir)/embed/libephyembed.la \
+ $(top_builddir)/lib/widgets/libephywidgets.la \
$(top_builddir)/lib/history/libephyhistory.la \
$(top_builddir)/lib/libephymisc.la \
$(DEPENDENCIES_LIBS) \
diff --git a/src/bookmarks/ephy-bookmark-action.c b/src/bookmarks/ephy-bookmark-action.c
index fb8b55f..cbe6ca2 100644
--- a/src/bookmarks/ephy-bookmark-action.c
+++ b/src/bookmarks/ephy-bookmark-action.c
@@ -128,13 +128,14 @@ ephy_bookmark_action_sync_icon (GtkAction *action,
EphyBookmarkAction *bma = EPHY_BOOKMARK_ACTION (action);
const char *page_location;
WebKitFaviconDatabase *database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
g_return_if_fail (bma->priv->node != NULL);
page_location = ephy_node_get_property_string (bma->priv->node,
EPHY_NODE_BMK_PROP_LOCATION);
- database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
if (page_location && *page_location)
{
@@ -387,9 +388,10 @@ ephy_bookmark_action_dispose (GObject *object)
if (priv->cache_handler != 0)
{
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
WebKitFaviconDatabase *database;
- database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context
(shell));
g_signal_handler_disconnect (database, priv->cache_handler);
priv->cache_handler = 0;
}
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 5cd0d1e..ac9c65c 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -245,8 +245,9 @@ static void
ephy_setup_history_notifiers (EphyBookmarks *eb)
{
WebKitFaviconDatabase *favicon_database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- favicon_database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
g_signal_connect (favicon_database, "favicon-changed",
G_CALLBACK (icon_updated_cb), eb);
}
@@ -1135,6 +1136,7 @@ ephy_bookmarks_add (EphyBookmarks *eb,
{
EphyNode *bm;
WebKitFaviconDatabase *favicon_database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
bm = ephy_node_new (eb->priv->db);
@@ -1149,7 +1151,7 @@ ephy_bookmarks_add (EphyBookmarks *eb,
}
ephy_node_set_property_string (bm, EPHY_NODE_BMK_PROP_TITLE, title);
- favicon_database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ favicon_database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
if (favicon_database != NULL)
{
char *icon = webkit_favicon_database_get_favicon_uri (favicon_database, url);
diff --git a/src/clear-data-dialog.c b/src/clear-data-dialog.c
index 5436e45..cad5b4b 100644
--- a/src/clear-data-dialog.c
+++ b/src/clear-data-dialog.c
@@ -66,8 +66,9 @@ static WebKitCookieManager *
get_cookie_manager (void)
{
WebKitWebContext *web_context;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- web_context = webkit_web_context_get_default ();
+ web_context = ephy_embed_shell_get_web_context (shell);;
return webkit_web_context_get_cookie_manager (web_context);
}
@@ -126,7 +127,7 @@ clear_data_dialog_response_cb (GtkDialog *widget,
ephy_embed_shell_clear_cache (shell);
- database = webkit_web_context_get_favicon_database (webkit_web_context_get_default
());
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context
(shell));
webkit_favicon_database_clear (database);
}
}
diff --git a/src/cookies-dialog.c b/src/cookies-dialog.c
index f0cf1fc..9f2a395 100644
--- a/src/cookies-dialog.c
+++ b/src/cookies-dialog.c
@@ -28,6 +28,7 @@
#include <webkit2/webkit2.h>
#include "ephy-string.h"
+#include "ephy-shell.h"
#include "cookies-dialog.h"
@@ -381,11 +382,12 @@ static void
cookies_dialog_init (CookiesDialog *dialog)
{
WebKitWebContext *web_context;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
dialog->priv = cookies_dialog_get_instance_private (dialog);
gtk_widget_init_template (GTK_WIDGET (dialog));
- web_context = webkit_web_context_get_default ();
+ web_context = ephy_embed_shell_get_web_context (shell);
dialog->priv->cookie_manager = webkit_web_context_get_cookie_manager (web_context);
setup_page (dialog);
diff --git a/src/ephy-completion-model.c b/src/ephy-completion-model.c
index 46f20dc..f2a8854 100644
--- a/src/ephy-completion-model.c
+++ b/src/ephy-completion-model.c
@@ -240,8 +240,9 @@ set_row_in_model (EphyCompletionModel *model, int position, PotentialRow *row)
GtkTreePath *path;
IconLoadData *data;
WebKitFaviconDatabase* database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
gtk_list_store_insert_with_values (GTK_LIST_STORE (model), &iter, position,
EPHY_COMPLETION_TEXT_COL, row->title ? row->title : "",
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index 2028053..38de783 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -275,6 +275,7 @@ new_history_menu_item (EphyWebView *view,
GtkWidget *item;
GtkLabel *label;
WebKitFaviconDatabase* database;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
g_return_val_if_fail (address != NULL && origtext != NULL, NULL);
@@ -284,7 +285,7 @@ new_history_menu_item (EphyWebView *view,
gtk_label_set_ellipsize (label, PANGO_ELLIPSIZE_END);
gtk_label_set_max_width_chars (label, MAX_LABEL_LENGTH);
- database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
+ database = webkit_web_context_get_favicon_database (ephy_embed_shell_get_web_context (shell));
webkit_favicon_database_get_favicon (database, address,
NULL,
(GAsyncReadyCallback)icon_loaded_cb,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 374510a..3f1ad72 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -256,14 +256,63 @@ static GActionEntry app_normal_mode_entries[] = {
};
static void
+download_started_cb (WebKitWebContext *web_context,
+ WebKitDownload *download,
+ EphyShell *shell)
+{
+ GtkWindow *window = NULL;
+ WebKitWebView *web_view;
+ EphyDownload *ephy_download;
+ gboolean ephy_download_set;
+
+ /* Is download locked down? */
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK)) {
+ webkit_download_cancel (download);
+ return;
+ }
+
+ /* Only create an EphyDownload for the WebKitDownload if it doesn't exist yet.
+ * This can happen when the download has been started automatically by WebKit,
+ * due to a context menu action or policy checker decision. Downloads started
+ * explicitly by Epiphany are marked with ephy-download-set GObject data.
+ */
+ ephy_download_set = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (download), "ephy-download-set"));
+ if (ephy_download_set)
+ return;
+
+ web_view = webkit_download_get_web_view (download);
+ if (web_view) {
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
+ if (GTK_IS_WINDOW (toplevel))
+ window = GTK_WINDOW (toplevel);
+ }
+
+ if (!window)
+ window = gtk_application_get_active_window (GTK_APPLICATION (shell));
+
+ ephy_download = ephy_download_new (download, window);
+ ephy_window_add_download (EPHY_WINDOW (window), ephy_download);
+ g_object_unref (ephy_download);
+}
+
+static void
ephy_shell_startup (GApplication* application)
{
+ EphyEmbedShell *embed_shell = EPHY_EMBED_SHELL (application);
EphyEmbedShellMode mode;
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));
+ g_signal_connect (ephy_embed_shell_get_web_context (embed_shell),
+ "download-started",
+ G_CALLBACK (download_started_cb),
+ application);
+
+ mode = ephy_embed_shell_get_mode (embed_shell);
if (mode != EPHY_EMBED_SHELL_MODE_APPLICATION) {
GtkBuilder *builder;
@@ -519,55 +568,9 @@ ephy_shell_class_init (EphyShellClass *klass)
}
static void
-download_started_cb (WebKitWebContext *web_context,
- WebKitDownload *download,
- EphyShell *shell)
-{
- GtkWindow *window = NULL;
- WebKitWebView *web_view;
- EphyDownload *ephy_download;
- gboolean ephy_download_set;
-
- /* Is download locked down? */
- if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
- EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK)) {
- webkit_download_cancel (download);
- return;
- }
-
- /* Only create an EphyDownload for the WebKitDownload if it doesn't exist yet.
- * This can happen when the download has been started automatically by WebKit,
- * due to a context menu action or policy checker decision. Downloads started
- * explicitly by Epiphany are marked with ephy-download-set GObject data.
- */
- ephy_download_set = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (download), "ephy-download-set"));
- if (ephy_download_set)
- return;
-
- web_view = webkit_download_get_web_view (download);
- if (web_view) {
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (web_view));
- if (GTK_IS_WINDOW (toplevel))
- window = GTK_WINDOW (toplevel);
- }
-
- if (!window)
- window = gtk_application_get_active_window (GTK_APPLICATION (shell));
-
- ephy_download = ephy_download_new (download, window);
- ephy_window_add_download (EPHY_WINDOW (window), ephy_download);
- g_object_unref (ephy_download);
-}
-
-static void
ephy_shell_init (EphyShell *shell)
{
EphyShell **ptr = &ephy_shell;
- WebKitWebContext *web_context;
- EphyEmbedShellMode mode;
- char *favicon_db_path;
shell->priv = EPHY_SHELL_GET_PRIVATE (shell);
@@ -576,24 +579,6 @@ ephy_shell_init (EphyShell *shell)
ephy_shell = shell;
g_object_add_weak_pointer (G_OBJECT (ephy_shell),
(gpointer *)ptr);
-
- web_context = webkit_web_context_get_default ();
- g_signal_connect (web_context, "download-started",
- G_CALLBACK (download_started_cb),
- shell);
-
- /* Do not ignore TLS errors. */
- webkit_web_context_set_tls_errors_policy (web_context, WEBKIT_TLS_ERRORS_POLICY_FAIL);
-
- /* Initialize the favicon cache as early as possible, or further
- calls to webkit_web_context_get_favicon_database will fail. */
- mode = ephy_embed_shell_get_mode (ephy_embed_shell_get_default ());
- favicon_db_path = g_build_filename (EPHY_EMBED_SHELL_MODE_HAS_PRIVATE_PROFILE (mode) ?
- ephy_dot_dir () : g_get_user_cache_dir (),
- g_get_prgname (), "icondatabase", NULL);
-
- webkit_web_context_set_favicon_database_directory (web_context, favicon_db_path);
- g_free (favicon_db_path);
}
static void
diff --git a/src/window-commands.c b/src/window-commands.c
index 603d57f..43c6a4e 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -546,8 +546,9 @@ download_icon_and_set_image (EphyApplicationDialogData *data)
{
WebKitDownload *download;
char *destination, *destination_uri, *tmp_filename;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- download = webkit_web_context_download_uri (webkit_web_context_get_default (),
+ download = webkit_web_context_download_uri (ephy_embed_shell_get_web_context (shell),
data->icon_href);
/* We do not want this download to show up in the UI, so let's
* set 'ephy-download-set' to make Epiphany think this is
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]