[epiphany/mcatanzaro/cookies-prefs: 5/11] Remove cookie storage preferences



commit 098a63422375212ba24e09f1e17ab3d58d76aa9a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Jul 10 10:53:20 2020 -0500

    Remove cookie storage preferences
    
    Having a separate cookie storage preference doesn't make a lot of sense
    anymore now that we have ITP. See:
    https://gitlab.gnome.org/GNOME/epiphany/-/merge_requests/713#note_844468
    
    Our default setting (no third-party) does not work anymore since:
    https://bugs.webkit.org/show_bug.cgi?id=213502
    
    Also, users who disable cookie storage entirely are probably not
    achieving their desired behavior, since we still allow storing
    other forms of website data like localstorage or IndexedDB, unlike
    Safari which blocks website data storage when cookies are disabled.
    
    A new option to disable all local website data storage will follow in a
    subsequent commit.

 data/org.gnome.epiphany.gschema.xml     |  5 --
 embed/ephy-embed-prefs.c                | 44 -----------------
 embed/ephy-embed-shell.c                |  5 --
 lib/ephy-prefs.h                        |  9 ----
 src/preferences/prefs-privacy-page.c    | 85 ---------------------------------
 src/resources/gtk/prefs-privacy-page.ui | 51 --------------------
 6 files changed, 199 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 97464c836..fba022bd6 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -151,11 +151,6 @@
                        <summary>Languages</summary>
                        <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>
-                       <summary>Cookie accept</summary>
-                       <description>Where to accept cookies from. Possible values are “always”, 
“no-third-party” and “never”.</description>
-               </key>
                <key type="b" name="enable-popups">
                        <default>false</default>
                        <summary>Allow popups</summary>
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index 95f552813..a34c64e49 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -392,46 +392,6 @@ webkit_pref_callback_accept_languages (GSettings  *settings,
   g_array_free (array, TRUE);
 }
 
-
-void
-ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
-                                           const char          *settings_policy)
-{
-  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"))
-    policy = WEBKIT_COOKIE_POLICY_ACCEPT_NO_THIRD_PARTY;
-  else {
-    g_warn_if_reached ();
-    return;
-  }
-
-  webkit_cookie_manager_set_accept_policy (cookie_manager, policy);
-}
-
-static void
-webkit_pref_callback_cookie_accept_policy (GSettings  *settings,
-                                           const char *key,
-                                           gpointer    data)
-{
-  WebKitCookieManager *cookie_manager;
-  char *value;
-  EphyEmbedShell *shell;
-
-  value = g_settings_get_string (settings, key);
-  if (!value)
-    return;
-
-  shell = ephy_embed_shell_get_default ();
-  cookie_manager = webkit_web_context_get_cookie_manager (ephy_embed_shell_get_web_context (shell));
-  ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, value);
-  g_free (value);
-}
-
 static void
 webkit_pref_callback_gnome_fonts (GSettings  *ephy_settings,
                                   const char *key,
@@ -568,10 +528,6 @@ static const PrefData webkit_pref_entries[] = {
     EPHY_PREFS_WEB_USER_AGENT,
     "user-agent",
     webkit_pref_callback_user_agent },
-  { EPHY_PREFS_WEB_SCHEMA,
-    EPHY_PREFS_WEB_COOKIES_POLICY,
-    "accept-policy",
-    webkit_pref_callback_cookie_accept_policy },
   { EPHY_PREFS_WEB_SCHEMA,
     EPHY_PREFS_WEB_HARDWARE_ACCELERATION_POLICY,
     "hardware-acceleration-policy",
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index a7702860a..8abcbcea3 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -871,7 +871,6 @@ ephy_embed_shell_startup (GApplication *application)
   g_autofree char *favicon_db_path = NULL;
   WebKitCookieManager *cookie_manager;
   g_autofree char *filename = NULL;
-  g_autofree char *cookie_policy = NULL;
 
   G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application);
 
@@ -951,10 +950,6 @@ ephy_embed_shell_startup (GApplication *application)
                                                   WEBKIT_COOKIE_PERSISTENT_STORAGE_SQLITE);
   }
 
-  cookie_policy = g_settings_get_string (EPHY_SETTINGS_WEB,
-                                         EPHY_PREFS_WEB_COOKIES_POLICY);
-  ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
-
   g_signal_connect_object (priv->web_context, "download-started",
                            G_CALLBACK (download_started_cb), shell, 0);
 
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 05bbb2399..ba0654904 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -57,13 +57,6 @@ typedef enum
   EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY_NEVER
 } EphyPrefsUITabsBarVisibilityPolicy;
 
-typedef enum
-{
-  EPHY_PREFS_WEB_COOKIES_POLICY_ALWAYS,
-  EPHY_PREFS_WEB_COOKIES_POLICY_NO_THIRD_PARTY,
-  EPHY_PREFS_WEB_COOKIES_POLICY_NEVER
-} EphyPrefsWebCookiesPolicy;
-
 typedef enum
 {
   EPHY_PREFS_WEB_HARDWARE_ACCELERATION_POLICY_ON_DEMAND,
@@ -109,7 +102,6 @@ static const char * const ephy_prefs_state_schema[] = {
 #define EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING        "enable-spell-checking"
 #define EPHY_PREFS_WEB_ENABLE_SMOOTH_SCROLLING      "enable-smooth-scrolling"
 #define EPHY_PREFS_WEB_USER_AGENT                   "user-agent"
-#define EPHY_PREFS_WEB_COOKIES_POLICY               "cookies-policy"
 #define EPHY_PREFS_WEB_DEFAULT_ENCODING             "default-encoding"
 #define EPHY_PREFS_WEB_ENABLE_ADBLOCK               "enable-adblock"
 #define EPHY_PREFS_WEB_REMEMBER_PASSWORDS           "remember-passwords"
@@ -139,7 +131,6 @@ static const char * const ephy_prefs_web_schema[] = {
   EPHY_PREFS_WEB_ENABLE_SPELL_CHECKING,
   EPHY_PREFS_WEB_ENABLE_SMOOTH_SCROLLING,
   EPHY_PREFS_WEB_USER_AGENT,
-  EPHY_PREFS_WEB_COOKIES_POLICY,
   EPHY_PREFS_WEB_DEFAULT_ENCODING,
   EPHY_PREFS_WEB_ENABLE_ADBLOCK,
   EPHY_PREFS_WEB_REMEMBER_PASSWORDS,
diff --git a/src/preferences/prefs-privacy-page.c b/src/preferences/prefs-privacy-page.c
index a0b843979..2af88d151 100644
--- a/src/preferences/prefs-privacy-page.c
+++ b/src/preferences/prefs-privacy-page.c
@@ -41,11 +41,6 @@ struct _PrefsPrivacyPage {
   GtkWidget *enable_safe_browsing_switch;
   GtkWidget *enable_itp_switch;
 
-  /* Cookies */
-  GtkWidget *always;
-  GtkWidget *no_third_party;
-  GtkWidget *never;
-
   /* Passwords */
   GtkWidget *remember_passwords_switch;
 };
@@ -68,48 +63,6 @@ on_clear_data_row_activated (GtkWidget        *row,
   g_signal_emit (privacy_page, signals[CLEAR_DATA_ROW_ACTIVATED], 0);
 }
 
-static gboolean
-cookies_get_mapping (GValue   *value,
-                     GVariant *variant,
-                     gpointer  user_data)
-{
-  const char *setting;
-  const char *name;
-
-  setting = g_variant_get_string (variant, NULL);
-  name = gtk_buildable_get_name (GTK_BUILDABLE (user_data));
-
-  if (g_strcmp0 (name, "no_third_party") == 0)
-    name = "no-third-party";
-
-  /* If the button name matches the setting, it should be active. */
-  if (g_strcmp0 (name, setting) == 0)
-    g_value_set_boolean (value, TRUE);
-
-  return TRUE;
-}
-
-static GVariant *
-cookies_set_mapping (const GValue       *value,
-                     const GVariantType *expected_type,
-                     gpointer            user_data)
-{
-  GVariant *variant = NULL;
-  const char *name;
-
-  /* Don't act unless the button has been activated (turned ON). */
-  if (!g_value_get_boolean (value))
-    return NULL;
-
-  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
-    variant = g_variant_new_string (name);
-
-  return variant;
-}
-
 static void
 setup_privacy_page (PrefsPrivacyPage *privacy_page)
 {
@@ -142,39 +95,6 @@ setup_privacy_page (PrefsPrivacyPage *privacy_page)
                    "active",
                    G_SETTINGS_BIND_DEFAULT);
 
-  /* ======================================================================== */
-  /* ========================== Cookies ===================================== */
-  /* ======================================================================== */
-  g_settings_bind_with_mapping (web_settings,
-                                EPHY_PREFS_WEB_COOKIES_POLICY,
-                                privacy_page->always,
-                                "active",
-                                G_SETTINGS_BIND_DEFAULT,
-                                cookies_get_mapping,
-                                cookies_set_mapping,
-                                privacy_page->always,
-                                NULL);
-
-  g_settings_bind_with_mapping (web_settings,
-                                EPHY_PREFS_WEB_COOKIES_POLICY,
-                                privacy_page->no_third_party,
-                                "active",
-                                G_SETTINGS_BIND_DEFAULT,
-                                cookies_get_mapping,
-                                cookies_set_mapping,
-                                privacy_page->no_third_party,
-                                NULL);
-
-  g_settings_bind_with_mapping (web_settings,
-                                EPHY_PREFS_WEB_COOKIES_POLICY,
-                                privacy_page->never,
-                                "active",
-                                G_SETTINGS_BIND_DEFAULT,
-                                cookies_get_mapping,
-                                cookies_set_mapping,
-                                privacy_page->never,
-                                NULL);
-
   /* ======================================================================== */
   /* ========================== Passwords =================================== */
   /* ======================================================================== */
@@ -213,11 +133,6 @@ prefs_privacy_page_class_init (PrefsPrivacyPageClass *klass)
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, enable_safe_browsing_switch);
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, enable_itp_switch);
 
-  /* Cookies */
-  gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, always);
-  gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, no_third_party);
-  gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, never);
-
   /* Passwords */
   gtk_widget_class_bind_template_child (widget_class, PrefsPrivacyPage, remember_passwords_switch);
 
diff --git a/src/resources/gtk/prefs-privacy-page.ui b/src/resources/gtk/prefs-privacy-page.ui
index 62356b2b6..ab871cd77 100644
--- a/src/resources/gtk/prefs-privacy-page.ui
+++ b/src/resources/gtk/prefs-privacy-page.ui
@@ -70,57 +70,6 @@
         </child>
       </object>
     </child>
-    <child>
-      <object class="HdyPreferencesGroup">
-        <property name="title" translatable="yes">Cookies</property>
-        <property name="visible">True</property>
-        <child>
-          <object class="HdyActionRow">
-            <property name="activatable_widget">always</property>
-            <property name="title" translatable="yes">_Always accept</property>
-            <property name="use_underline">True</property>
-            <property name="visible">True</property>
-            <child type="prefix">
-              <object class="GtkRadioButton" id="always">
-                <property name="valign">center</property>
-                <property name="visible">True</property>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="HdyActionRow">
-            <property name="activatable_widget">no_third_party</property>
-            <property name="subtitle" translatable="yes" comments="Refers to &quot;Only from sites you 
visit&quot; option under Cookies.">For example, not from advertisers on these sites.</property>
-            <property name="title" translatable="yes">Only _from sites you visit</property>
-            <property name="use_underline">True</property>
-            <property name="visible">True</property>
-            <child type="prefix">
-              <object class="GtkRadioButton" id="no_third_party">
-                <property name="valign">center</property>
-                <property name="group">always</property>
-                <property name="visible">True</property>
-              </object>
-            </child>
-          </object>
-        </child>
-        <child>
-          <object class="HdyActionRow">
-            <property name="activatable_widget">never</property>
-            <property name="title" translatable="yes">_Never accept</property>
-            <property name="use_underline">True</property>
-            <property name="visible">True</property>
-            <child type="prefix">
-              <object class="GtkRadioButton" id="never">
-                <property name="valign">center</property>
-                <property name="group">always</property>
-                <property name="visible">True</property>
-              </object>
-            </child>
-          </object>
-        </child>
-      </object>
-    </child>
     <child>
       <object class="HdyPreferencesGroup">
         <property name="title" translatable="yes">Passwords</property>


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