Commit 66053f00 authored by Xan Lopez's avatar Xan Lopez

Make SoupCookieJarAcceptPolicy match our cookie policies

Bug #607484
parent 3fd99f85
......@@ -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])
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment