[epiphany] Enable EasyPrivacy filtering by default



commit 009216dc3287b65eb0e7ab82c8560c0dbbb6e830
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Jan 22 17:06:50 2017 -0600

    Enable EasyPrivacy filtering by default
    
    For now, you can disable or enable the filtering using the existing DNT
    setting, which has been renamed to reflect that it controls more than
    just DNT headers. Note that the underlying gsetting is different,
    though.

 data/org.gnome.epiphany.gschema.xml |    4 ++--
 lib/ephy-uri-tester-shared.h        |    1 +
 src/prefs-dialog.c                  |   24 ++++++++++++++++++++++++
 src/resources/gtk/prefs-dialog.ui   |    2 +-
 4 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 1c5f291..16c0b0e 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -178,7 +178,7 @@
                <key type="b" name="do-not-track">
                        <default>true</default>
                        <summary>Do Not Track</summary>
-                       <description>Whether to tell websites that we do not wish to be tracked. Please note 
that web pages are not forced to follow this setting.</description>
+                       <description>Enables DNT headers and tracking query parameter removal. Note that when 
changing this setting from the preferences dialog, the adblock-filters setting will additionally be updated 
to add/remove EasyPrivacy filters.</description>
                </key>
                <key type="b" name="enable-adblock">
                        <default>true</default>
@@ -186,7 +186,7 @@
                        <description>Whether to block the embedded advertisements that web pages might want 
to show.</description>
                </key>
                 <key type="as" name="adblock-filters">
-                        <default>['https://easylist.to/easylist/easylist.txt']</default>
+                        <default>['https://easylist.to/easylist/easylist.txt', 
'https://easylist.to/easylist/easyprivacy.txt']</default>
                         <summary>List of adblock filters</summary>
                         <description>List of URLs with filter rules to be used by the adblock.</description>
                 </key>
diff --git a/lib/ephy-uri-tester-shared.h b/lib/ephy-uri-tester-shared.h
index 345f62e..038417d 100644
--- a/lib/ephy-uri-tester-shared.h
+++ b/lib/ephy-uri-tester-shared.h
@@ -25,6 +25,7 @@
 G_BEGIN_DECLS
 
 #define ADBLOCK_DEFAULT_FILTER_URL "https://easylist.to/easylist/easylist.txt";
+#define ADBLOCK_PRIVACY_FILTER_URL "https://easylist.to/easylist/easyprivacy.txt";
 
 GFile *ephy_uri_tester_get_adblock_filter_file (const char *adblock_data_dir,
                                                 const char *filter_url);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index d5ae902..8faace6 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -36,6 +36,8 @@
 #include "ephy-session.h"
 #include "ephy-settings.h"
 #include "ephy-shell.h"
+#include "ephy-string.h"
+#include "ephy-uri-tester-shared.h"
 #include "clear-data-dialog.h"
 #include "cookies-dialog.h"
 #include "languages.h"
@@ -1265,6 +1267,24 @@ prefs_dialog_response_cb (GtkDialog *widget,
 }
 
 static void
+do_not_track_button_clicked_cb (GtkWidget   *button,
+                                PrefsDialog *dialog)
+{
+  char **filters;
+  char **new_filters;
+
+  filters = g_settings_get_strv (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ADBLOCK_FILTERS);
+  if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
+    new_filters = ephy_strv_append ((const char * const *)filters, ADBLOCK_PRIVACY_FILTER_URL);
+  else
+    new_filters = ephy_strv_remove ((const char * const *)filters, ADBLOCK_PRIVACY_FILTER_URL);
+  g_settings_set_strv (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ADBLOCK_FILTERS, (const char * const *)new_filters);
+
+  g_strfreev (filters);
+  g_strfreev (new_filters);
+}
+
+static void
 clear_personal_data_button_clicked_cb (GtkWidget   *button,
                                        PrefsDialog *dialog)
 {
@@ -1732,6 +1752,10 @@ setup_privacy_page (PrefsDialog *dialog)
                    dialog->do_not_track_checkbutton,
                    "active",
                    G_SETTINGS_BIND_DEFAULT);
+  g_signal_connect (dialog->do_not_track_checkbutton,
+                    "clicked",
+                    G_CALLBACK (do_not_track_button_clicked_cb),
+                    dialog);
 
   g_signal_connect (dialog->clear_personal_data_button,
                     "clicked",
diff --git a/src/resources/gtk/prefs-dialog.ui b/src/resources/gtk/prefs-dialog.ui
index ad4f428..3324727 100644
--- a/src/resources/gtk/prefs-dialog.ui
+++ b/src/resources/gtk/prefs-dialog.ui
@@ -561,7 +561,7 @@
                     </child>
                     <child>
                       <object class="GtkCheckButton" id="do_not_track_checkbutton">
-                        <property name="label" translatable="yes">_Tell websites I do not want to be 
tracked</property>
+                        <property name="label" translatable="yes">Block selected web _trackers</property>
                         <property name="visible">True</property>
                         <property name="use-underline">True</property>
                         <property name="halign">start</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]