Use setting for old and new prefetching option

So prefetching in private mode is disabled regardless of
whether prefetching is done in Midori or in new WebKit
versions.
Menu items also adhere to that same setting now.

And use the chance to correct version checks.
This commit is contained in:
Christian Dywan 2011-04-17 22:29:51 +02:00
parent ea264c31f6
commit 10c5ac4597
6 changed files with 51 additions and 14 deletions

View file

@ -2213,15 +2213,14 @@ main (int argc,
if (private) if (private)
{ {
g_object_set (settings,
#if WEBKIT_CHECK_VERSION (1, 1, 2) #if WEBKIT_CHECK_VERSION (1, 1, 2)
g_object_set (settings, "enable-private-browsing", TRUE, NULL); "enable-private-browsing", TRUE,
#endif #endif
/* Arguably DNS prefetching is or isn't a privacy concern. For the /* Arguably DNS prefetching is or isn't a privacy concern. For the
* lack of more fine-grained control we'll go the safe route. */ * lack of more fine-grained control we'll go the safe route. */
#if WEBKIT_CHECK_VERSION (1, 3, 13) "enable-dns-prefetching", FALSE,
g_object_set (settings, "enable-dns-prefetching", FALSE, NULL); "strip-referer", TRUE, NULL);
#endif
g_object_set (settings, "strip-referer", TRUE, NULL);
midori_browser_set_action_visible (browser, "Tools", FALSE); midori_browser_set_action_visible (browser, "Tools", FALSE);
midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE); midori_browser_set_action_visible (browser, "ClearPrivateData", FALSE);
} }

View file

@ -2697,7 +2697,8 @@ midori_browser_menu_item_select_cb (GtkWidget* menuitem,
if (item) if (item)
{ {
tooltip = g_strdup (katze_item_get_uri (item)); tooltip = g_strdup (katze_item_get_uri (item));
sokoke_prefetch_uri (tooltip, NULL, NULL); sokoke_prefetch_uri (midori_browser_get_settings (browser),
tooltip, NULL, NULL);
} }
} }
_midori_browser_set_statusbar_text (browser, tooltip); _midori_browser_set_statusbar_text (browser, tooltip);

View file

@ -1701,8 +1701,8 @@ webkit_web_view_hovering_over_link_cb (WebKitWebView* web_view,
const gchar* link_uri, const gchar* link_uri,
MidoriView* view) MidoriView* view)
{ {
#if !(WEBKIT_CHECK_VERSION (2, 18, 0) && defined (HAVE_LIBSOUP_2_29_3)) #if !(WEBKIT_CHECK_VERSION (1, 3, 1) && defined (HAVE_LIBSOUP_2_29_3))
sokoke_prefetch_uri (link_uri, NULL, NULL); sokoke_prefetch_uri (view->settings, link_uri, NULL, NULL);
#endif #endif
katze_assign (view->link_uri, g_strdup (link_uri)); katze_assign (view->link_uri, g_strdup (link_uri));

View file

@ -86,6 +86,9 @@ struct _MidoriWebSettings
gint clear_private_data; gint clear_private_data;
gchar* clear_data; gchar* clear_data;
#if !WEBKIT_CHECK_VERSION (1, 3, 13)
gboolean enable_dns_prefetching;
#endif
gboolean strip_referer; gboolean strip_referer;
}; };
@ -170,6 +173,7 @@ enum
PROP_CLEAR_PRIVATE_DATA, PROP_CLEAR_PRIVATE_DATA,
PROP_CLEAR_DATA, PROP_CLEAR_DATA,
PROP_ENABLE_DNS_PREFETCHING,
PROP_STRIP_REFERER PROP_STRIP_REFERER
}; };
@ -1102,6 +1106,24 @@ midori_web_settings_class_init (MidoriWebSettingsClass* class)
_("The data selected for deletion"), _("The data selected for deletion"),
NULL, NULL,
flags)); flags));
#if !WEBKIT_CHECK_VERSION (1, 3, 13)
/**
* MidoriWebSettings:enable-dns-prefetching:
*
* Whether to resolve host names in advance.
*
* Since: 0.3.4
*/
g_object_class_install_property (gobject_class,
PROP_ENABLE_DNS_PREFETCHING,
g_param_spec_boolean (
"enable-dns-prefetching",
"Whether to resolve host names in advance",
"Whether host names on a website or in bookmarks should be prefetched",
TRUE,
flags));
#endif
/** /**
* MidoriWebSettings:strip-referer: * MidoriWebSettings:strip-referer:
* *
@ -1537,6 +1559,11 @@ midori_web_settings_set_property (GObject* object,
case PROP_CLEAR_DATA: case PROP_CLEAR_DATA:
katze_assign (web_settings->clear_data, g_value_dup_string (value)); katze_assign (web_settings->clear_data, g_value_dup_string (value));
break; break;
#if !WEBKIT_CHECK_VERSION (1, 3, 13)
case PROP_ENABLE_DNS_PREFETCHING:
web_settings->enable_dns_prefetching = g_value_get_boolean (value);
break;
#endif
case PROP_STRIP_REFERER: case PROP_STRIP_REFERER:
web_settings->strip_referer = g_value_get_boolean (value); web_settings->strip_referer = g_value_get_boolean (value);
break; break;
@ -1771,6 +1798,11 @@ midori_web_settings_get_property (GObject* object,
case PROP_CLEAR_DATA: case PROP_CLEAR_DATA:
g_value_set_string (value, web_settings->clear_data); g_value_set_string (value, web_settings->clear_data);
break; break;
#if !WEBKIT_CHECK_VERSION (1, 3, 13)
case PROP_ENABLE_DNS_PREFETCHING:
g_value_set_boolean (value, web_settings->enable_dns_prefetching);
break;
#endif
case PROP_STRIP_REFERER: case PROP_STRIP_REFERER:
g_value_set_boolean (value, web_settings->strip_referer); g_value_set_boolean (value, web_settings->strip_referer);
break; break;

View file

@ -793,7 +793,7 @@ sokoke_resolve_hostname (const gchar* hostname)
gint host_resolved = 0; gint host_resolved = 0;
uri = g_strconcat ("http://", hostname, NULL); uri = g_strconcat ("http://", hostname, NULL);
if (sokoke_prefetch_uri (uri, sokoke_resolve_hostname_cb, if (sokoke_prefetch_uri (NULL, uri, sokoke_resolve_hostname_cb,
&host_resolved)) &host_resolved))
{ {
GTimer* timer = g_timer_new (); GTimer* timer = g_timer_new ();
@ -1957,6 +1957,7 @@ sokoke_file_chooser_dialog_new (const gchar* title,
/** /**
* sokoke_prefetch_uri: * sokoke_prefetch_uri:
* @settings: a #MidoriWebSettings instance, or %NULL
* @uri: an URI string * @uri: an URI string
* *
* Attempts to prefetch the specified URI, that is * Attempts to prefetch the specified URI, that is
@ -1965,7 +1966,8 @@ sokoke_file_chooser_dialog_new (const gchar* title,
* Return value: %TRUE on success * Return value: %TRUE on success
**/ **/
gboolean gboolean
sokoke_prefetch_uri (const char* uri, sokoke_prefetch_uri (MidoriWebSettings* settings,
const char* uri,
SoupAddressCallback callback, SoupAddressCallback callback,
gpointer user_data) gpointer user_data)
{ {
@ -1977,6 +1979,10 @@ sokoke_prefetch_uri (const char* uri,
if (!uri) if (!uri)
return FALSE; return FALSE;
if (settings && !katze_object_get_boolean (settings, "enable-dns-prefetching"))
return FALSE;
s_uri = soup_uri_new (uri); s_uri = soup_uri_new (uri);
if (!s_uri || !s_uri->host) if (!s_uri || !s_uri->host)
return FALSE; return FALSE;

View file

@ -19,10 +19,8 @@
#define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK) #define MIDORI_MOD_BACKGROUND(state) (state & GDK_SHIFT_MASK)
#define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK) #define MIDORI_MOD_SCROLL(state) (state & GDK_CONTROL_MASK)
#include <katze/katze.h>
#include <webkit/webkit.h>
#include <JavaScriptCore/JavaScript.h> #include <JavaScriptCore/JavaScript.h>
#include <midori/midori-websettings.h>
#if !GLIB_CHECK_VERSION (2, 14, 0) #if !GLIB_CHECK_VERSION (2, 14, 0)
#define G_PARAM_STATIC_STRINGS \ #define G_PARAM_STATIC_STRINGS \
@ -254,7 +252,8 @@ sokoke_file_chooser_dialog_new (const gchar* title,
GtkFileChooserAction action); GtkFileChooserAction action);
gboolean gboolean
sokoke_prefetch_uri (const char* uri, sokoke_prefetch_uri (MidoriWebSettings* settings,
const char* uri,
SoupAddressCallback callback, SoupAddressCallback callback,
gpointer user_data); gpointer user_data);