2016-03-24 20:15:04 +00:00
|
|
|
'use strict'
|
2016-03-10 19:54:17 +00:00
|
|
|
|
2016-04-25 03:35:09 +00:00
|
|
|
const electron = require('electron')
|
2016-04-28 16:38:05 +00:00
|
|
|
const {session, Menu} = electron
|
2016-03-24 20:15:04 +00:00
|
|
|
const EventEmitter = require('events').EventEmitter
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
const bindings = process.atomBinding('app')
|
|
|
|
const downloadItemBindings = process.atomBinding('download_item')
|
|
|
|
const app = bindings.app
|
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-03-24 20:15:04 +00:00
|
|
|
app.setApplicationMenu = function (menu) {
|
|
|
|
return Menu.setApplicationMenu(menu)
|
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
app.getApplicationMenu = function () {
|
|
|
|
return Menu.getApplicationMenu()
|
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
|
|
|
app.commandLine = {
|
|
|
|
appendSwitch: bindings.appendSwitch,
|
|
|
|
appendArgument: bindings.appendArgument
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
|
|
|
if (process.platform === 'darwin') {
|
|
|
|
app.dock = {
|
2016-03-24 20:15:04 +00:00
|
|
|
bounce: function (type) {
|
2016-01-12 02:40:23 +00:00
|
|
|
if (type == null) {
|
2016-03-24 20:15:04 +00:00
|
|
|
type = 'informational'
|
2016-01-12 02:40:23 +00:00
|
|
|
}
|
2016-03-24 20:15:04 +00:00
|
|
|
return bindings.dockBounce(type)
|
2016-01-12 02:40:23 +00:00
|
|
|
},
|
|
|
|
cancelBounce: bindings.dockCancelBounce,
|
|
|
|
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-03-24 20:15:04 +00:00
|
|
|
var appPath = null
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
app.setAppPath = function (path) {
|
2016-03-29 01:00:30 +00:00
|
|
|
appPath = path
|
2016-03-24 20:15:04 +00:00
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
app.getAppPath = function () {
|
|
|
|
return appPath
|
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-01-14 18:35:29 +00:00
|
|
|
// Routes the events to webContents.
|
2016-03-24 20:15:04 +00:00
|
|
|
var ref1 = ['login', 'certificate-error', 'select-client-certificate']
|
|
|
|
var fn = function (name) {
|
|
|
|
return app.on(name, function (event, webContents, ...args) {
|
|
|
|
return webContents.emit.apply(webContents, [name, event].concat(args))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
var i, len
|
2016-01-12 02:40:23 +00:00
|
|
|
for (i = 0, len = ref1.length; i < len; i++) {
|
2016-03-24 20:15:04 +00:00
|
|
|
fn(ref1[i])
|
2016-01-12 02:40:23 +00:00
|
|
|
}
|
|
|
|
|
2016-01-14 18:35:29 +00:00
|
|
|
// Wrappers for native classes.
|
2016-03-24 20:15:04 +00:00
|
|
|
var wrapDownloadItem = function (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-03-24 20:15:04 +00:00
|
|
|
}
|
2016-01-12 02:40:23 +00:00
|
|
|
|
2016-03-24 20:15:04 +00:00
|
|
|
downloadItemBindings._setWrapDownloadItem(wrapDownloadItem)
|
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
|