diff options
author | Xan Lopez <xan@gnome.org> | 2010-02-05 05:05:16 +0800 |
---|---|---|
committer | Xan Lopez <xan@gnome.org> | 2010-02-05 05:07:37 +0800 |
commit | 66053f00ec618994942aa8a4685376a792c26acc (patch) | |
tree | fb1641363918922669d0e9896383d60efdb41cee | |
parent | 3fd99f851981c9bf4fea17a65cb94353fc37511d (diff) | |
download | gsoc2013-epiphany-66053f00ec618994942aa8a4685376a792c26acc.tar.gz gsoc2013-epiphany-66053f00ec618994942aa8a4685376a792c26acc.tar.zst gsoc2013-epiphany-66053f00ec618994942aa8a4685376a792c26acc.zip |
Make SoupCookieJarAcceptPolicy match our cookie policies
Bug #607484
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.c | 61 | ||||
-rw-r--r-- | embed/ephy-embed-prefs.h | 8 | ||||
-rw-r--r-- | embed/ephy-embed-single.c | 5 | ||||
-rw-r--r-- | embed/ephy-embed-utils.c | 1 |
5 files changed, 71 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index e923ca96c..04ad71314 100644 --- a/configure.ac +++ b/configure.ac @@ -101,7 +101,7 @@ LIBSTARTUP_NOTIFICATION_REQUIRED=0.5 LIBNOTIFY_REQUIRED=0.4 DBUS_GLIB_REQUIRED=0.35 WEBKIT_GTK_REQUIRED=1.1.19 -LIBSOUP_GNOME_REQUIRED=2.29.4 +LIBSOUP_GNOME_REQUIRED=2.29.90 GNOME_KEYRING_REQUIRED=2.26.0 PKG_CHECK_EXISTS([libnotify >= $LIBNOTIFY_REQUIRED],[have_libnotify=yes],[have_libnotify=no]) diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c index 0323d3282..382ff542f 100644 --- a/embed/ephy-embed-prefs.c +++ b/embed/ephy-embed-prefs.c @@ -329,6 +329,62 @@ webkit_pref_callback_accept_languages (GConfClient *client, g_free (langs_str); } +void +ephy_embed_prefs_set_cookie_jar_policy (SoupCookieJar *jar, + const char *gconf_policy) +{ + SoupCookieJarAcceptPolicy policy; + + g_return_if_fail (SOUP_IS_COOKIE_JAR (jar)); + g_return_if_fail (gconf_policy != NULL); + + if (g_str_equal (gconf_policy, "nowhere")) + policy = SOUP_COOKIE_JAR_ACCEPT_NEVER; + else if (g_str_equal (gconf_policy, "anywhere")) + policy = SOUP_COOKIE_JAR_ACCEPT_ALWAYS; + else if (g_str_equal (gconf_policy, "current site")) + policy = SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY; + else { + g_warn_if_reached (); + return; + } + + g_object_set (G_OBJECT (jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL); +} + +static void +webkit_pref_callback_cookie_accept_policy (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + gpointer data) +{ + SoupSession *session; + char *webkit_pref; + GConfValue *gcvalue; + const char *value = NULL; + + webkit_pref = data; + + gcvalue = gconf_entry_get_value (entry); + + /* happens on initial notify if the key doesn't exist */ + if (gcvalue != NULL && + gcvalue->type == GCONF_VALUE_STRING) { + value = gconf_value_get_string (gcvalue); + } + + if (value) { + SoupSessionFeature *jar; + + session = webkit_get_default_session (); + jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR); + if (!jar) + return; + + ephy_embed_prefs_set_cookie_jar_policy (SOUP_COOKIE_JAR (jar), value); + } +} + static const PrefData webkit_pref_entries[] = { { CONF_RENDERING_FONT_MIN_SIZE, @@ -372,7 +428,10 @@ static const PrefData webkit_pref_entries[] = webkit_pref_callback_accept_languages }, { CONF_USER_AGENT, "user-agent", - webkit_pref_callback_user_agent } + webkit_pref_callback_user_agent }, + { CONF_SECURITY_COOKIES_ACCEPT, + "accept-policy", + webkit_pref_callback_cookie_accept_policy } }; static void diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h index 4865aa0ed..c515eab80 100644 --- a/embed/ephy-embed-prefs.h +++ b/embed/ephy-embed-prefs.h @@ -72,9 +72,11 @@ G_BEGIN_DECLS -void ephy_embed_prefs_init (void); -void ephy_embed_prefs_shutdown (void); -void ephy_embed_prefs_add_embed (EphyEmbed *embed); +void ephy_embed_prefs_init (void); +void ephy_embed_prefs_shutdown (void); +void ephy_embed_prefs_add_embed (EphyEmbed *embed); +void ephy_embed_prefs_set_cookie_jar_policy (SoupCookieJar *jar, + const char *gconf_policy); G_END_DECLS diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c index f8e0319a9..44efecaed 100644 --- a/embed/ephy-embed-single.c +++ b/embed/ephy-embed-single.c @@ -23,6 +23,7 @@ #define LIBSOUP_I_HAVE_READ_BUG_594377_AND_KNOW_SOUP_PASSWORD_MANAGER_MIGHT_GO_AWAY #define NSPLUGINWRAPPER_SETUP "/usr/bin/mozilla-plugin-config" +#include "eel-gconf-extensions.h" #include "ephy-embed-single.h" #include "ephy-embed-prefs.h" #include "ephy-embed-type-builtins.h" @@ -470,6 +471,7 @@ ephy_embed_single_initialize (EphyEmbedSingle *single) SoupSession *session; SoupCookieJar *jar; char *filename; + char *cookie_policy; /* Initialise nspluginwrapper's plugins if available */ if (g_file_test (NSPLUGINWRAPPER_SETUP, G_FILE_TEST_EXISTS) != FALSE) @@ -483,6 +485,9 @@ ephy_embed_single_initialize (EphyEmbedSingle *single) filename = g_build_filename (ephy_dot_dir (), "cookies.sqlite", NULL); jar = soup_cookie_jar_sqlite_new (filename, FALSE); g_free (filename); + cookie_policy = eel_gconf_get_string (CONF_SECURITY_COOKIES_ACCEPT); + ephy_embed_prefs_set_cookie_jar_policy (jar, cookie_policy); + g_free (cookie_policy); soup_session_add_feature (session, SOUP_SESSION_FEATURE (jar)); g_object_unref (jar); diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c index eb7c434c2..3463f2d52 100644 --- a/embed/ephy-embed-utils.c +++ b/embed/ephy-embed-utils.c @@ -19,7 +19,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $Id: */ #include "config.h" |