commit df1b4288031f4133974fb2d17c47ae110166c901
parent de099ce636e90fa2ffa9ef54d3deb4597f60305e
Author: Christoph Lohmann <20h@r-36.net>
Date: Fri, 21 Apr 2017 21:20:32 +0200
Allow the page cache and private browsing to be configured.
Diffstat:
3 files changed, 36 insertions(+), 4 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -34,6 +34,11 @@ static int diskcachebytes = 5 * 1024 * 1024;
static Bool enablescrollbars = TRUE;
static Bool enablespatialbrowsing = TRUE;
static Bool enableplugins = TRUE;
+static Bool enablepagecache = TRUE; /* Enable cache of pages in current
+ * history. This will save memory
+ * if you do not have any. */
+static Bool privatebrowsing = FALSE; /* Set default value for private
+ * browsing. */
static Bool enablescripts = TRUE;
static Bool enableinspector = TRUE;
static Bool enablestyle = TRUE;
@@ -182,6 +187,7 @@ static Key keys[] = {
{ MODKEY|GDK_SHIFT_MASK,GDK_v, toggle, { .v = "enable-plugins" } },
{ MODKEY|GDK_SHIFT_MASK,GDK_l, toggle, { .v = "enable-display-of-insecure-content" } },
{ MODKEY|GDK_SHIFT_MASK,GDK_t, togglesoup, { .v = "ssl-strict" } },
+ { MODKEY|GDK_SHIFT_MASK,GDK_w, toggle, { .v = "enable-private-browsing" } },
{ MODKEY|GDK_SHIFT_MASK,GDK_a, togglecookiepolicy, { 0 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_m, togglestyle, { 0 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_b, togglescrollbars, { 0 } },
diff --git a/surf.1 b/surf.1
@@ -3,7 +3,7 @@
surf \- simple webkit-based browser
.SH SYNOPSIS
.B surf
-.RB [-bBdDfFgGiIkKmLlMnNpPsStTvx]
+.RB [-bBdDfFgGiIkKlLmMnNpPsStTvwWx]
.RB [-a\ cookiepolicies]
.RB [-c\ cookiefile]
.RB [-e\ xid]
@@ -122,6 +122,12 @@ which surf should use.
.B \-v
Prints version information to standard output, then exits.
.TP
+.B \-w
+Disable private browsing.
+.TP
+.B \-W
+Enable private browsing.
+.TP
.B \-x
Prints xid to standard output. This can be used to script the browser in for
example
diff --git a/surf.c b/surf.c
@@ -109,7 +109,7 @@ static GdkNativeWindow embed = 0;
static gboolean showxid = FALSE;
static char winid[64];
static gboolean usingproxy = 0;
-static char togglestat[11];
+static char togglestat[12];
static char pagestat[3];
static GTlsDatabase *tlsdb;
static int policysel = 0;
@@ -1070,6 +1070,10 @@ newclient(void)
g_object_set(G_OBJECT(settings),
"enable-offline-web-application-cache",
offlineappcache, NULL);
+ g_object_set(G_OBJECT(settings),
+ "enable-page-cache", enablepagecache, NULL);
+ g_object_set(G_OBJECT(settings),
+ "enable-private-browsing", privatebrowsing, NULL);
g_object_set(G_OBJECT(settings), "enable-dns-prefetching",
dnsprefetching, NULL);
if (!(ua = getenv("SURF_USERAGENT")))
@@ -1171,7 +1175,7 @@ void
newwindow(Client *c, const Arg *arg, gboolean noembed)
{
guint i = 0;
- const char *cmd[29], *uri;
+ const char *cmd[30], *uri;
const Arg a = { .v = (void *)cmd };
char tmp[64], ztmp[6];
@@ -1263,6 +1267,12 @@ newwindow(Client *c, const Arg *arg, gboolean noembed)
cmd[i++] = useragent;
}
+ if (privatebrowsing)
+ cmd[i++] = "-W";
+ else
+ cmd[i++] = "-w";
+
+
if (showxid)
cmd[i++] = "-x";
@@ -1804,6 +1814,10 @@ gettogglestat(Client *c)
g_object_get(G_OBJECT(settings), "enable-plugins", &value, NULL);
togglestat[p++] = value? 'V': 'v';
+ g_object_get(G_OBJECT(settings), "enable-private-browsing", &value,
+ NULL);
+ togglestat[p++] = value? 'W': 'w';
+
togglestat[p] = '\0';
}
@@ -1860,7 +1874,7 @@ updatewinid(Client *c)
void
usage(void)
{
- die("usage: %s [-bBdDfFgGiIkKlLmMnNpPsStTvx] [-a cookiepolicies ] "
+ die("usage: %s [-bBdDfFgGiIkKlLmMnNpPsStTvwWx] [-a cookiepolicies ] "
"[-c cookiefile] [-e xid] [-r scriptfile] [-y stylefile] "
"[-u useragent] [-z zoomlevel] [uri]\n", basename(argv0));
}
@@ -1992,6 +2006,12 @@ main(int argc, char *argv[])
case 'v':
die("surf-"VERSION", ©2009-2016 surf engineers, "
"see LICENSE for details\n");
+ case 'w':
+ privatebrowsing = 0;
+ break;
+ case 'W':
+ privatebrowsing = 1;
+ break;
case 'x':
showxid = TRUE;
break;