2016-03-24 20:15:04 +00:00
|
|
|
'use strict'
|
2016-03-10 19:54:17 +00:00
|
|
|
|
2016-05-23 05:29:55 +00:00
|
|
|
const {deprecate, Menu, session} = require('electron')
|
2016-05-14 15:17:46 +00:00
|
|
|
const {EventEmitter} = require('events')
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
const bindings = process.atomBinding('app')
|
2016-05-14 15:17:46 +00:00
|
|
|
const {app} = bindings
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-29 00:51:11 +00:00
|
|
|
Object.setPrototypeOf(app, EventEmitter.prototype)
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-05-14 15:17:46 +00:00
|
|
|
let appPath = null
|
|
|
|
|
|
|
|
Object.assign(app, {
|
2016-05-14 15:31:08 +00:00
|
|
|
getAppPath () { return appPath },
|
|
|
|
setAppPath (path) { appPath = path },
|
|
|
|
setApplicationMenu (menu) {
|
2016-05-14 15:17:46 +00:00
|
|
|
return Menu.setApplicationMenu(menu)
|
|
|
|
},
|
2016-05-14 15:31:08 +00:00
|
|
|
getApplicationMenu () {
|
2016-05-14 15:17:46 +00:00
|
|
|
return Menu.getApplicationMenu()
|
|
|
|
},
|
|
|
|
commandLine: {
|
|
|
|
appendSwitch: bindings.appendSwitch,
|
|
|
|
appendArgument: bindings.appendArgument
|
|
|
|
}
|
|
|
|
})
|
2016-01-12 02:40:23 +00:00
|
|
|
|
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
app.dock = {
|
2016-05-14 15:17:46 +00:00
|
|
|
bounce (type = 'informational') {
|
2016-03-24 20:15:04 +00:00
|
|
|
return bindings.dockBounce(type)
|
2016-01-12 02:40:23 +00:00
|
|
|
},
|
|
|
|
cancelBounce: bindings.dockCancelBounce,
|
2016-05-10 19:02:56 +00:00
|
|
|
downloadFinished: bindings.dockDownloadFinished,
|
2016-01-12 02:40:23 +00:00
|
|
|
setBadge: bindings.dockSetBadgeText,
|
|
|
|
getBadge: bindings.dockGetBadgeText,
|
|
|
|
hide: bindings.dockHide,
|
|
|
|
show: bindings.dockShow,
|
2016-01-23 23:30:14 +00:00
|
|
|
setMenu: bindings.dockSetMenu,
|
|
|
|
setIcon: bindings.dockSetIcon
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
}
|
|
|
|
|
2016-05-23 05:29:55 +00:00
|
|
|
app.allowNTLMCredentialsForAllDomains = function (allow) {
|
|
|
|
if (!process.noDeprecations) {
|
|
|
|
deprecate.warn('app.allowNTLMCredentialsForAllDomains', 'session.allowNTLMCredentialsForDomains')
|
|
|
|
}
|
|
|
|
let domains = allow ? '*' : ''
|
|
|
|
if (!this.isReady()) {
|
|
|
|
this.commandLine.appendSwitch('auth-server-whitelist', domains)
|
|
|
|
} else {
|
|
|
|
session.defaultSession.allowNTLMCredentialsForDomains(domains)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-14 18:35:29 +00:00
|
|
|
// Routes the events to webContents.
|
2016-05-14 15:17:46 +00:00
|
|
|
const events = ['login', 'certificate-error', 'select-client-certificate']
|
|
|
|
for (let name of events) {
|
|
|
|
app.on(name, (event, webContents, ...args) => {
|
2016-05-19 22:28:08 +00:00
|
|
|
webContents.emit.apply(webContents, [name, event].concat(args))
|
2016-03-24 20:15:04 +00:00
|
|
|
})
|
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-01-14 18:35:29 +00:00
|
|
|
// Wrappers for native classes.
|
2016-05-14 23:43:30 +00:00
|
|
|
process.atomBinding('download_item')._setWrapDownloadItem((downloadItem) => {
|
2016-01-14 18:35:29 +00:00
|
|
|
// downloadItem is an EventEmitter.
|
2016-03-29 00:51:11 +00:00
|
|
|
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
2016-05-14 16:28:28 +00:00
|
|
|
})
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-01-14 18:35:29 +00:00
|
|
|
// Only one App object pemitted.
|
2016-03-24 20:15:04 +00:00
|
|
|
module.exports = app
|