| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | 'use strict' | 
					
						
							| 
									
										
										
										
											2016-03-10 11:54:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-25 12:35:09 +09:00
										 |  |  | const electron = require('electron') | 
					
						
							|  |  |  | const {deprecate, session, Menu} = electron | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | const EventEmitter = require('events').EventEmitter | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | const bindings = process.atomBinding('app') | 
					
						
							|  |  |  | const downloadItemBindings = process.atomBinding('download_item') | 
					
						
							|  |  |  | const app = bindings.app | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-28 17:51:11 -07:00
										 |  |  | Object.setPrototypeOf(app, EventEmitter.prototype) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | app.setApplicationMenu = function (menu) { | 
					
						
							|  |  |  |   return Menu.setApplicationMenu(menu) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | app.getApplicationMenu = function () { | 
					
						
							|  |  |  |   return Menu.getApplicationMenu() | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | app.commandLine = { | 
					
						
							|  |  |  |   appendSwitch: bindings.appendSwitch, | 
					
						
							|  |  |  |   appendArgument: bindings.appendArgument | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (process.platform === 'darwin') { | 
					
						
							|  |  |  |   app.dock = { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     bounce: function (type) { | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |       if (type == null) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |         type = 'informational' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       return bindings.dockBounce(type) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |     cancelBounce: bindings.dockCancelBounce, | 
					
						
							|  |  |  |     setBadge: bindings.dockSetBadgeText, | 
					
						
							|  |  |  |     getBadge: bindings.dockGetBadgeText, | 
					
						
							|  |  |  |     hide: bindings.dockHide, | 
					
						
							|  |  |  |     show: bindings.dockShow, | 
					
						
							| 
									
										
										
										
											2016-01-24 08:30:14 +09:00
										 |  |  |     setMenu: bindings.dockSetMenu, | 
					
						
							|  |  |  |     setIcon: bindings.dockSetIcon | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | var appPath = null | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | app.setAppPath = function (path) { | 
					
						
							| 
									
										
										
										
											2016-03-28 18:00:30 -07:00
										 |  |  |   appPath = path | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | app.getAppPath = function () { | 
					
						
							|  |  |  |   return appPath | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Routes the events to webContents.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07: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-11 18:40:23 -08:00
										 |  |  | for (i = 0, len = ref1.length; i < len; i++) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   fn(ref1[i]) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Deprecated.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | app.getHomeDir = deprecate('app.getHomeDir', 'app.getPath', function () { | 
					
						
							|  |  |  |   return this.getPath('home') | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | app.getDataPath = deprecate('app.getDataPath', 'app.getPath', function () { | 
					
						
							|  |  |  |   return this.getPath('userData') | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | app.setDataPath = deprecate('app.setDataPath', 'app.setPath', function (path) { | 
					
						
							|  |  |  |   return this.setPath('userData', path) | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | app.resolveProxy = deprecate('app.resolveProxy', 'session.defaultSession.resolveProxy', function (url, callback) { | 
					
						
							|  |  |  |   return session.defaultSession.resolveProxy(url, callback) | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | deprecate.rename(app, 'terminate', 'quit') | 
					
						
							|  |  |  | deprecate.event(app, 'finish-launching', 'ready', function () { | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // give default app a chance to setup default menu.
 | 
					
						
							| 
									
										
										
										
											2016-03-10 11:54:17 -08:00
										 |  |  |   setImmediate(() => { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     this.emit('finish-launching') | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | deprecate.event(app, 'activate-with-no-open-windows', 'activate', function (event, hasVisibleWindows) { | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   if (!hasVisibleWindows) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     return this.emit('activate-with-no-open-windows', event) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | }) | 
					
						
							|  |  |  | deprecate.event(app, 'select-certificate', 'select-client-certificate') | 
					
						
							| 
									
										
										
										
											2016-04-25 12:35:09 +09:00
										 |  |  | if (process.platform === 'win32') { | 
					
						
							|  |  |  |   app.isAeroGlassEnabled = deprecate('app.isAeroGlassEnabled', 'systemPreferences.isAeroGlassEnabled', function () { | 
					
						
							| 
									
										
										
										
											2016-04-25 14:34:30 +09:00
										 |  |  |     return electron.systemPreferences.isAeroGlassEnabled() | 
					
						
							| 
									
										
										
										
											2016-04-25 12:35:09 +09:00
										 |  |  |   }) | 
					
						
							|  |  |  | } else if (process.platform === 'darwin') { | 
					
						
							|  |  |  |   app.isDarkMode = deprecate('app.isDarkMode', 'systemPreferences.isDarkMode', function () { | 
					
						
							| 
									
										
										
										
											2016-04-25 14:34:30 +09:00
										 |  |  |     return electron.systemPreferences.isDarkMode() | 
					
						
							| 
									
										
										
										
											2016-04-25 12:35:09 +09:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-04-25 14:34:30 +09:00
										 |  |  |   app.on = app.addListener = function (event, listener) { | 
					
						
							|  |  |  |     if (event === 'platform-theme-changed') { | 
					
						
							|  |  |  |       deprecate.warn('platform-theme-changed event', "systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', callback)") | 
					
						
							|  |  |  |       electron.systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', function () { | 
					
						
							|  |  |  |         app.emit('platform-theme-changed') | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     EventEmitter.prototype.addListener.call(app, event, listener) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-04-25 12:35:09 +09:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Wrappers for native classes.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | var wrapDownloadItem = function (downloadItem) { | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // downloadItem is an EventEmitter.
 | 
					
						
							| 
									
										
										
										
											2016-03-28 17:51:11 -07:00
										 |  |  |   Object.setPrototypeOf(downloadItem, EventEmitter.prototype) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Deprecated.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   deprecate.property(downloadItem, 'url', 'getURL') | 
					
						
							|  |  |  |   deprecate.property(downloadItem, 'filename', 'getFilename') | 
					
						
							|  |  |  |   deprecate.property(downloadItem, 'mimeType', 'getMimeType') | 
					
						
							|  |  |  |   return deprecate.rename(downloadItem, 'getUrl', 'getURL') | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | downloadItemBindings._setWrapDownloadItem(wrapDownloadItem) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Only one App object pemitted.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | module.exports = app |