No third-party cookies with soup 2.29.91/ WebKit 1.1.21
This commit is contained in:
parent
1d4f129d6c
commit
1ed184ba1c
2 changed files with 57 additions and 1 deletions
|
@ -755,6 +755,10 @@ midori_browser_privacy_preferences_cb (MidoriBrowser* browser,
|
|||
katze_preferences_add_widget (preferences, button, "indented");
|
||||
button = katze_property_proxy (settings, "maximum-cookie-age", "days");
|
||||
katze_preferences_add_widget (preferences, button, "spanned");
|
||||
#ifdef HAVE_LIBSOUP_2_29_91
|
||||
button = katze_property_proxy (settings, "first-party-cookies-only", NULL);
|
||||
katze_preferences_add_widget (preferences, button, "filled");
|
||||
#endif
|
||||
|
||||
markup = g_strdup_printf ("<span size=\"smaller\">%s</span>",
|
||||
_("Cookies store login data, saved games, "
|
||||
|
@ -922,6 +926,20 @@ soup_session_settings_notify_http_proxy_cb (MidoriWebSettings* settings,
|
|||
midori_soup_session_set_proxy_uri (session, NULL);
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBSOUP_2_29_91
|
||||
static void
|
||||
soup_session_settings_notify_first_party_cb (MidoriWebSettings* settings,
|
||||
GParamSpec* pspec,
|
||||
SoupSession* session)
|
||||
{
|
||||
void* jar = soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
|
||||
gboolean yes = katze_object_get_boolean (settings, "first-party-cookies-only");
|
||||
g_object_set (jar, "accept-policy",
|
||||
yes ? SOUP_COOKIE_JAR_ACCEPT_NO_THIRD_PARTY
|
||||
: SOUP_COOKIE_JAR_ACCEPT_ALWAYS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
midori_soup_session_settings_accept_language_cb (SoupSession* session,
|
||||
SoupMessage* msg,
|
||||
|
@ -1028,6 +1046,12 @@ midori_load_soup_session (gpointer settings)
|
|||
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
|
||||
g_signal_connect (settings, "notify::proxy-type",
|
||||
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), session);
|
||||
#ifdef HAVE_LIBSOUP_2_29_91
|
||||
if (g_object_class_find_property (G_OBJECT_GET_CLASS (settings),
|
||||
"enable-file-access-from-file-uris")) /* WebKitGTK+ >= 1.1.21 */
|
||||
g_signal_connect (settings, "notify::first-party-cookies-only",
|
||||
G_CALLBACK (soup_session_settings_notify_first_party_cb), session);
|
||||
#endif
|
||||
|
||||
g_signal_connect (session, "request-queued",
|
||||
G_CALLBACK (midori_soup_session_settings_accept_language_cb), settings);
|
||||
|
@ -2186,6 +2210,9 @@ main (int argc,
|
|||
g_object_set (settings,
|
||||
"preferred-languages", "en",
|
||||
"enable-private-browsing", TRUE,
|
||||
#ifdef HAVE_LIBSOUP_2_29_91
|
||||
"first-party-cookies-only", TRUE,
|
||||
#endif
|
||||
"enable-html5-database", FALSE,
|
||||
"enable-html5-local-storage", FALSE,
|
||||
"enable-offline-web-application-cache", FALSE,
|
||||
|
|
|
@ -58,7 +58,7 @@ struct _MidoriWebSettings
|
|||
gboolean zoom_text_and_images : 1;
|
||||
gboolean find_while_typing : 1;
|
||||
gboolean kinetic_scrolling : 1;
|
||||
gboolean original_cookies_only : 1;
|
||||
gboolean first_party_cookies_only : 1;
|
||||
gboolean remember_last_visited_pages : 1;
|
||||
MidoriProxy proxy_type : 2;
|
||||
MidoriIdentity identify_as : 3;
|
||||
|
@ -156,6 +156,7 @@ enum
|
|||
PROP_FIND_WHILE_TYPING,
|
||||
PROP_KINETIC_SCROLLING,
|
||||
PROP_MAXIMUM_COOKIE_AGE,
|
||||
PROP_FIRST_PARTY_COOKIES_ONLY,
|
||||
|
||||
PROP_MAXIMUM_HISTORY_AGE,
|
||||
|
||||
|
@ -837,6 +838,28 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
|
|||
0, G_MAXINT, 30,
|
||||
flags));
|
||||
|
||||
/**
|
||||
* MidoriWebSettings:first-party-cookies-only:
|
||||
*
|
||||
* Whether only first party cookies should be accepted.
|
||||
* WebKitGTK+ 1.1.21 is required for this to work.
|
||||
*
|
||||
* Since: 0.4.2
|
||||
*/
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_FIRST_PARTY_COOKIES_ONLY,
|
||||
g_param_spec_boolean (
|
||||
"first-party-cookies-only",
|
||||
_("Only accept Cookies from sites you visit"),
|
||||
_("Block cookies sent by third-party websites"),
|
||||
#ifdef HAVE_LIBSOUP_2_29_91
|
||||
TRUE,
|
||||
g_object_class_find_property (gobject_class, /* WebKitGTK+ >= 1.1.21 */
|
||||
"enable-file-access-from-file-uris") ? flags : G_PARAM_READABLE));
|
||||
#else
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
#endif
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_MAXIMUM_HISTORY_AGE,
|
||||
|
@ -1350,6 +1373,9 @@ midori_web_settings_set_property (GObject* object,
|
|||
case PROP_MAXIMUM_COOKIE_AGE:
|
||||
web_settings->maximum_cookie_age = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_FIRST_PARTY_COOKIES_ONLY:
|
||||
web_settings->first_party_cookies_only = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_MAXIMUM_HISTORY_AGE:
|
||||
web_settings->maximum_history_age = g_value_get_int (value);
|
||||
|
@ -1608,6 +1634,9 @@ midori_web_settings_get_property (GObject* object,
|
|||
case PROP_MAXIMUM_COOKIE_AGE:
|
||||
g_value_set_int (value, web_settings->maximum_cookie_age);
|
||||
break;
|
||||
case PROP_FIRST_PARTY_COOKIES_ONLY:
|
||||
g_value_set_boolean (value, web_settings->first_party_cookies_only);
|
||||
break;
|
||||
|
||||
case PROP_MAXIMUM_HISTORY_AGE:
|
||||
g_value_set_int (value, web_settings->maximum_history_age);
|
||||
|
|
Loading…
Reference in a new issue