about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Rameau <quinq@fifth.space>2018-10-08 11:37:11 +0200
committerQuentin Rameau <quinq@fifth.space>2020-11-01 16:59:12 +0100
commitf61cfc720c598491d7a93c9f314ceae349e00450 (patch)
treeceea76deb6642803206b11e1e965b65d86ca709a
parentAdd support for configuring plugins directories (diff)
downloadsurf-f61cfc720c598491d7a93c9f314ceae349e00450.tar.gz
surf-f61cfc720c598491d7a93c9f314ceae349e00450.tar.bz2
surf-f61cfc720c598491d7a93c9f314ceae349e00450.zip
Add support for ephemeral (zero disk access)
-rw-r--r--config.def.h1
-rw-r--r--surf.c26
2 files changed, 19 insertions, 8 deletions
diff --git a/config.def.h b/config.def.h
index 738f464..be168ab 100644
--- a/config.def.h
+++ b/config.def.h
@@ -29,6 +29,7 @@ static Parameter defconfig[ParameterLast] = {
 	[DefaultCharset]      =       { { .v = "UTF-8" }, },
 	[DiskCache]           =       { { .i = 1 },     },
 	[DNSPrefetch]         =       { { .i = 0 },     },
+	[Ephemeral]           =       { { .i = 0 },     },
 	[FileURLsCrossAccess] =       { { .i = 0 },     },
 	[FontSize]            =       { { .i = 12 },    },
 	[FrameFlattening]     =       { { .i = 0 },     },
diff --git a/surf.c b/surf.c
index 2d25fa4..edaf348 100644
--- a/surf.c
+++ b/surf.c
@@ -58,6 +58,7 @@ typedef enum {
 	DiskCache,
 	DefaultCharset,
 	DNSPrefetch,
+	Ephemeral,
 	FileURLsCrossAccess,
 	FontSize,
 	FrameFlattening,
@@ -350,8 +351,11 @@ setup(void)
 	/* dirs and files */
 	cookiefile = buildfile(cookiefile);
 	scriptfile = buildfile(scriptfile);
-	cachedir   = buildpath(cachedir);
 	certdir    = buildpath(certdir);
+	if (curconfig[Ephemeral].val.i)
+		cachedir = NULL;
+	else
+		cachedir   = buildpath(cachedir);
 
 	gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
 
@@ -1141,11 +1145,16 @@ newview(Client *c, WebKitWebView *rv)
 
 		contentmanager = webkit_user_content_manager_new();
 
-		context = webkit_web_context_new_with_website_data_manager(
-		          webkit_website_data_manager_new(
-		          "base-cache-directory", cachedir,
-		          "base-data-directory", cachedir,
-		          NULL));
+		if (curconfig[Ephemeral].val.i) {
+			context = webkit_web_context_new_ephemeral();
+		} else {
+			context = webkit_web_context_new_with_website_data_manager(
+			          webkit_website_data_manager_new(
+			          "base-cache-directory", cachedir,
+			          "base-data-directory", cachedir,
+			          NULL));
+		}
+
 
 		cookiemanager = webkit_web_context_get_cookie_manager(context);
 
@@ -1167,8 +1176,9 @@ newview(Client *c, WebKitWebView *rv)
 			    context, *plugindirs);
 
 		/* Currently only works with text file to be compatible with curl */
-		webkit_cookie_manager_set_persistent_storage(cookiemanager,
-		    cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
+		if (!curconfig[Ephemeral].val.i)
+			webkit_cookie_manager_set_persistent_storage(cookiemanager,
+			    cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
 		/* cookie policy */
 		webkit_cookie_manager_set_accept_policy(cookiemanager,
 		    cookiepolicy_get());