From 1d4c7e4876cc5b7fe86c1b03716dc2ce7fe2a03f Mon Sep 17 00:00:00 2001 From: Alice Gaudon Date: Tue, 26 May 2020 10:20:14 +0200 Subject: [PATCH] Disable unused features in webviews --- src/Application.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Application.ts b/src/Application.ts index eb05399..16dc94d 100644 --- a/src/Application.ts +++ b/src/Application.ts @@ -62,6 +62,16 @@ export default class Application { }); } }); + + // Disable unused features + app.on('web-contents-created', (e, contents) => { + contents.on('will-attach-webview', (e, webPreferences, params) => { + delete webPreferences.preload; + webPreferences.nodeIntegration = false; + + // TODO: Here would be a good place to filter accessed urls (params.src). Also consider 'will-navigate' event on contents. + }); + }); } private setupSystemTray() {