2017-06-26 21:12:03 +00:00
|
|
|
const {app, BrowserWindow, ipcMain} = require('electron')
|
2017-06-16 22:34:11 +00:00
|
|
|
const path = require('path')
|
|
|
|
|
2017-06-19 15:03:02 +00:00
|
|
|
process.on('uncaughtException', () => {
|
2017-06-16 22:34:11 +00:00
|
|
|
app.exit(1)
|
|
|
|
})
|
|
|
|
|
2017-06-28 15:33:06 +00:00
|
|
|
if (!process.argv.includes('--enable-mixed-sandbox')) {
|
|
|
|
app.enableMixedSandbox()
|
|
|
|
}
|
|
|
|
|
2017-06-26 21:12:03 +00:00
|
|
|
let sandboxWindow
|
|
|
|
let noSandboxWindow
|
2017-06-19 15:03:02 +00:00
|
|
|
|
2017-06-26 21:12:03 +00:00
|
|
|
app.once('ready', () => {
|
|
|
|
sandboxWindow = new BrowserWindow({
|
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
|
|
|
|
sandbox: true
|
2017-06-16 22:34:11 +00:00
|
|
|
}
|
|
|
|
})
|
2017-06-26 21:12:03 +00:00
|
|
|
sandboxWindow.loadURL('about:blank')
|
|
|
|
|
|
|
|
noSandboxWindow = new BrowserWindow({
|
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(app.getAppPath(), 'electron-app-mixed-sandbox-preload.js'),
|
|
|
|
sandbox: false
|
|
|
|
}
|
2017-06-16 22:34:11 +00:00
|
|
|
})
|
2017-06-26 21:12:03 +00:00
|
|
|
noSandboxWindow.loadURL('about:blank')
|
2017-06-16 22:34:11 +00:00
|
|
|
|
2017-06-26 21:12:03 +00:00
|
|
|
const argv = {
|
|
|
|
sandbox: null,
|
|
|
|
noSandbox: null
|
2017-06-16 22:34:11 +00:00
|
|
|
}
|
2017-06-26 21:12:03 +00:00
|
|
|
|
|
|
|
ipcMain.on('argv', (event, value) => {
|
|
|
|
if (event.sender === sandboxWindow.webContents) {
|
|
|
|
argv.sandbox = value
|
|
|
|
} else if (event.sender === noSandboxWindow.webContents) {
|
|
|
|
argv.noSandbox = value
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argv.sandbox != null && argv.noSandbox != null) {
|
|
|
|
process.send(argv)
|
|
|
|
}
|
|
|
|
})
|
2017-06-16 22:34:11 +00:00
|
|
|
})
|