summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/web-settings.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/web-settings.c b/src/web-settings.c
index 0820f8d..7e3c713 100644
--- a/src/web-settings.c
+++ b/src/web-settings.c
@@ -229,6 +229,28 @@ wkwc_preferred_languages_cb(MqConfig *config, const gchar *name,
}
static void
+wkcm_accept_policy_cb(MqConfig __attribute__((unused)) *config,
+ const gchar __attribute__((unused)) *name, const gchar *value,
+ WebKitCookieManager *wk_cookie_manager)
+{
+ if (g_strcmp0(value, "always") == 0) {
+ webkit_cookie_manager_set_accept_policy(wk_cookie_manager,
+ WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS);
+ } else if (g_strcmp0(value, "never") == 0) {
+ webkit_cookie_manager_set_accept_policy(wk_cookie_manager,
+ WEBKIT_COOKIE_POLICY_ACCEPT_NEVER);
+ } else if (g_strcmp0(value, "never") == 0) {
+ webkit_cookie_manager_set_accept_policy(wk_cookie_manager,
+ WEBKIT_COOKIE_POLICY_ACCEPT_NEVER);
+ } else if (g_strcmp0(value, "no-third-party") == 0) {
+ webkit_cookie_manager_set_accept_policy(wk_cookie_manager,
+ WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY);
+ } else {
+ g_assert_not_reached();
+ }
+}
+
+static void
init_mappings_table(void)
{
gsize i;
@@ -250,7 +272,11 @@ void
mq_web_settings_connect(MqConfig *config, WebKitSettings *wk_settings,
WebKitWebContext *wk_web_context)
{
- gsize i;
+ gsize i;
+ WebKitCookieManager *wk_cookie_manager;
+
+ wk_cookie_manager = webkit_web_context_get_cookie_manager(
+ wk_web_context);
init_mappings_table();
@@ -317,4 +343,12 @@ mq_web_settings_connect(MqConfig *config, WebKitSettings *wk_settings,
wk_web_context);
wkwc_preferred_languages_cb(config, "intl.accept-languages", NULL,
wk_web_context);
+
+ /* Security and Privacy -> Cookies */
+ mq_config_notify_string(config, "cookies.accept",
+ (MqConfigStringCallback) wkcm_accept_policy_cb,
+ wk_cookie_manager);
+ wkcm_accept_policy_cb(config, "cookies.accept",
+ mq_config_get_string(config, "cookies.accept"),
+ wk_cookie_manager);
}