aboutsummaryrefslogtreecommitdiffstats
path: root/src/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.js')
-rw-r--r--src/index.js31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/index.js b/src/index.js
index 027884826..dac8ec770 100644
--- a/src/index.js
+++ b/src/index.js
@@ -35,6 +35,7 @@ import {
35import { mainIpcHandler as basicAuthHandler } from './features/basicAuth'; 35import { mainIpcHandler as basicAuthHandler } from './features/basicAuth';
36import ipcApi from './electron/ipc-api'; 36import ipcApi from './electron/ipc-api';
37import Tray from './lib/Tray'; 37import Tray from './lib/Tray';
38import DBus from './lib/DBus';
38import Settings from './electron/Settings'; 39import Settings from './electron/Settings';
39import handleDeepLink from './electron/deepLinking'; 40import handleDeepLink from './electron/deepLinking';
40import { isPositionValid } from './electron/windowUtils'; 41import { isPositionValid } from './electron/windowUtils';
@@ -152,8 +153,8 @@ const createWindow = () => {
152 const mainWindowState = windowStateKeeper({ 153 const mainWindowState = windowStateKeeper({
153 defaultWidth: DEFAULT_WINDOW_OPTIONS.width, 154 defaultWidth: DEFAULT_WINDOW_OPTIONS.width,
154 defaultHeight: DEFAULT_WINDOW_OPTIONS.height, 155 defaultHeight: DEFAULT_WINDOW_OPTIONS.height,
155 maximize: false, 156 maximize: true, // Automatically maximizes the window, if it was last clsoed maximized
156 fullScreen: false, 157 fullScreen: true, // Automatically restores the window to full screen, if it was last closed full screen
157 }); 158 });
158 159
159 let posX = mainWindowState.x || DEFAULT_WINDOW_OPTIONS.x; 160 let posX = mainWindowState.x || DEFAULT_WINDOW_OPTIONS.x;
@@ -192,6 +193,14 @@ const createWindow = () => {
192 }, 193 },
193 }); 194 });
194 195
196 app.on('web-contents-created', (e, contents) => {
197 if (contents.getType() === 'webview') {
198 contents.on('new-window', (event) => {
199 event.preventDefault();
200 });
201 }
202 });
203
195 mainWindow.webContents.on('did-finish-load', () => { 204 mainWindow.webContents.on('did-finish-load', () => {
196 const fns = onDidLoadFns; 205 const fns = onDidLoadFns;
197 onDidLoadFns = null; 206 onDidLoadFns = null;
@@ -205,6 +214,9 @@ const createWindow = () => {
205 // Initialize System Tray 214 // Initialize System Tray
206 const trayIcon = new Tray(); 215 const trayIcon = new Tray();
207 216
217 // Initialize DBus interface
218 const dbus = new DBus(trayIcon);
219
208 // Initialize ipcApi 220 // Initialize ipcApi
209 ipcApi({ 221 ipcApi({
210 mainWindow, 222 mainWindow,
@@ -215,6 +227,9 @@ const createWindow = () => {
215 trayIcon, 227 trayIcon,
216 }); 228 });
217 229
230 // Connect to the DBus after ipcApi took care of the System Tray
231 dbus.start();
232
218 // Manage Window State 233 // Manage Window State
219 mainWindowState.manage(mainWindow); 234 mainWindowState.manage(mainWindow);
220 235
@@ -257,6 +272,7 @@ const createWindow = () => {
257 mainWindow.hide(); 272 mainWindow.hide();
258 } 273 }
259 } else { 274 } else {
275 dbus.stop();
260 app.quit(); 276 app.quit();
261 } 277 }
262 }); 278 });
@@ -316,7 +332,7 @@ const createWindow = () => {
316 e.preventDefault(); 332 e.preventDefault();
317 333
318 if (isValidExternalURL(url)) { 334 if (isValidExternalURL(url)) {
319 shell.openExternal(url); 335 shell.openExternal(url);
320 } 336 }
321 }); 337 });
322 338
@@ -395,6 +411,15 @@ ipcMain.on('feature-basic-auth-credentials', (e, { user, password }) => {
395 authCallback = noop; 411 authCallback = noop;
396}); 412});
397 413
414ipcMain.on('open-browser-window', (e, {disposition, url}, serviceId) => {
415 if (disposition === 'foreground-tab') {
416 let serviceSession = session.fromPartition(`persist:service-${serviceId}`)
417 let child = new BrowserWindow({ parent: mainWindow, webPreferences: {session: serviceSession}});
418 child.show();
419 child.loadURL(url);
420 }
421 debug('Received open-browser-window', disposition, url);
422});
398 423
399ipcMain.on('modifyRequestHeaders', (e, { modifiedRequestHeaders, serviceId }) => { 424ipcMain.on('modifyRequestHeaders', (e, { modifiedRequestHeaders, serviceId }) => {
400 debug('Received modifyRequestHeaders', modifiedRequestHeaders, serviceId); 425 debug('Received modifyRequestHeaders', modifiedRequestHeaders, serviceId);