about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorMarco Peereboom <marco@conformal.com>2011-07-07 16:33:31 +0000
committerMarco Peereboom <marco@conformal.com>2011-07-07 16:33:31 +0000
commit2119081cc065c39406b7cdb9b718a978bf843a66 (patch)
tree887a133cec736a08129e990e15e41cecb9497aea
parent76f1b1be26ae788310170bae95a6cf2bd2c20163 (diff)
downloadxombrero-2119081cc065c39406b7cdb9b718a978bf843a66.tar.gz
Add toplevel toggle command to temporary enable cookie and js whitelist
for the toplevel domain.  The "play" button now uses this too instead of
the old FQDN JS only action.

requested by several people.
-rw-r--r--xxxterm.16
-rw-r--r--xxxterm.c42
-rw-r--r--xxxterm.conf1
3 files changed, 40 insertions, 9 deletions
diff --git a/xxxterm.1 b/xxxterm.1
index e6b6820..4091af2 100644
--- a/xxxterm.1
+++ b/xxxterm.1
@@ -199,6 +199,8 @@ It can be useful when the
 option is used.
 .Pp
 .Bl -tag -width Ds -offset indent -compact
+.It Cm F4
+Alias for ":toplevel toggle"
 .It Cm F9
 Alias for ":open"
 .Pq Cm promptopen
@@ -507,6 +509,10 @@ Go to the next tab.
 Go to the previous tab.
 .It Cm tabshow , tabs
 Show tabs.
+.It Cm toplevel , toplevel toggle
+Toggle the top level domain name cookie and JS session whitelist.
+This is to enable/disable short lived full site functionality without
+permanently adding the top level domain to the persistent whitelist.
 .It Cm urlhide , urlh
 Hide url entry and tool bar.
 .It Cm urlshow , urls
diff --git a/xxxterm.c b/xxxterm.c
index d8208a0..eb8a3da 100644
--- a/xxxterm.c
+++ b/xxxterm.c
@@ -430,6 +430,7 @@ struct karg {
 #define XT_WL_TOPLEVEL		(1<<4)
 #define XT_WL_PERSISTENT	(1<<5)
 #define XT_WL_SESSION		(1<<6)
+#define XT_WL_RELOAD		(1<<7)
 
 #define XT_SHOW			(1<<7)
 #define XT_DELETE		(1<<8)
@@ -2375,7 +2376,8 @@ toggle_cwl(struct tab *t, struct karg *args)
 		/* disable cookies for domain */
 		RB_REMOVE(domain_list, &c_wl, d);
 
-	webkit_web_view_reload(t->wv);
+	if (args->i & XT_WL_RELOAD)
+		webkit_web_view_reload(t->wv);
 
 	g_free(dom);
 	return (0);
@@ -2430,7 +2432,9 @@ toggle_js(struct tab *t, struct karg *args)
 	g_object_set(G_OBJECT(t->settings),
 	    "javascript-can-open-windows-automatically", es, (char *)NULL);
 	webkit_web_view_set_settings(t->wv, t->settings);
-	webkit_web_view_reload(t->wv);
+
+	if (args->i & XT_WL_RELOAD)
+		webkit_web_view_reload(t->wv);
 done:
 	if (dom)
 		g_free(dom);
@@ -2442,7 +2446,10 @@ js_toggle_cb(GtkWidget *w, struct tab *t)
 {
 	struct karg		a;
 
-	a.i = XT_WL_TOGGLE | XT_WL_FQDN;
+	a.i = XT_WL_TOGGLE | XT_WL_TOPLEVEL;
+	toggle_cwl(t, &a);
+
+	a.i = XT_WL_TOGGLE | XT_WL_TOPLEVEL | XT_WL_RELOAD;
 	toggle_js(t, &a);
 }
 
@@ -3342,11 +3349,13 @@ cookie_cmd(struct tab *t, struct karg *args)
 {
 	if (args->i & XT_SHOW)
 		wl_show(t, args, "Cookie White List", &c_wl);
-	else if (args->i & XT_WL_TOGGLE)
+	else if (args->i & XT_WL_TOGGLE) {
+		args->i |= XT_WL_RELOAD;
 		toggle_cwl(t, args);
-	else if (args->i & XT_SAVE)
+	} else if (args->i & XT_SAVE) {
+		args->i |= XT_WL_RELOAD;
 		wl_save(t, args, 0);
-	else if (args->i & XT_DELETE)
+	} else if (args->i & XT_DELETE)
 		show_oops(t, "'cookie delete' currently unimplemented");
 
 	return (0);
@@ -3357,17 +3366,27 @@ js_cmd(struct tab *t, struct karg *args)
 {
 	if (args->i & XT_SHOW)
 		wl_show(t, args, "JavaScript White List", &js_wl);
-	else if (args->i & XT_SAVE)
+	else if (args->i & XT_SAVE) {
+		args->i |= XT_WL_RELOAD;
 		wl_save(t, args, 1);
-	else if (args->i & XT_WL_TOGGLE)
+	} else if (args->i & XT_WL_TOGGLE) {
+		args->i |= XT_WL_RELOAD;
 		toggle_js(t, args);
-	else if (args->i & XT_DELETE)
+	} else if (args->i & XT_DELETE)
 		show_oops(t, "'js delete' currently unimplemented");
 
 	return (0);
 }
 
 int
+toplevel_cmd(struct tab *t, struct karg *args)
+{
+	js_toggle_cb(t->js_toggle, t);
+
+	return (0);
+}
+
+int
 add_favorite(struct tab *t, struct karg *args)
 {
 	char			file[PATH_MAX];
@@ -4655,6 +4674,7 @@ struct key_binding {
 	{ "yankuri",		0,	0,	GDK_y		},
 	{ "pasteuricur",	0,	0,	GDK_p		},
 	{ "pasteurinew",	0,	0,	GDK_P		},
+	{ "toplevel toggle",	0,	0,	GDK_F4		},
 
 	/* search */
 	{ "searchnext",		0,	0,	GDK_n		},
@@ -5007,6 +5027,10 @@ struct cmd {
 	{ "domain",		2,	cookie_cmd,		XT_WL_TOGGLE | XT_WL_TOPLEVEL,			0 },
 	{ "fqdn",		2,	cookie_cmd,		XT_WL_TOGGLE | XT_WL_FQDN,			0 },
 
+	/* toplevel (domain) command */
+	{ "toplevel",		0,	toplevel_cmd,		XT_WL_TOGGLE | XT_WL_TOPLEVEL | XT_WL_RELOAD,	0 },
+	{ "toggle",		1,	toplevel_cmd,		XT_WL_TOGGLE | XT_WL_TOPLEVEL | XT_WL_RELOAD,	0 },
+
 	/* cookie jar */
 	{ "cookiejar",		0,	xtp_page_cl,		0,			0 },
 
diff --git a/xxxterm.conf b/xxxterm.conf
index 4919793..c78db9b 100644
--- a/xxxterm.conf
+++ b/xxxterm.conf
@@ -153,6 +153,7 @@
 # keybinding	= yankuri,y
 # keybinding	= pasteuricur,p
 # keybinding	= pasteurinew,P
+# keybinding	= toplevel toggle,F4
 # keybinding	= searchnext,n
 # keybinding	= searchprevious,N
 # keybinding	= focusaddress,F6