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. 45
      app/ux/WebView.js
  3. 2
      app/view/add/Add.js
  4. 16
      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'
,type: 'boolean'
,defaultValue: false
,defaultValue: true
},{
name: 'enabled'
,type: 'boolean'

45
app/ux/WebView.js

@ -6,9 +6,9 @@ Ext.define('Rambox.ux.WebView',{
,xtype: 'webview'
,requires: [
'Rambox.util.Format',
'Rambox.util.Notifier',
'Rambox.util.UnreadCounter'
'Rambox.util.Format'
,'Rambox.util.Notifier'
,'Rambox.util.UnreadCounter'
]
// private
@ -34,7 +34,7 @@ Ext.define('Rambox.ux.WebView',{
}
// 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, {
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: {
afterrender: me.onAfterRender
}
@ -186,12 +198,10 @@ Ext.define('Rambox.ux.WebView',{
// Show and hide spinner when is loading
webview.addEventListener("did-start-loading", function() {
console.info('Start loading...', me.src);
me.mask('Loading...', 'bottomMask');
// Manually remove modal from mask
Ext.cq1('#'+me.id).el.dom.getElementsByClassName('bottomMask')[0].parentElement.className = '';
me.down('statusbar').showBusy();
});
webview.addEventListener("did-stop-loading", function() {
me.unmask();
me.down('statusbar').clearStatus({useDefaults: true});
});
webview.addEventListener("did-finish-load", function(e) {
@ -262,10 +272,21 @@ Ext.define('Rambox.ux.WebView',{
*/
console.groupEnd();
// Scroll always to top (bug)
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) {
@ -321,6 +342,10 @@ Ext.define('Rambox.ux.WebView',{
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) {
/*
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'
,name: 'trust'
,hidden: me.record.get('type') !== 'custom'
,checked: me.edit ? me.record.get('trust') : false
,checked: me.edit ? me.record.get('trust') : true
,uncheckedValue: false
,inputValue: true
}

16
app/view/add/AddController.js

@ -33,10 +33,10 @@ Ext.define('Rambox.view.add.AddController', {
,url: formValues.url
,align: formValues.align
,notifications: formValues.notifications
,muted: formValues.muted,
displayTabUnreadCounter: formValues.displayTabUnreadCounter,
includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter,
trust: formValues.trust
,muted: formValues.muted
,displayTabUnreadCounter: formValues.displayTabUnreadCounter
,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
,trust: formValues.trust
,js_unread: formValues.js_unread
});
@ -84,10 +84,10 @@ Ext.define('Rambox.view.add.AddController', {
,url: formValues.url
,align: formValues.align
,notifications: formValues.notifications
,muted: formValues.muted,
displayTabUnreadCounter: formValues.displayTabUnreadCounter,
includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter,
trust: formValues.trust
,muted: formValues.muted
,displayTabUnreadCounter: formValues.displayTabUnreadCounter
,includeInGlobalUnreadCounter: formValues.includeInGlobalUnreadCounter
,trust: formValues.trust
,js_unread: formValues.js_unread
});
service.save();

22
electron/main.js

@ -306,28 +306,6 @@ if (shouldQuit) {
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
// Credit: Ghetto Skype (https://github.com/stanfieldr/ghetto-skype)
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 {
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