From 6557ae0a2be27931401da6e5f2543d561963df91 Mon Sep 17 00:00:00 2001 From: Bastien Nocera <hadess@hadess.net> Date: Thu, 23 Mar 2017 16:54:28 +0100 Subject: [PATCH] portalHelper: Simplify our non-use of cache Instead of using directories that we'll destroy when done, use the new "ephemeral" data manager feature, through the JavaScript version of: webkit_web_context_new_ephemeral() We also throw an error on startup, in the logs, if WebKitGTK is too old. https://bugzilla.gnome.org/show_bug.cgi?id=780453 --- js/portalHelper/main.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/portalHelper/main.js b/js/portalHelper/main.js index 84eed5754..f64cae49b 100644 --- a/js/portalHelper/main.js +++ b/js/portalHelper/main.js @@ -12,7 +12,6 @@ const WebKit = imports.gi.WebKit2; const _ = Gettext.gettext; const Config = imports.misc.config; -const FileUtils = imports.misc.fileUtils; const PortalHelperResult = { CANCELLED: 0, @@ -141,12 +140,8 @@ const PortalWindow = new Lang.Class({ this._doneCallback = doneCallback; this._lastRecheck = 0; this._recheckAtExit = false; - let cacheDir = GLib.Dir.make_tmp("gnome-shell-portal-helper-XXXXXXXX"); - this._cacheDir = Gio.File.new_for_path(cacheDir); - let dataManager = new WebKit.WebsiteDataManager({ base_data_directory: cacheDir, - base_cache_directory: cacheDir }); - this._webContext = new WebKit.WebContext({ website_data_manager: dataManager }); + this._webContext = WebKit.WebContext.new_ephemeral(); this._webContext.set_cache_model(WebKit.CacheModel.DOCUMENT_VIEWER); this._webView = WebKit.WebView.new_with_context(this._webContext); @@ -169,7 +164,6 @@ const PortalWindow = new Lang.Class({ destroyWindow: function() { this.destroy(); - FileUtils.recursivelyDeleteDir(this._cacheDir, true); }, _syncUri: function() { @@ -363,6 +357,11 @@ function initEnvironment() { function main(argv) { initEnvironment(); + if (!WebKit.WebContext.new_ephemeral) { + log('WebKitGTK 2.16 is required for the portal-helper, see https://bugzilla.gnome.org/show_bug.cgi?id=780453'); + return 1; + } + Gettext.bindtextdomain(Config.GETTEXT_PACKAGE, Config.LOCALEDIR); Gettext.textdomain(Config.GETTEXT_PACKAGE);