From 95afb316ab196d09ef68d79d4a74223636906246 Mon Sep 17 00:00:00 2001 From: ugla Date: Tue, 14 Dec 2021 23:00:35 +0100 Subject: Add option for WebKit Intelligent Tracking Prevention --- doc/neovimb.1 | 3 +++ src/setting.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/doc/neovimb.1 b/doc/neovimb.1 index 3ccc58f..bf7975f 100644 --- a/doc/neovimb.1 +++ b/doc/neovimb.1 @@ -1347,6 +1347,9 @@ CSS style applied to the inputbox in normal state. .B input-error-css (string) CSS style applied to the inputbox in case of displayed error. .TP +.B intelligent-tracking-prevention (bool) +Whether WebKit's Intelligent Tracking Prevention (ITP) is enabled. +.TP .B javascript-can-access-clipboard (bool) Whether JavaScript can access the clipboard. .TP diff --git a/src/setting.c b/src/setting.c index b347e9b..12d7704 100644 --- a/src/setting.c +++ b/src/setting.c @@ -61,6 +61,7 @@ static int input_autohide(Client *c, const char *name, DataType type, void *valu static int internal(Client *c, const char *name, DataType type, void *value, void *data); static int notification(Client *c, const char *name, DataType type, void *value, void *data); static int headers(Client *c, const char *name, DataType type, void *value, void *data); +static int intelligent_tracking_prevention(Client *c, const char *name, DataType type, void *value, void *data); static int user_scripts(Client *c, const char *name, DataType type, void *value, void *data); static int user_style(Client *c, const char *name, DataType type, void *value, void *data); static int statusbar(Client *c, const char *name, DataType type, void *value, void *data); @@ -107,6 +108,7 @@ void setting_init(Client *c) setting_add(c, "html5-local-storage", TYPE_BOOLEAN, &on, webkit, 0, "enable-html5-local-storage"); setting_add(c, "hyperlink-auditing", TYPE_BOOLEAN, &off, webkit, 0, "enable-hyperlink-auditing"); setting_add(c, "images", TYPE_BOOLEAN, &on, webkit, 0, "auto-load-images"); + setting_add(c, "intelligent-tracking-prevention", TYPE_BOOLEAN, &off, intelligent_tracking_prevention, 0, NULL); setting_add(c, "javascript-can-access-clipboard", TYPE_BOOLEAN, &off, webkit, 0, "javascript-can-access-clipboard"); setting_add(c, "javascript-can-open-windows-automatically", TYPE_BOOLEAN, &off, webkit, 0, "javascript-can-open-windows-automatically"); #if WEBKIT_CHECK_VERSION(2, 24, 0) @@ -566,6 +568,14 @@ static int geolocation(Client *c, const char *name, DataType type, void *value, return CMD_SUCCESS; } +static int intelligent_tracking_prevention(Client *c, const char *name, DataType type, void *value, void *data) +{ + WebKitWebContext *ctx = webkit_web_view_get_context(c->webview); + WebKitWebsiteDataManager *manager = webkit_web_context_get_website_data_manager(ctx); + webkit_website_data_manager_set_itp_enabled(manager, *(gboolean*)value); + return CMD_SUCCESS; +} + /* This needs to be called before the window is shown for the best chance of * success, but it may be called at any time. * Currently the setting file is read after the window has been shown, which -- cgit v1.2.3