Use WebKitWebView:session property if it exists

This commit is contained in:
Christian Dywan 2009-01-15 03:29:47 +01:00
parent b7a9d724b0
commit 03678a16b1
3 changed files with 38 additions and 6 deletions

View file

@ -1464,9 +1464,7 @@ cookie_jar_constructed_cb (GObject* object)
(GClosureNotify)g_free, 0);
#endif
}
#endif
#if HAVE_LIBSOUP
static void
authentication_dialog_response_cb (GtkWidget* dialog,
gint response,
@ -1903,6 +1901,11 @@ main (int argc,
gchar* uri;
KatzeItem* item;
gchar* uri_ready;
#if HAVE_LIBSOUP
GObjectClass* webkit_class;
KatzeNet* net;
SoupSession* s_session;
#endif
#ifdef HAVE_SQLITE
sqlite3* db;
gint max_history_age;
@ -1980,6 +1983,9 @@ main (int argc,
}
#if HAVE_LIBSOUP
webkit_class = g_type_class_ref (WEBKIT_TYPE_WEB_VIEW);
if (!g_object_class_find_property (webkit_class, "session"))
{
/* This is a nasty trick that allows us to manipulate cookies
even without having a pointer to the jar. */
soup_cookie_jar_get_type ();
@ -1991,8 +1997,6 @@ main (int argc,
old_jar_constructed_cb = G_OBJECT_CLASS (jar_class)->constructed;
G_OBJECT_CLASS (jar_class)->constructed = cookie_jar_constructed_cb;
}
#endif
#if HAVE_LIBSOUP
/* This is a nasty trick that allows us to manipulate preferences
even without having a pointer to the session. */
soup_session_get_type ();
@ -2004,6 +2008,7 @@ main (int argc,
old_session_constructed_cb = G_OBJECT_CLASS (session_class)->constructed;
G_OBJECT_CLASS (session_class)->constructed = soup_session_constructed_cb;
}
}
#endif
/* Load configuration files */
@ -2121,6 +2126,24 @@ main (int argc,
}
g_string_free (error_messages, TRUE);
#if HAVE_LIBSOUP
webkit_class = g_type_class_ref (WEBKIT_TYPE_WEB_VIEW);
if (g_object_class_find_property (webkit_class, "session"))
{
net = katze_net_new ();
s_session = katze_net_get_session (net);
soup_session_settings_notify_http_proxy_cb (settings, NULL, s_session);
soup_session_settings_notify_ident_string_cb (settings, NULL, s_session);
g_signal_connect (settings, "notify::http-proxy",
G_CALLBACK (soup_session_settings_notify_http_proxy_cb), s_session);
g_signal_connect (settings, "notify::ident-string",
G_CALLBACK (soup_session_settings_notify_ident_string_cb), s_session);
g_signal_connect (s_session, "authenticate",
G_CALLBACK (soup_session_authenticate_cb), app);
g_object_unref (net);
}
#endif
/* Open as many tabs as we have uris, seperated by pipes */
i = 0;
while (uris && uris[i])

View file

@ -300,6 +300,9 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
GtkWidget* entry;
GtkWidget* hbox;
gint icon_width, icon_height;
#if HAVE_LIBSOUP
GObjectClass* webkit_class;
#endif
g_return_if_fail (MIDORI_IS_PREFERENCES (preferences));
g_return_if_fail (MIDORI_IS_WEB_SETTINGS (settings));
@ -535,8 +538,10 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
/* Page "Network" */
#if HAVE_LIBSOUP
webkit_class = g_type_class_ref (WEBKIT_TYPE_WEB_VIEW);
if (g_object_class_find_property (webkit_class, "session") ||
/* If a cookie jar was created, WebKit is using Soup */
if (g_type_get_qdata (SOUP_TYPE_COOKIE_JAR,
g_type_get_qdata (SOUP_TYPE_COOKIE_JAR,
g_quark_from_static_string ("midori-has-jar")))
{
PAGE_NEW (GTK_STOCK_NETWORK, _("Network"));
@ -571,8 +576,9 @@ midori_preferences_set_settings (MidoriPreferences* preferences,
/* Page "Privacy" */
PAGE_NEW (GTK_STOCK_INDEX, _("Privacy"));
#if HAVE_LIBSOUP_2_25_2
if (g_object_class_find_property (webkit_class, "session") ||
/* If a cookie jar was created, WebKit is using Soup */
if (g_type_get_qdata (SOUP_TYPE_COOKIE_JAR,
g_type_get_qdata (SOUP_TYPE_COOKIE_JAR,
g_quark_from_static_string ("midori-has-jar")))
{
FRAME_NEW (_("Web Cookies"));

View file

@ -1442,6 +1442,9 @@ midori_view_construct_web_view (MidoriView* view)
gpointer inspector;
view->web_view = webkit_web_view_new ();
if (g_object_class_find_property (G_OBJECT_GET_CLASS (view->web_view), "session"))
g_object_set (view->web_view, "session",
katze_net_get_session (view->net), NULL);
web_frame = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (view->web_view));