about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-03-01 14:11:13 +0000
committerMarco Peereboom <marco@conformal.com>2011-03-01 14:11:13 +0000
commit4ed816d9346eed6b22ed504da97d7fb29889f4e7 (patch)
treeafc095cf38ac3f5f5c491954e8363246dcbb1603
parentf01e39312c2b09d38f0ff7be38e68e91ba90efd6 (diff)
downloadxombrero-4ed816d9346eed6b22ed504da97d7fb29889f4e7.tar.gz
help browser open a url in same tab that would have opened in a new tab.
fixes news.google.com in whitelist mode
-rw-r--r--xxxterm.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/xxxterm.c b/xxxterm.c
index 7a576f9..1860cec 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -5894,7 +5894,9 @@ webview_npd_cb(WebKitWebView *wv, WebKitWebFrame *wf,
     WebKitNetworkRequest *request, WebKitWebNavigationAction *na,
     WebKitWebPolicyDecision *pd, struct tab *t)
 {
-	char			*uri;
+	char				*uri;
+	WebKitWebNavigationReason	reason;
+	struct domain			*d = NULL;
 
 	if (t == NULL) {
 		show_oops_s("webview_npd_cb invalid parameters");
@@ -5914,8 +5916,22 @@ webview_npd_cb(WebKitWebView *wv, WebKitWebFrame *wf,
 		return (TRUE); /* we made the decission */
 	}
 
-	webkit_web_policy_decision_use(pd);
-	return (TRUE); /* we made the decission */
+	/*
+	 * This is a little hairy but it comes down to this:
+	 * when we run in whitelist mode we have to assist the browser in
+	 * opening the URL that it would have opened in a new tab.
+	 */
+	reason = webkit_web_navigation_action_get_reason(na);
+	if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
+		if (enable_scripts == 0 && enable_cookie_whitelist == 1)
+			if (uri && (d = wl_find_uri(uri, &js_wl)) == NULL)
+				load_uri(t, uri);
+
+		webkit_web_policy_decision_use(pd);
+		return (TRUE); /* we made the decission */
+	}
+
+	return (FALSE);
 }
 
 WebKitWebView *