Browse Source

Updated Electron and fixed some major bugs

pull/3102/head
Ramiro Saenz 4 years ago
parent
commit
c91ef575e3
  1. 3
      app/ux/Auth0.js
  2. 145
      app/ux/WebView.js
  3. 81
      electron/main.js
  4. 19
      package.json

3
app/ux/Auth0.js

@ -253,7 +253,8 @@ Ext.define('Rambox.ux.Auth0', {
,height: 600 ,height: 600
,maximizable: false ,maximizable: false
,minimizable: false ,minimizable: false
,resizable: false ,resizable: true
,closable: true
,center: true ,center: true
,autoHideMenuBar: true ,autoHideMenuBar: true
,skipTaskbar: true ,skipTaskbar: true

145
app/ux/WebView.js

@ -35,9 +35,6 @@ Ext.define('Rambox.ux.WebView',{
} }
} }
// Allow Custom sites with self certificates
//if ( me.record.get('trust') ) ipc.send('allowCertificate', me.src);
const prefConfig = ipc.sendSync('getConfig'); const prefConfig = ipc.sendSync('getConfig');
Ext.apply(me, { Ext.apply(me, {
items: me.webViewConstructor() items: me.webViewConstructor()
@ -216,14 +213,13 @@ Ext.define('Rambox.ux.WebView',{
,plugins: 'true' ,plugins: 'true'
,allowtransparency: 'on' ,allowtransparency: 'on'
,autosize: 'on' ,autosize: 'on'
,webpreferences: '' //,nativeWindowOpen=yes ,webpreferences: 'nativeWindowOpen=yes, spellcheck=no, contextIsolation=no'
//,disablewebsecurity: 'on' // Disabled because some services (Like Google Drive) dont work with this enabled ,allowpopups: 'on'
// ,disablewebsecurity: 'on' // Disabled because some services (Like Google Drive) dont work with this enabled
,useragent: me.getUserAgent() ,useragent: me.getUserAgent()
,preload: './resources/js/rambox-service-api.js' ,preload: './resources/js/rambox-service-api.js'
} }
}]; }];
if ( Ext.getStore('ServicesList').getById(this.record.get('type')) ? Ext.getStore('ServicesList').getById(me.record.get('type')).get('allow_popups') : false ) cfg[0].autoEl.allowpopups = 'on';
} }
return cfg; return cfg;
@ -380,139 +376,12 @@ Ext.define('Rambox.ux.WebView',{
// Open links in default browser // Open links in default browser
webview.addEventListener('new-window', function(e) { webview.addEventListener('new-window', function(e) {
switch ( me.type ) {
case 'skype':
// hack to fix multiple browser tabs on Skype link click, re #11
if ( require('url').parse(me.down('statusbar #url').html).protocol !== null ) {
e.url = me.down('statusbar #url').html;
} else if ( e.url.indexOf('imgpsh_fullsize') >= 0 ) {
ipc.send('image:download', e.url, e.target.partition);
e.preventDefault();
return;
}
break;
case 'hangouts':
e.preventDefault();
if ( e.url.indexOf('plus.google.com/u/0/photos/albums') >= 0 ) {
ipc.send('image:popup', e.url, e.target.partition);
return;
} else if ( e.url.indexOf('/el/CONVERSATION/') >= 0 ) {
me.add({
xtype: 'window'
,title: 'Video Call'
,width: '80%'
,height: '80%'
,maximizable: true
,resizable: true
,draggable: true
,collapsible: true
,items: {
xtype: 'component'
,hideMode: 'offsets'
,autoRender: true
,autoShow: true
,autoEl: {
tag: 'webview'
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: me.getUserAgent()
}
}
}).show();
return;
}
break;
case 'slack':
if ( e.url.indexOf('slack.com/call/') >= 0 ) {
me.add({
xtype: 'window'
,title: e.options.title
,width: e.options.width
,height: e.options.height
,maximizable: true
,resizable: true
,draggable: true
,collapsible: true
,items: {
xtype: 'component'
,hideMode: 'offsets'
,autoRender: true
,autoShow: true
,autoEl: {
tag: 'webview'
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: me.getUserAgent()
}
}
}).show();
e.preventDefault(); e.preventDefault();
return;
}
break;
case 'icloud':
if ( e.url.indexOf('index.html#compose') >= 0 ) {
me.add({
xtype: 'window'
,title: 'iCloud - Compose'
,width: 700
,height: 500
,maximizable: true
,resizable: true
,draggable: true
,collapsible: true
,items: {
xtype: 'component'
,itemId: 'webview'
,hideMode: 'offsets'
,autoRender: true
,autoShow: true
,autoEl: {
tag: 'webview'
,src: e.url
,style: 'width:100%;height:100%;'
,partition: me.getWebView().partition
,useragent: me.getUserAgent()
,preload: './resources/js/rambox-modal-api.js'
}
}
,listeners: {
show: function(win) {
const webview = win.down('#webview').el.dom;
webview.addEventListener('ipc-message', function(event) {
var channel = event.channel;
switch (channel) {
case 'close':
win.close();
break;
default:
break;
}
});
}
}
}).show();
e.preventDefault();
return;
}
break;
case 'flowdock':
if ( e.disposition === 'new-window' ) {
e.preventDefault();
require('electron').shell.openExternal(e.url);
}
return;
default:
break;
}
const protocol = require('url').parse(e.url).protocol; const protocol = require('url').parse(e.url).protocol;
if (protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:') { // Block some Deep links to prevent that open its app (Ex: Slack)
e.preventDefault(); if ( ['slack:'].includes(protocol) ) return;
require('electron').shell.openExternal(e.url); // Allow Deep links
} if ( !['http:', 'https:', 'about:'].includes(protocol) ) return require('electron').shell.openExternal(e.url);
}); });
webview.addEventListener('will-navigate', function(e, url) { webview.addEventListener('will-navigate', function(e, url) {

81
electron/main.js

@ -107,6 +107,8 @@ function createWindow () {
,partition: 'persist:rambox' ,partition: 'persist:rambox'
,nodeIntegration: true ,nodeIntegration: true
,webviewTag: true ,webviewTag: true
,contextIsolation: false
,spellcheck: false
} }
}); });
@ -386,6 +388,85 @@ app.on('second-instance', (event, commandLine, workingDirectory) => {
} }
}); });
// ALLOWED URLS POPUPS
let allowPopUp = [
'feedly.com/v3/auth/',
'identity.linuxfoundation.org/cas/login',
'auth.missiveapp.com',
'accounts.google.com/AccountChooser',
'facebook.com/v3.1/dialog/oauth?',
'accounts.google.com/o/oauth2',
'app.slack.com/files/import/gdrive',
'spikenow.com/s/account',
'app.mixmax.com/_oauth/google',
'officeapps.live.com',
'dropbox.com/profile_services/start_auth_flow',
'facebook.com/v3.2/dialog/oauth?',
'notion.so/googlepopupredirect',
'zoom.us/office365',
'figma.com/start_google_sso',
'mail.google.com/mail',
'app.slack.com/free-willy/',
'messenger.com/videocall',
'api.moo.do',
'manychat.com/fb?popup',
'=?print=true' // esta ultima checkea como anda imprimir un pedf desde gmail, si no va bie sacala
];
app.on('web-contents-created', (webContentsCreatedEvent, contents) => {
if (contents.getType() !== 'webview') return;
// Block some Deep links to prevent that open its app (Ex: Slack)
contents.on('will-navigate', (event, url) => url.substring(0, 8) === 'slack://' && event.preventDefault());
// New Window handler
contents.on('new-window', (event, url, frameName, disposition, options, additionalFeatures, referrer, postBody) => {
// If the url is about:blank we allow the window and handle it in 'did-create-window'
if (['about:blank', 'about:blank#blocked'].includes(url)) {
event.preventDefault();
Object.assign(options, { show: false });
const win = new BrowserWindow(options);
win.center();
let once = false;
win.webContents.on('will-navigate', (e, nextURL) => {
if (once) return;
if (['about:blank', 'about:blank#blocked'].includes(nextURL)) return;
once = true;
let allow = false;
allowPopUp.forEach(url => nextURL.indexOf(url) > -1 && (allow = true));
// If the url is in aboutBlankOnlyWindow we handle this as a popup window
if (allow) return win.show();
shell.openExternal(nextURL);
win.close()
})
event.newGuest = win;
return;
}
// We check if url is in the allowPopUpLoginURLs or allowForegroundTabURLs in Firebase to open a as a popup,
// if it is not we send this to the app
let allow = false;
allowPopUp.forEach(allowed => url.indexOf(allowed) > -1 && (allow = true));
if (allow) return;
shell.openExternal(url);
event.preventDefault();
});
contents.on('did-create-window', (win, details) => {
// Here we center the new window.
win.center();
// The following code is for handling the about:blank cases only.
if (!['about:blank', 'about:blank#blocked'].includes(details.url)) return;
let once = false;
win.webContents.on('will-navigate', (e, nextURL) => {
if (once) return;
if (['about:blank', 'about:blank#blocked'].includes(nextURL)) return;
once = true;
let allow = false;
allowPopUp.forEach(url => nextURL.indexOf(url) > -1 && (allow = true));
// If the url is in aboutBlankOnlyWindow we handle this as a popup window
if (allow) return win.show();
shell.openExternal(url);
win.close();
});
});
});
// Code for downloading images as temporal files // Code for downloading images as temporal files
// Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype) // Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype)

19
package.json

@ -1,7 +1,7 @@
{ {
"name": "Rambox", "name": "Rambox",
"productName": "Rambox", "productName": "Rambox",
"version": "0.7.7", "version": "0.7.8",
"description": "Free and Open Source messaging and emailing app that combines common web applications into one.", "description": "Free and Open Source messaging and emailing app that combines common web applications into one.",
"main": "electron/main.js", "main": "electron/main.js",
"repository": { "repository": {
@ -66,8 +66,9 @@
"appId": "com.grupovrs.ramboxce", "appId": "com.grupovrs.ramboxce",
"afterSign": "resources/installer/notarize.js", "afterSign": "resources/installer/notarize.js",
"asar": true, "asar": true,
"electronVersion": "11.4.10",
"electronDownload": { "electronDownload": {
"version": "11.0.2" "version": "11.4.10"
}, },
"mac": { "mac": {
"category": "public.app-category.productivity", "category": "public.app-category.productivity",
@ -127,10 +128,14 @@
"camera", "camera",
"audio-record", "audio-record",
"audio-playback", "audio-playback",
"removable-media" "removable-media",
"raw-usb",
"u2f-devices",
"cups-control"
] ]
}, },
"linux": { "linux": {
"icon": "resources/installer/icons",
"category": "Network", "category": "Network",
"desktop": { "desktop": {
"Terminal": "false", "Terminal": "false",
@ -138,6 +143,9 @@
"Categories": "GTK;GNOME;Network;Email;Chat;InstantMessaging;" "Categories": "GTK;GNOME;Network;Email;Chat;InstantMessaging;"
}, },
"artifactName": "Rambox-${version}-linux-${arch}.${ext}", "artifactName": "Rambox-${version}-linux-${arch}.${ext}",
"executableArgs": [
"--no-sandbox"
],
"target": [ "target": [
{ {
"target": "snap", "target": "snap",
@ -200,7 +208,7 @@
"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": "11.0.2", "electron": "11.4.10",
"electron-builder": "22.9.1", "electron-builder": "22.9.1",
"electron-notarize": "1.0.0", "electron-notarize": "1.0.0",
"electron-packager": "15.1.0", "electron-packager": "15.1.0",
@ -212,7 +220,8 @@
"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",
"electron-contextmenu-wrapper": "4.0.1", "diskusage": "1.1.3",
"electron-contextmenu-wrapper": "git+https://github.com/ramboxapp/electron-contextmenu-wrapper.git",
"electron-is-dev": "1.2.0", "electron-is-dev": "1.2.0",
"electron-log": "4.3.0", "electron-log": "4.3.0",
"electron-store": "6.0.1", "electron-store": "6.0.1",

Loading…
Cancel
Save