logo

badwolf

minimalist and privacy-oriented web browser based on WebKitGTK git clone https://hacktivis.me/git/badwolf.git
commit: 4df40cf5a802aca6f986c3669212b3c6b072ba5b
parent 27cf275730730674367efdd4c0f84524282b7c3d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Wed,  7 Apr 2021 16:48:28 +0200

badwolf: Inherit the WebContext when old_browser is present

Diffstat:

Mbadwolf.c29++++++++++++++++++-----------
1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/badwolf.c b/badwolf.c @@ -623,6 +623,8 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b target_url = badwolf_ensure_uri_scheme(target_url, (old_browser == NULL)); char *badwolf_l10n = NULL; + WebKitWebContext *web_context; + if(browser == NULL) return NULL; browser->window = window; @@ -666,16 +668,19 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b browser->statuslabel = gtk_label_new(NULL); gtk_widget_set_name(browser->statuslabel, "browser__statuslabel"); - WebKitWebsiteDataManager *website_data_manager = webkit_website_data_manager_new_ephemeral(); - webkit_website_data_manager_set_itp_enabled(website_data_manager, TRUE); - - WebKitWebContext *web_context = - webkit_web_context_new_with_website_data_manager(website_data_manager); - g_object_unref(website_data_manager); - webkit_web_context_set_sandbox_enabled(web_context, TRUE); - webkit_web_context_set_process_model(web_context, - WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); - webkit_web_context_set_web_extensions_directory(web_context, web_extensions_directory); + if(old_browser == NULL) { + WebKitWebsiteDataManager *website_data_manager = webkit_website_data_manager_new_ephemeral(); + webkit_website_data_manager_set_itp_enabled(website_data_manager, TRUE); + + web_context = webkit_web_context_new_with_website_data_manager(website_data_manager); + g_object_unref(website_data_manager); + webkit_web_context_set_sandbox_enabled(web_context, TRUE); + webkit_web_context_set_process_model(web_context, + WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES); + webkit_web_context_set_web_extensions_directory(web_context, web_extensions_directory); + } else { + web_context = webkit_web_view_get_context(old_browser->webView); + } badwolf_l10n = getenv("BADWOLF_L10N"); @@ -704,7 +709,9 @@ new_browser(struct Window *window, const gchar *target_url, struct Client *old_b settings, NULL)); gtk_widget_set_name(GTK_WIDGET(browser->webView), "browser__webView"); - g_object_unref(web_context); + if(old_browser == NULL) { + g_object_unref(web_context); + } g_object_unref(settings); gtk_box_pack_start(