Add support for ephemeral (zero disk access)

This commit is contained in:
Quentin Rameau 2018-10-08 11:37:11 +02:00
parent 6850365d7c
commit f61cfc720c
2 changed files with 19 additions and 8 deletions

View File

@ -29,6 +29,7 @@ static Parameter defconfig[ParameterLast] = {
[DefaultCharset] = { { .v = "UTF-8" }, }, [DefaultCharset] = { { .v = "UTF-8" }, },
[DiskCache] = { { .i = 1 }, }, [DiskCache] = { { .i = 1 }, },
[DNSPrefetch] = { { .i = 0 }, }, [DNSPrefetch] = { { .i = 0 }, },
[Ephemeral] = { { .i = 0 }, },
[FileURLsCrossAccess] = { { .i = 0 }, }, [FileURLsCrossAccess] = { { .i = 0 }, },
[FontSize] = { { .i = 12 }, }, [FontSize] = { { .i = 12 }, },
[FrameFlattening] = { { .i = 0 }, }, [FrameFlattening] = { { .i = 0 }, },

26
surf.c
View File

@ -58,6 +58,7 @@ typedef enum {
DiskCache, DiskCache,
DefaultCharset, DefaultCharset,
DNSPrefetch, DNSPrefetch,
Ephemeral,
FileURLsCrossAccess, FileURLsCrossAccess,
FontSize, FontSize,
FrameFlattening, FrameFlattening,
@ -350,8 +351,11 @@ setup(void)
/* dirs and files */ /* dirs and files */
cookiefile = buildfile(cookiefile); cookiefile = buildfile(cookiefile);
scriptfile = buildfile(scriptfile); scriptfile = buildfile(scriptfile);
cachedir = buildpath(cachedir);
certdir = buildpath(certdir); 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)); 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(); contentmanager = webkit_user_content_manager_new();
context = webkit_web_context_new_with_website_data_manager( if (curconfig[Ephemeral].val.i) {
webkit_website_data_manager_new( context = webkit_web_context_new_ephemeral();
"base-cache-directory", cachedir, } else {
"base-data-directory", cachedir, context = webkit_web_context_new_with_website_data_manager(
NULL)); webkit_website_data_manager_new(
"base-cache-directory", cachedir,
"base-data-directory", cachedir,
NULL));
}
cookiemanager = webkit_web_context_get_cookie_manager(context); cookiemanager = webkit_web_context_get_cookie_manager(context);
@ -1167,8 +1176,9 @@ newview(Client *c, WebKitWebView *rv)
context, *plugindirs); context, *plugindirs);
/* Currently only works with text file to be compatible with curl */ /* Currently only works with text file to be compatible with curl */
webkit_cookie_manager_set_persistent_storage(cookiemanager, if (!curconfig[Ephemeral].val.i)
cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT); webkit_cookie_manager_set_persistent_storage(cookiemanager,
cookiefile, WEBKIT_COOKIE_PERSISTENT_STORAGE_TEXT);
/* cookie policy */ /* cookie policy */
webkit_cookie_manager_set_accept_policy(cookiemanager, webkit_cookie_manager_set_accept_policy(cookiemanager,
cookiepolicy_get()); cookiepolicy_get());