diff --git a/app/ux/WebView.js b/app/ux/WebView.js index 3fbd5475..db1b9449 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -288,8 +288,8 @@ Ext.define('Rambox.ux.WebView',{ webview.addEventListener("did-start-loading", function() { console.info('Start loading...', me.src); - webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => { - Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}) + require('electron').remote.webContents.fromId(webview.getWebContentsId()).session.webRequest.onBeforeSendHeaders((details, callback) => { + Rambox.app.config.googleURLs.forEach((loginURL) => { if ( details.url.indexOf(loginURL) > -1 ) details.requestHeaders['User-Agent'] = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:70.0) Gecko/20100101 Firefox/70.0'}); callback({ cancel: false, requestHeaders: details.requestHeaders }); }); @@ -504,7 +504,6 @@ Ext.define('Rambox.ux.WebView',{ require('electron').shell.openExternal(e.url); } return; - break; default: break; } @@ -551,8 +550,8 @@ Ext.define('Rambox.ux.WebView',{ js_inject += 'document.body.scrollTop=0;'; // Handles Certificate Errors - webview.getWebContents().on('certificate-error', function(event, url, error, certificate, callback) { - if ( me.record.get('trust') ) { + require('electron').remote.webContents.fromId(webview.getWebContentsId()).on('certificate-error', function(event, url, error, certificate, callback) { + if (me.record.get('trust')) { event.preventDefault(); callback(true); } else { @@ -562,25 +561,25 @@ Ext.define('Rambox.ux.WebView',{ me.down('statusbar').keep = true; me.down('statusbar').show(); me.down('statusbar').setStatus({ - text: ' Certification Warning' + text: ' Certification Warning', }); me.down('statusbar').down('button').show(); }); if (!eventsOnDom) { - webview.getWebContents().on('before-input-event', (event, input) => { + require('electron').remote.webContents.fromId(webview.getWebContentsId()).on('before-input-event', (event, input) => { if (input.type !== 'keyDown') return; var modifiers = []; - if ( input.shift ) modifiers.push('shift'); - if ( input.control ) modifiers.push('control'); - if ( input.alt ) modifiers.push('alt'); - if ( input.meta ) modifiers.push('meta'); - if ( input.isAutoRepeat ) modifiers.push('isAutoRepeat'); + if (input.shift) modifiers.push('shift'); + if (input.control) modifiers.push('control'); + if (input.alt) modifiers.push('alt'); + if (input.meta) modifiers.push('meta'); + if (input.isAutoRepeat) modifiers.push('isAutoRepeat'); - if ( input.key === 'Tab' && !(modifiers && modifiers.length) ) return; + if (input.key === 'Tab' && !(modifiers && modifiers.length)) return; // Maps special keys to fire the correct event in Mac OS - if ( require('electron').remote.process.platform === 'darwin' ) { + if (require('electron').remote.process.platform === 'darwin') { var keys = []; keys['ƒ'] = 'f'; // Search keys[' '] = 'l'; // Lock @@ -589,14 +588,22 @@ Ext.define('Rambox.ux.WebView',{ input.key = keys[input.key] ? keys[input.key] : input.key; } - if ( input.key === 'F11' || input.key === 'a' || input.key === 'A' || input.key === 'F12' || input.key === 'q' || (input.key === 'F1' && modifiers.includes('control'))) return; + if ( + input.key === 'F11' || + input.key === 'a' || + input.key === 'A' || + input.key === 'F12' || + input.key === 'q' || + (input.key === 'F1' && modifiers.includes('control')) + ) + return; require('electron').remote.getCurrentWebContents().sendInputEvent({ type: input.type, keyCode: input.key, - modifiers: modifiers + modifiers: modifiers, }); - }) + }); eventsOnDom = true; Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) diff --git a/app/view/main/MainController.js b/app/view/main/MainController.js index d3bd3d57..c7a41106 100644 --- a/app/view/main/MainController.js +++ b/app/view/main/MainController.js @@ -162,11 +162,15 @@ Ext.define('Rambox.view.main.MainController', { if ( config.default_service === rec.get('id') ) ipc.send('setConfig', Ext.apply(config, { default_service: 'ramboxTab' })); function clearData(webview, tab) { - webview.getWebContents().clearHistory(); - webview.getWebContents().session.flushStorageData(); - webview.getWebContents().session.clearCache().then(() => { - webview.getWebContents().session.clearStorageData().then(() => { - webview.getWebContents().session.cookies.flushStore().then(() => { + const currentWebView = require("electron").remote.webContents.fromId( + webview.getWebContentsId() + ); + + currentWebView.clearHistory(); + currentWebView.session.flushStorageData(); + currentWebView.session.clearCache().then(() => { + currentWebView.session.clearStorageData().then(() => { + currentWebView.session.cookies.flushStore().then(() => { // Remove record from localStorage Ext.getStore('Services').remove(rec); // Close tab diff --git a/electron/main.js b/electron/main.js index 43183f95..de77e69c 100644 --- a/electron/main.js +++ b/electron/main.js @@ -102,7 +102,8 @@ function createWindow () { ,show: !config.get('start_minimized') ,acceptFirstMouse: true ,webPreferences: { - plugins: true + enableRemoteModule: true + ,plugins: true ,partition: 'persist:rambox' ,nodeIntegration: true ,webviewTag: true diff --git a/package.json b/package.json index 6be616f0..4028642b 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "afterSign": "resources/installer/notarize.js", "asar": true, "electronDownload": { - "version": "7.2.4" + "version": "11.0.2" }, "mac": { "category": "public.app-category.productivity", @@ -200,10 +200,10 @@ "chai": "3.5.0", "crowdin": "1.0.0", "csvjson": "4.3.3", - "electron": "7.2.4", - "electron-builder": "21.2.0", - "electron-notarize": "0.2.1", - "electron-packager": "12.1.0", + "electron": "11.0.2", + "electron-builder": "22.9.1", + "electron-notarize": "1.0.0", + "electron-packager": "15.1.0", "mocha": "5.2.0", "spectron": "3.8.0" }, @@ -212,12 +212,11 @@ "auth0-js": "9.13.2", "auto-launch-patched": "5.0.2", "crypto": "1.0.1", - "diskusage": "1.1.3", - "electron-contextmenu-wrapper": "2.0.0", - "electron-is-dev": "0.3.0", - "electron-log": "2.2.17", - "electron-store": "6.0.0", - "electron-updater": "4.1.2", + "electron-contextmenu-wrapper": "4.0.1", + "electron-is-dev": "1.2.0", + "electron-log": "4.3.0", + "electron-store": "6.0.1", + "electron-updater": "4.3.5", "is-online": "8.2.0", "mime": "2.3.1", "mousetrap": "1.6.3", @@ -227,6 +226,6 @@ "tmp": "0.0.28" }, "volta": { - "node": "8.9.1" + "node": "14.16.1" } }