[epiphany] Initial support for intelligent tracking prevention
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Initial support for intelligent tracking prevention
- Date: Mon, 15 Jan 2018 23:46:44 +0000 (UTC)
commit d4a25d10dd0a4ee627ed024fe874c39b1f11f1d3
Author: Michael Catanzaro <mcatanzaro igalia com>
Date: Mon Jan 15 16:41:22 2018 -0600
Initial support for intelligent tracking prevention
Enabled by default, of course.
We might want to drop the vanilla third-party policy, but let's start
with this for now.
Concern: there's not currently any way to clear the resource load
statistics directory....
data/org.gnome.epiphany.gschema.xml | 4 ++--
embed/ephy-embed-prefs.c | 12 ++++++++++--
lib/ephy-prefs.h | 3 ++-
src/prefs-dialog.c | 15 +++++++++++++++
src/resources/gtk/prefs-dialog.ui | 12 ++++--------
5 files changed, 33 insertions(+), 13 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 981968d..cfc0898 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -169,9 +169,9 @@
<description>Preferred languages. Array of locale codes or “system” to use current
locale.</description>
</key>
<key name="cookies-policy" enum="org.gnome.Epiphany.EphyPrefsWebCookiesPolicy">
- <default>'no-third-party'</default>
+ <default>'intelligent-tracking-prevention'</default>
<summary>Cookie accept</summary>
- <description>Where to accept cookies from. Possible values are “always”,
“no-third-party” and “never”.</description>
+ <description>Where to accept cookies from. Possible values are “always”,
“no-third-party”, “intelligent-tracking-prevention”, and “never”.</description>
</key>
<key type="b" name="enable-popups">
<default>true</default>
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 0ce447f..0b5d19a 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -275,20 +275,28 @@ void
ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
const char *settings_policy)
{
+ EphyEmbedShell *shell;
+ WebKitWebContext *context;
+ WebKitWebsiteDataManager *manager;
WebKitCookieAcceptPolicy policy;
if (!strcmp (settings_policy, "never"))
policy = WEBKIT_COOKIE_POLICY_ACCEPT_NEVER;
else if (!strcmp (settings_policy, "always"))
policy = WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS;
- else if (!strcmp (settings_policy, "no-third-party"))
+ else if (!strcmp (settings_policy, "no-third-party") || !strcmp (settings_policy,
"intelligent-tracking-prevention"))
policy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY;
else {
g_warn_if_reached ();
return;
}
-
webkit_cookie_manager_set_accept_policy (cookie_manager, policy);
+
+ shell = ephy_embed_shell_get_default ();
+ context = ephy_embed_shell_get_web_context (shell);
+ manager = webkit_web_context_get_website_data_manager (context);
+ webkit_website_data_manager_set_resource_load_statistics_enabled (manager,
+ !strcmp (settings_policy,
"intelligent-tracking-prevention"));
}
static void
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 3f35920..79fc17b 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -49,7 +49,8 @@ typedef enum
{
EPHY_PREFS_WEB_COOKIES_POLICY_ALWAYS,
EPHY_PREFS_WEB_COOKIES_POLICY_NO_THIRD_PARTY,
- EPHY_PREFS_WEB_COOKIES_POLICY_NEVER
+ EPHY_PREFS_WEB_COOKIES_POLICY_NEVER,
+ EPHY_PREFS_WEB_COOKIES_POLICY_INTELLIGENT_TRACKING_PREVENTION
} EphyPrefsWebCookiesPolicy;
typedef enum
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 1c9913f..0bc9af3 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -97,6 +97,7 @@ struct _PrefsDialog {
/* stored data */
GtkWidget *always;
GtkWidget *no_third_party;
+ GtkWidget *intelligent_tracking_prevention;
GtkWidget *never;
GtkWidget *remember_passwords_checkbutton;
GtkWidget *do_not_track_checkbutton;
@@ -753,6 +754,7 @@ prefs_dialog_class_init (PrefsDialogClass *klass)
/* stored data */
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, always);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, no_third_party);
+ gtk_widget_class_bind_template_child (widget_class, PrefsDialog, intelligent_tracking_prevention);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, never);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, remember_passwords_checkbutton);
gtk_widget_class_bind_template_child (widget_class, PrefsDialog, do_not_track_checkbutton);
@@ -1486,6 +1488,8 @@ cookies_get_mapping (GValue *value,
if (g_strcmp0 (name, "no_third_party") == 0)
name = "no-third-party";
+ else if (g_strcmp0 (name, "intelligent_tracking_prevention") == 0)
+ name = "intelligent-tracking-prevention";
/* If the button name matches the setting, it should be active. */
if (g_strcmp0 (name, setting) == 0)
@@ -1509,6 +1513,8 @@ cookies_set_mapping (const GValue *value,
name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
if (g_strcmp0 (name, "no_third_party") == 0)
variant = g_variant_new_string ("no-third-party");
+ else if (g_strcmp0 (name, "intelligent_tracking_prevention") == 0)
+ variant = g_variant_new_string ("intelligent-tracking-prevention");
else
variant = g_variant_new_string (name);
@@ -1843,6 +1849,15 @@ setup_stored_data_page (PrefsDialog *dialog)
NULL);
g_settings_bind_with_mapping (web_settings,
EPHY_PREFS_WEB_COOKIES_POLICY,
+ dialog->intelligent_tracking_prevention,
+ "active",
+ G_SETTINGS_BIND_DEFAULT,
+ cookies_get_mapping,
+ cookies_set_mapping,
+ dialog->intelligent_tracking_prevention,
+ NULL);
+ g_settings_bind_with_mapping (web_settings,
+ EPHY_PREFS_WEB_COOKIES_POLICY,
dialog->never,
"active",
G_SETTINGS_BIND_DEFAULT,
diff --git a/src/resources/gtk/prefs-dialog.ui b/src/resources/gtk/prefs-dialog.ui
index e258499..b4118d3 100644
--- a/src/resources/gtk/prefs-dialog.ui
+++ b/src/resources/gtk/prefs-dialog.ui
@@ -526,15 +526,11 @@
</object>
</child>
<child>
- <object class="GtkLabel">
+ <object class="GtkRadioButton" id="intelligent_tracking_prevention">
+ <property name="label" translatable="yes">Use _intelligent tracking
prevention</property>
<property name="visible">True</property>
- <property name="halign">start</property>
- <property name="label" translatable="yes" comments="Refers to "Only from
sites you visit" option under Cookies.">For example, not from advertisers on these sites</property>
- <property name="use-markup">True</property>
- <property name="margin-start">22</property>
- <attributes>
- <attribute name="scale" value="0.8"/>
- </attributes>
+ <property name="use-underline">True</property>
+ <property name="group">always</property>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]