| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | 'use strict' | 
					
						
							| 
									
										
										
										
											2016-03-10 11:54:17 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-22 15:21:45 -07:00
										 |  |  | const bindings = process.atomBinding('app') | 
					
						
							| 
									
										
										
										
											2016-08-02 20:38:35 +09:00
										 |  |  | const {app, App} = bindings | 
					
						
							| 
									
										
										
										
											2016-06-22 15:21:45 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Only one app object permitted.
 | 
					
						
							|  |  |  | module.exports = app | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-01 14:57:35 +09:00
										 |  |  | const electron = require('electron') | 
					
						
							|  |  |  | const {deprecate, Menu} = electron | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  | const {EventEmitter} = require('events') | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-02 20:38:35 +09:00
										 |  |  | Object.setPrototypeOf(App.prototype, EventEmitter.prototype) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  | let appPath = null | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Object.assign(app, { | 
					
						
							| 
									
										
										
										
											2016-05-14 11:31:08 -04:00
										 |  |  |   getAppPath () { return appPath }, | 
					
						
							|  |  |  |   setAppPath (path) { appPath = path }, | 
					
						
							|  |  |  |   setApplicationMenu (menu) { | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  |     return Menu.setApplicationMenu(menu) | 
					
						
							|  |  |  |   }, | 
					
						
							| 
									
										
										
										
											2016-05-14 11:31:08 -04:00
										 |  |  |   getApplicationMenu () { | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  |     return Menu.getApplicationMenu() | 
					
						
							|  |  |  |   }, | 
					
						
							|  |  |  |   commandLine: { | 
					
						
							| 
									
										
										
										
											2016-09-16 11:43:48 -07:00
										 |  |  |     appendSwitch() { | 
					
						
							|  |  |  |       let castedArgs = [...arguments].map((arg) => { | 
					
						
							|  |  |  |         return typeof arg !== 'string' ? `${arg}` : arg | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return binding.appendSwitch(...castedArgs) | 
					
						
							|  |  |  |     }, | 
					
						
							|  |  |  |     appendArgument() { | 
					
						
							|  |  |  |       let castedArgs = [...arguments].map((arg) => { | 
					
						
							|  |  |  |         return typeof arg !== 'string' ? `${arg}` : arg | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       return binding.appendArgument(...castedArgs) | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  |   } | 
					
						
							|  |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (process.platform === 'darwin') { | 
					
						
							|  |  |  |   app.dock = { | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  |     bounce (type = 'informational') { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       return bindings.dockBounce(type) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     }, | 
					
						
							|  |  |  |     cancelBounce: bindings.dockCancelBounce, | 
					
						
							| 
									
										
										
										
											2016-05-10 15:02:56 -04:00
										 |  |  |     downloadFinished: bindings.dockDownloadFinished, | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     setBadge: bindings.dockSetBadgeText, | 
					
						
							|  |  |  |     getBadge: bindings.dockGetBadgeText, | 
					
						
							|  |  |  |     hide: bindings.dockHide, | 
					
						
							|  |  |  |     show: bindings.dockShow, | 
					
						
							| 
									
										
										
										
											2016-08-01 15:22:37 -07:00
										 |  |  |     isVisible: bindings.dockIsVisible, | 
					
						
							| 
									
										
										
										
											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-06-26 11:48:58 +02:00
										 |  |  | if (process.platform === 'linux') { | 
					
						
							|  |  |  |   app.launcher = { | 
					
						
							| 
									
										
										
										
											2016-06-26 01:55:24 +02:00
										 |  |  |     setBadgeCount: bindings.unityLauncherSetBadgeCount, | 
					
						
							| 
									
										
										
										
											2016-06-26 11:48:58 +02:00
										 |  |  |     getBadgeCount: bindings.unityLauncherGetBadgeCount, | 
					
						
							| 
									
										
										
										
											2016-06-29 19:23:56 +02:00
										 |  |  |     isCounterBadgeAvailable: bindings.unityLauncherAvailable, | 
					
						
							|  |  |  |     isUnityRunning: bindings.unityLauncherAvailable | 
					
						
							| 
									
										
										
										
											2016-06-26 02:00:41 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-26 01:55:24 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-05-23 10:59:55 +05:30
										 |  |  | 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 { | 
					
						
							| 
									
										
										
										
											2016-06-01 14:57:35 +09:00
										 |  |  |     electron.session.defaultSession.allowNTLMCredentialsForDomains(domains) | 
					
						
							| 
									
										
										
										
											2016-05-23 10:59:55 +05:30
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Routes the events to webContents.
 | 
					
						
							| 
									
										
										
										
											2016-05-14 11:17:46 -04:00
										 |  |  | const events = ['login', 'certificate-error', 'select-client-certificate'] | 
					
						
							|  |  |  | for (let name of events) { | 
					
						
							|  |  |  |   app.on(name, (event, webContents, ...args) => { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |     webContents.emit.apply(webContents, [name, event].concat(args)) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   }) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Wrappers for native classes.
 | 
					
						
							| 
									
										
										
										
											2016-08-02 20:38:35 +09:00
										 |  |  | const {DownloadItem} = process.atomBinding('download_item') | 
					
						
							|  |  |  | Object.setPrototypeOf(DownloadItem.prototype, EventEmitter.prototype) |