aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
authorLibravatar Stefan Malzner <stefan@adlk.io>2018-11-27 18:06:14 +0100
committerLibravatar Stefan Malzner <stefan@adlk.io>2018-11-27 18:06:14 +0100
commit62972747866740dae84fc7b519fcedd731572329 (patch)
tree3a74610caa47350ff6b3cc07482f8472f18c1764 /src/index.js
parentFix listening key (diff)
downloadferdium-app-62972747866740dae84fc7b519fcedd731572329.tar.gz
ferdium-app-62972747866740dae84fc7b519fcedd731572329.tar.zst
ferdium-app-62972747866740dae84fc7b519fcedd731572329.zip
feat(App): Add proxy support for services
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/index.js b/src/index.js
index 7d906ad71..994531dbf 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,4 @@
1import { app, BrowserWindow, shell } from 'electron'; 1import { app, BrowserWindow, shell, ipcMain } from 'electron';
2import fs from 'fs-extra'; 2import fs from 'fs-extra';
3import path from 'path'; 3import path from 'path';
4 4
@@ -12,6 +12,8 @@ import handleDeepLink from './electron/deepLinking';
12import { appId } from './package.json'; // eslint-disable-line import/no-unresolved 12import { appId } from './package.json'; // eslint-disable-line import/no-unresolved
13import './electron/exception'; 13import './electron/exception';
14 14
15import { DEFAULT_APP_SETTINGS } from './config';
16
15const debug = require('debug')('Franz:App'); 17const debug = require('debug')('Franz:App');
16 18
17// Keep a global reference of the window object, if you don't, the window will 19// Keep a global reference of the window object, if you don't, the window will
@@ -62,7 +64,8 @@ if (isLinux && ['Pantheon', 'Unity:Unity7'].indexOf(process.env.XDG_CURRENT_DESK
62} 64}
63 65
64// Initialize Settings 66// Initialize Settings
65const settings = new Settings(); 67const settings = new Settings('app', DEFAULT_APP_SETTINGS);
68const proxySettings = new Settings('proxy');
66 69
67// Disable GPU acceleration 70// Disable GPU acceleration
68if (!settings.get('enableGPUAcceleration')) { 71if (!settings.get('enableGPUAcceleration')) {
@@ -94,7 +97,14 @@ const createWindow = () => {
94 const trayIcon = new Tray(); 97 const trayIcon = new Tray();
95 98
96 // Initialize ipcApi 99 // Initialize ipcApi
97 ipcApi({ mainWindow, settings, trayIcon }); 100 ipcApi({
101 mainWindow,
102 settings: {
103 app: settings,
104 proxy: proxySettings,
105 },
106 trayIcon,
107 });
98 108
99 // Manage Window State 109 // Manage Window State
100 mainWindowState.manage(mainWindow); 110 mainWindowState.manage(mainWindow);
@@ -177,6 +187,24 @@ const createWindow = () => {
177// Some APIs can only be used after this event occurs. 187// Some APIs can only be used after this event occurs.
178app.on('ready', createWindow); 188app.on('ready', createWindow);
179 189
190// This is the worst possible implementation as the webview.webContents based callback doesn't work 🖕
191app.on('login', (event, webContents, request, authInfo, callback) => {
192 event.preventDefault();
193 debug('browser login event', authInfo);
194 if (authInfo.isProxy && authInfo.scheme === 'basic') {
195 webContents.send('get-service-id');
196
197 ipcMain.on('service-id', (e, id) => {
198 debug('Received service id', id);
199
200 const ps = proxySettings.get(id);
201 callback(ps.user, ps.password);
202 });
203 } else {
204 // TODO: implement basic auth
205 }
206});
207
180// Quit when all windows are closed. 208// Quit when all windows are closed.
181app.on('window-all-closed', () => { 209app.on('window-all-closed', () => {
182 // On OS X it is common for applications and their menu bar 210 // On OS X it is common for applications and their menu bar