aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-06-08 16:50:30 +0800
committerCarlos Garcia Campos <carlosgc@gnome.org>2012-07-04 19:15:37 +0800
commitdcb11d1f5517bd4df39fc0d0228fd02214ad903d (patch)
tree48cace962d9e6edafed409ec5720769d22702545 /embed
parent74ff5812f0cc1c2f94c64cc00bc99e8bc887793f (diff)
downloadgsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar.gz
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar.bz2
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar.lz
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar.xz
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.tar.zst
gsoc2013-epiphany-dcb11d1f5517bd4df39fc0d0228fd02214ad903d.zip
Port cookies to WebKit2
https://bugzilla.gnome.org/show_bug.cgi?id=678626
Diffstat (limited to 'embed')
-rw-r--r--embed/ephy-embed-prefs.c34
-rw-r--r--embed/ephy-embed-prefs.h19
-rw-r--r--embed/ephy-embed-single.c14
3 files changed, 60 insertions, 7 deletions
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index b9daf227d..164abbab3 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -372,6 +372,28 @@ webkit_pref_callback_accept_languages (GSettings *settings,
#endif
}
+
+#ifdef HAVE_WEBKIT2
+void
+ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
+ const char *settings_policy)
+{
+ WebKitCookieAcceptPolicy policy;
+
+ if (g_str_equal (settings_policy, "never"))
+ policy = WEBKIT_COOKIE_POLICY_ACCEPT_NEVER;
+ else if (g_str_equal (settings_policy, "always"))
+ policy = WEBKIT_COOKIE_POLICY_ACCEPT_ALWAYS;
+ else if (g_str_equal (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);
+}
+#else
void
ephy_embed_prefs_set_cookie_jar_policy (SoupCookieJar *jar,
const char *settings_policy)
@@ -394,6 +416,7 @@ ephy_embed_prefs_set_cookie_jar_policy (SoupCookieJar *jar,
g_object_set (G_OBJECT (jar), SOUP_COOKIE_JAR_ACCEPT_POLICY, policy, NULL);
}
+#endif
static void
webkit_pref_callback_cookie_accept_policy (GSettings *settings,
@@ -401,7 +424,16 @@ webkit_pref_callback_cookie_accept_policy (GSettings *settings,
gpointer data)
{
#ifdef HAVE_WEBKIT2
- /* TODO: Cookies */
+ WebKitCookieManager *cookie_manager;
+ char *value;
+
+ value = g_settings_get_string (settings, key);
+ if (!value)
+ return;
+
+ cookie_manager = webkit_web_context_get_cookie_manager (webkit_web_context_get_default ());
+ ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, value);
+ g_free (value);
#else
SoupSession *session;
char *value = NULL;
diff --git a/embed/ephy-embed-prefs.h b/embed/ephy-embed-prefs.h
index 0db4ffbc3..f214250e3 100644
--- a/embed/ephy-embed-prefs.h
+++ b/embed/ephy-embed-prefs.h
@@ -23,7 +23,11 @@
#include "ephy-embed.h"
+#ifdef HAVE_WEBKIT2
+#include <webkit2/webkit2.h>
+#else
#include <libsoup/soup.h>
+#endif
#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
#error "Only <epiphany/epiphany.h> can be included directly."
@@ -34,11 +38,16 @@
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_set_cookie_jar_policy (SoupCookieJar *jar,
- const char *gconf_policy);
+void ephy_embed_prefs_init (void);
+void ephy_embed_prefs_shutdown (void);
+void ephy_embed_prefs_add_embed (EphyEmbed *embed);
+#ifdef HAVE_WEBKIT2
+void ephy_embed_prefs_set_cookie_accept_policy (WebKitCookieManager *cookie_manager,
+ const char *settings_policy);
+#else
+void ephy_embed_prefs_set_cookie_jar_policy (SoupCookieJar *jar,
+ const char *gconf_policy);
+#endif
G_END_DECLS
diff --git a/embed/ephy-embed-single.c b/embed/ephy-embed-single.c
index c927ba89c..da4704206 100644
--- a/embed/ephy-embed-single.c
+++ b/embed/ephy-embed-single.c
@@ -405,8 +405,20 @@ gboolean
ephy_embed_single_initialize (EphyEmbedSingle *single)
{
#ifdef HAVE_WEBKIT2
+ WebKitWebContext *web_context;
+ char *cookie_policy;
+
/* TODO: Network features */
- webkit_web_context_register_uri_scheme (webkit_web_context_get_default (),
+
+ web_context = webkit_web_context_get_default ();
+
+ cookie_policy = g_settings_get_string (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_COOKIES_POLICY);
+ ephy_embed_prefs_set_cookie_accept_policy (webkit_web_context_get_cookie_manager (web_context),
+ cookie_policy);
+ g_free (cookie_policy);
+
+ webkit_web_context_register_uri_scheme (web_context,
EPHY_ABOUT_SCHEME,
about_request_cb,
NULL);