Browse Source

Fixed Certification Warning and added URL display on mouse over

Fixes #573
Fixes #588
Fixes #587
Fixes #585
Fixes #506
Fixes #576
pull/594/merge
Ramiro Saenz 8 years ago
parent
commit
1643172425
  1. 2
      app/model/Service.js
  2. 47
      app/ux/WebView.js
  3. 2
      app/view/add/Add.js
  4. 18
      app/view/add/AddController.js
  5. 22
      electron/main.js
  6. 8
      packages/local/rambox-default-theme/sass/etc/all.scss

2
app/model/Service.js

@ -48,7 +48,7 @@ Ext.define('Rambox.model.Service', {
},{ },{
name: 'trust' name: 'trust'
,type: 'boolean' ,type: 'boolean'
,defaultValue: false ,defaultValue: true
},{ },{
name: 'enabled' name: 'enabled'
,type: 'boolean' ,type: 'boolean'

47
app/ux/WebView.js

@ -6,9 +6,9 @@ Ext.define('Rambox.ux.WebView',{
,xtype: 'webview' ,xtype: 'webview'
,requires: [ ,requires: [
'Rambox.util.Format', 'Rambox.util.Format'
'Rambox.util.Notifier', ,'Rambox.util.Notifier'
'Rambox.util.UnreadCounter' ,'Rambox.util.UnreadCounter'
] ]
// private // private
@ -34,7 +34,7 @@ Ext.define('Rambox.ux.WebView',{
} }
// Allow Custom sites with self certificates // Allow Custom sites with self certificates
if ( me.record.get('trust') ) ipc.send('allowCertificate', me.src); //if ( me.record.get('trust') ) ipc.send('allowCertificate', me.src);
Ext.apply(me, { Ext.apply(me, {
items: me.webViewConstructor() items: me.webViewConstructor()
@ -123,6 +123,18 @@ Ext.define('Rambox.ux.WebView',{
] ]
} }
} }
,bbar: {
xtype: 'statusbar'
,defaultText: '<i class="fa fa-check fa-fw" aria-hidden="true"></i> Ready'
,busyIconCls : ''
,busyText: '<i class="fa fa-circle-o-notch fa-spin fa-fw"></i> Loading...'
,items: [
,{
xtype: 'tbtext'
,itemId: 'url'
}
]
}
,listeners: { ,listeners: {
afterrender: me.onAfterRender afterrender: me.onAfterRender
} }
@ -186,17 +198,15 @@ Ext.define('Rambox.ux.WebView',{
// Show and hide spinner when is loading // Show and hide spinner when is loading
webview.addEventListener("did-start-loading", function() { webview.addEventListener("did-start-loading", function() {
console.info('Start loading...', me.src); console.info('Start loading...', me.src);
me.mask('Loading...', 'bottomMask'); me.down('statusbar').showBusy();
// Manually remove modal from mask
Ext.cq1('#'+me.id).el.dom.getElementsByClassName('bottomMask')[0].parentElement.className = '';
}); });
webview.addEventListener("did-stop-loading", function() { webview.addEventListener("did-stop-loading", function() {
me.unmask(); me.down('statusbar').clearStatus({useDefaults: true});
}); });
webview.addEventListener("did-finish-load", function(e) { webview.addEventListener("did-finish-load", function(e) {
Rambox.app.setTotalServicesLoaded( Rambox.app.getTotalServicesLoaded() + 1 ); Rambox.app.setTotalServicesLoaded( Rambox.app.getTotalServicesLoaded() + 1 );
// Apply saved zoom level // Apply saved zoom level
webview.setZoomLevel(me.record.get('zoomLevel')); webview.setZoomLevel(me.record.get('zoomLevel'));
}); });
@ -262,10 +272,21 @@ Ext.define('Rambox.ux.WebView',{
*/ */
console.groupEnd(); console.groupEnd();
// Scroll always to top (bug) // Scroll always to top (bug)
webview.executeJavaScript('document.body.scrollTop=0;'); webview.executeJavaScript('document.body.scrollTop=0;');
// Handles Certificate Errors
webview.getWebContents().on('certificate-error', function(event, url, error, certificate, callback) {
if ( me.record.get('trust') ) {
event.preventDefault();
callback(true);
} else {
callback(false);
}
me.down('statusbar').setStatus({
text: '<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> Certification Warning'
});
});
}); });
webview.addEventListener('ipc-message', function(event) { webview.addEventListener('ipc-message', function(event) {
@ -321,6 +342,10 @@ Ext.define('Rambox.ux.WebView',{
if ( e.isMainFrame ) webview.loadURL(e.newURL); if ( e.isMainFrame ) webview.loadURL(e.newURL);
}); });
webview.addEventListener('update-target-url', function( url ) {
me.down('statusbar #url').setText(url.url);
});
if(ipc.sendSync('getConfig').spellcheck) { if(ipc.sendSync('getConfig').spellcheck) {
/* /*
var webFrame = require('electron').webFrame; var webFrame = require('electron').webFrame;

2
app/view/add/Add.js

@ -157,7 +157,7 @@ Ext.define('Rambox.view.add.Add',{
,boxLabel: 'Trust invalid authority certificates' ,boxLabel: 'Trust invalid authority certificates'
,name: 'trust' ,name: 'trust'
,hidden: me.record.get('type') !== 'custom' ,hidden: me.record.get('type') !== 'custom'
,checked: me.edit ? me.record.get('trust') : false ,checked: me.edit ? me.record.get('trust') : true
,uncheckedValue: false ,uncheckedValue: false
,inputValue: true ,inputValue: true
} }

18
app/view/add/AddController.js

@ -33,10 +33,10 @@ Ext.define('Rambox.view.add.AddController', {
,url: formValues.url ,url: formValues.url
,align: formValues.align ,align: formValues.align
,notifications: formValues.notifications ,notifications: formValues.notifications
,muted: formValues.muted, ,muted: formValues.muted
displayTabUnreadCounter: formValues.displayTabUnreadCounter, ,displayTabUnreadCounter: formValues.displayTabUnreadCounter
includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter, ,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
trust: formValues.trust ,trust: formValues.trust
,js_unread: formValues.js_unread ,js_unread: formValues.js_unread
}); });
@ -76,7 +76,7 @@ Ext.define('Rambox.view.add.AddController', {
if ( win.record.get('url').indexOf('___') >= 0 ) { if ( win.record.get('url').indexOf('___') >= 0 ) {
formValues.url = formValues.cycleValue === '1' ? win.record.get('url').replace('___', formValues.url) : formValues.url; formValues.url = formValues.cycleValue === '1' ? win.record.get('url').replace('___', formValues.url) : formValues.url;
} }
var service = Ext.create('Rambox.model.Service', { var service = Ext.create('Rambox.model.Service', {
type: win.record.get('id') type: win.record.get('id')
,logo: formValues.logo ,logo: formValues.logo
@ -84,10 +84,10 @@ Ext.define('Rambox.view.add.AddController', {
,url: formValues.url ,url: formValues.url
,align: formValues.align ,align: formValues.align
,notifications: formValues.notifications ,notifications: formValues.notifications
,muted: formValues.muted, ,muted: formValues.muted
displayTabUnreadCounter: formValues.displayTabUnreadCounter, ,displayTabUnreadCounter: formValues.displayTabUnreadCounter
includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter, ,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
trust: formValues.trust ,trust: formValues.trust
,js_unread: formValues.js_unread ,js_unread: formValues.js_unread
}); });
service.save(); service.save();

22
electron/main.js

@ -306,28 +306,6 @@ if (shouldQuit) {
return; return;
} }
var allowedURLCertificates = [];
ipcMain.on('allowCertificate', (event, url) => {
allowedURLCertificates.push(require('url').parse(url).host);
});
app.on('certificate-error', function(event, webContents, url, error, certificate, callback) {
if ( allowedURLCertificates.indexOf(require('url').parse(url).host) >= 0 ) {
event.preventDefault();
callback(true);
} else {
callback(false);
dialog.showMessageBox(mainWindow, {
title: 'Certification Warning'
,message: 'The service with the following URL has an invalid authority certification.\n\n'+url+'\n\nIf is a Custom Service, you have to remove it and add it again, enabling the "Trust invalid authority certificates" in the Options.'
,buttons: ['OK']
,type: 'warning'
}, function() {
});
}
});
// 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)
const tmp = require('tmp'); const tmp = require('tmp');

8
packages/local/rambox-default-theme/sass/etc/all.scss

@ -260,3 +260,11 @@ body {
.auth0-lock.auth0-lock .auth0-lock-header-logo { .auth0-lock.auth0-lock .auth0-lock-header-logo {
height: 50px !important; height: 50px !important;
} }
.x-statusbar {
padding: 0px !important;
&.x-docked-bottom {
border-top: 1px solid #CCC !important;
border-top-width: 1px !important;
}
}

Loading…
Cancel
Save