Browse Source

Merge pull request #2897 from mhatvan/chore/update-electron

Update Electron
pull/3102/head
Ramiro Saenz 4 years ago committed by GitHub
parent
commit
5e94ebf0e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      app/ux/WebView.js
  2. 14
      app/view/main/MainController.js
  3. 3
      electron/main.js
  4. 23
      package.json

25
app/ux/WebView.js

@ -288,8 +288,8 @@ Ext.define('Rambox.ux.WebView',{
webview.addEventListener("did-start-loading", function() { webview.addEventListener("did-start-loading", function() {
console.info('Start loading...', me.src); console.info('Start loading...', me.src);
webview.getWebContents().session.webRequest.onBeforeSendHeaders((details, callback) => { 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'}) 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 }); callback({ cancel: false, requestHeaders: details.requestHeaders });
}); });
@ -504,7 +504,6 @@ Ext.define('Rambox.ux.WebView',{
require('electron').shell.openExternal(e.url); require('electron').shell.openExternal(e.url);
} }
return; return;
break;
default: default:
break; break;
} }
@ -551,7 +550,7 @@ Ext.define('Rambox.ux.WebView',{
js_inject += 'document.body.scrollTop=0;'; js_inject += 'document.body.scrollTop=0;';
// Handles Certificate Errors // Handles Certificate Errors
webview.getWebContents().on('certificate-error', function(event, url, error, certificate, callback) { require('electron').remote.webContents.fromId(webview.getWebContentsId()).on('certificate-error', function(event, url, error, certificate, callback) {
if (me.record.get('trust')) { if (me.record.get('trust')) {
event.preventDefault(); event.preventDefault();
callback(true); callback(true);
@ -562,12 +561,12 @@ Ext.define('Rambox.ux.WebView',{
me.down('statusbar').keep = true; me.down('statusbar').keep = true;
me.down('statusbar').show(); me.down('statusbar').show();
me.down('statusbar').setStatus({ me.down('statusbar').setStatus({
text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning' text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning',
}); });
me.down('statusbar').down('button').show(); me.down('statusbar').down('button').show();
}); });
if (!eventsOnDom) { 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; if (input.type !== 'keyDown') return;
var modifiers = []; var modifiers = [];
@ -589,14 +588,22 @@ Ext.define('Rambox.ux.WebView',{
input.key = keys[input.key] ? keys[input.key] : input.key; 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({ require('electron').remote.getCurrentWebContents().sendInputEvent({
type: input.type, type: input.type,
keyCode: input.key, keyCode: input.key,
modifiers: modifiers modifiers: modifiers,
});
}); });
})
eventsOnDom = true; eventsOnDom = true;
Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() }) Rambox.app.config.googleURLs.forEach((loginURL) => { if ( webview.getURL().indexOf(loginURL) > -1 ) webview.reload() })

14
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' })); if ( config.default_service === rec.get('id') ) ipc.send('setConfig', Ext.apply(config, { default_service: 'ramboxTab' }));
function clearData(webview, tab) { function clearData(webview, tab) {
webview.getWebContents().clearHistory(); const currentWebView = require("electron").remote.webContents.fromId(
webview.getWebContents().session.flushStorageData(); webview.getWebContentsId()
webview.getWebContents().session.clearCache().then(() => { );
webview.getWebContents().session.clearStorageData().then(() => {
webview.getWebContents().session.cookies.flushStore().then(() => { currentWebView.clearHistory();
currentWebView.session.flushStorageData();
currentWebView.session.clearCache().then(() => {
currentWebView.session.clearStorageData().then(() => {
currentWebView.session.cookies.flushStore().then(() => {
// Remove record from localStorage // Remove record from localStorage
Ext.getStore('Services').remove(rec); Ext.getStore('Services').remove(rec);
// Close tab // Close tab

3
electron/main.js

@ -102,7 +102,8 @@ function createWindow () {
,show: !config.get('start_minimized') ,show: !config.get('start_minimized')
,acceptFirstMouse: true ,acceptFirstMouse: true
,webPreferences: { ,webPreferences: {
plugins: true enableRemoteModule: true
,plugins: true
,partition: 'persist:rambox' ,partition: 'persist:rambox'
,nodeIntegration: true ,nodeIntegration: true
,webviewTag: true ,webviewTag: true

23
package.json

@ -67,7 +67,7 @@
"afterSign": "resources/installer/notarize.js", "afterSign": "resources/installer/notarize.js",
"asar": true, "asar": true,
"electronDownload": { "electronDownload": {
"version": "7.2.4" "version": "11.0.2"
}, },
"mac": { "mac": {
"category": "public.app-category.productivity", "category": "public.app-category.productivity",
@ -200,10 +200,10 @@
"chai": "3.5.0", "chai": "3.5.0",
"crowdin": "1.0.0", "crowdin": "1.0.0",
"csvjson": "4.3.3", "csvjson": "4.3.3",
"electron": "7.2.4", "electron": "11.0.2",
"electron-builder": "21.2.0", "electron-builder": "22.9.1",
"electron-notarize": "0.2.1", "electron-notarize": "1.0.0",
"electron-packager": "12.1.0", "electron-packager": "15.1.0",
"mocha": "5.2.0", "mocha": "5.2.0",
"spectron": "3.8.0" "spectron": "3.8.0"
}, },
@ -212,12 +212,11 @@
"auth0-js": "9.13.2", "auth0-js": "9.13.2",
"auto-launch-patched": "5.0.2", "auto-launch-patched": "5.0.2",
"crypto": "1.0.1", "crypto": "1.0.1",
"diskusage": "1.1.3", "electron-contextmenu-wrapper": "4.0.1",
"electron-contextmenu-wrapper": "2.0.0", "electron-is-dev": "1.2.0",
"electron-is-dev": "0.3.0", "electron-log": "4.3.0",
"electron-log": "2.2.17", "electron-store": "6.0.1",
"electron-store": "6.0.0", "electron-updater": "4.3.5",
"electron-updater": "4.1.2",
"is-online": "8.2.0", "is-online": "8.2.0",
"mime": "2.3.1", "mime": "2.3.1",
"mousetrap": "1.6.3", "mousetrap": "1.6.3",
@ -227,6 +226,6 @@
"tmp": "0.0.28" "tmp": "0.0.28"
}, },
"volta": { "volta": {
"node": "8.9.1" "node": "14.16.1"
} }
} }

Loading…
Cancel
Save