| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | 'use strict' | 
					
						
							| 
									
										
										
										
											2016-03-18 11:51:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | const ipcMain = require('electron').ipcMain | 
					
						
							|  |  |  | const webContents = require('electron').webContents | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Doesn't exist in early initialization.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | let webViewManager = null | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const supportedWebViewEvents = [ | 
					
						
							| 
									
										
										
										
											2016-01-25 22:07:15 +05:30
										 |  |  |   'load-commit', | 
					
						
							|  |  |  |   'did-finish-load', | 
					
						
							|  |  |  |   'did-fail-load', | 
					
						
							|  |  |  |   'did-frame-finish-load', | 
					
						
							|  |  |  |   'did-start-loading', | 
					
						
							|  |  |  |   'did-stop-loading', | 
					
						
							|  |  |  |   'did-get-response-details', | 
					
						
							|  |  |  |   'did-get-redirect-request', | 
					
						
							|  |  |  |   'dom-ready', | 
					
						
							|  |  |  |   'console-message', | 
					
						
							|  |  |  |   'devtools-opened', | 
					
						
							|  |  |  |   'devtools-closed', | 
					
						
							|  |  |  |   'devtools-focused', | 
					
						
							|  |  |  |   'new-window', | 
					
						
							|  |  |  |   'will-navigate', | 
					
						
							|  |  |  |   'did-navigate', | 
					
						
							|  |  |  |   'did-navigate-in-page', | 
					
						
							|  |  |  |   'close', | 
					
						
							|  |  |  |   'crashed', | 
					
						
							|  |  |  |   'gpu-crashed', | 
					
						
							|  |  |  |   'plugin-crashed', | 
					
						
							|  |  |  |   'destroyed', | 
					
						
							|  |  |  |   'page-title-updated', | 
					
						
							|  |  |  |   'page-favicon-updated', | 
					
						
							|  |  |  |   'enter-html-full-screen', | 
					
						
							|  |  |  |   'leave-html-full-screen', | 
					
						
							|  |  |  |   'media-started-playing', | 
					
						
							|  |  |  |   'media-paused', | 
					
						
							|  |  |  |   'found-in-page', | 
					
						
							| 
									
										
										
										
											2016-06-07 15:56:19 +09:00
										 |  |  |   'did-change-theme-color', | 
					
						
							|  |  |  |   'update-target-url' | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | ] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | let nextInstanceId = 0 | 
					
						
							|  |  |  | const guestInstances = {} | 
					
						
							|  |  |  | const embedderElementsMap = {} | 
					
						
							|  |  |  | const reverseEmbedderElementsMap = {} | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Moves the last element of array to the first one.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const moveLastToFirst = function (list) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   return list.unshift(list.pop()) | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Generate guestInstanceId.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const getNextInstanceId = function () { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   return ++nextInstanceId | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Create a new guest instance.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const createGuest = function (embedder, params) { | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   if (webViewManager == null) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     webViewManager = process.atomBinding('web_view_manager') | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const id = getNextInstanceId(embedder) | 
					
						
							|  |  |  |   const guest = webContents.create({ | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     isGuest: true, | 
					
						
							|  |  |  |     partition: params.partition, | 
					
						
							|  |  |  |     embedder: embedder | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   guestInstances[id] = { | 
					
						
							|  |  |  |     guest: guest, | 
					
						
							|  |  |  |     embedder: embedder | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Destroy guest when the embedder is gone or navigated.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |   const destroyEvents = ['will-destroy', 'crashed', 'did-navigate'] | 
					
						
							|  |  |  |   const destroy = function () { | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     if (guestInstances[id] != null) { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |       destroyGuest(embedder, id) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |   for (const event of destroyEvents) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     embedder.once(event, destroy) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:25:21 -07:00
										 |  |  |     // Users might also listen to the crashed event, so we must ensure the guest
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:44:21 -08:00
										 |  |  |     // is destroyed before users' listener gets called. It is done by moving our
 | 
					
						
							|  |  |  |     // listener to the first one in queue.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |     const listeners = embedder._events[event] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     if (Array.isArray(listeners)) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       moveLastToFirst(listeners) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   guest.once('destroyed', function () { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:33 -07:00
										 |  |  |     for (const event of destroyEvents) { | 
					
						
							|  |  |  |       embedder.removeListener(event, destroy) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Init guest web view after attached.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   guest.once('did-attach', function () { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  |     let opts | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     params = this.attachParams | 
					
						
							|  |  |  |     delete this.attachParams | 
					
						
							|  |  |  |     this.viewInstanceId = params.instanceId | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     this.setSize({ | 
					
						
							|  |  |  |       normal: { | 
					
						
							|  |  |  |         width: params.elementWidth, | 
					
						
							|  |  |  |         height: params.elementHeight | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       enableAutoSize: params.autosize, | 
					
						
							|  |  |  |       min: { | 
					
						
							|  |  |  |         width: params.minwidth, | 
					
						
							|  |  |  |         height: params.minheight | 
					
						
							|  |  |  |       }, | 
					
						
							|  |  |  |       max: { | 
					
						
							|  |  |  |         width: params.maxwidth, | 
					
						
							|  |  |  |         height: params.maxheight | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     if (params.src) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       opts = {} | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |       if (params.httpreferrer) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |         opts.httpReferrer = params.httpreferrer | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |       } | 
					
						
							|  |  |  |       if (params.useragent) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |         opts.userAgent = params.useragent | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       this.loadURL(params.src, opts) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-28 17:40:40 -07:00
										 |  |  |     guest.allowPopups = params.allowpopups | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Dispatch events to embedder.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |   const fn = function (event) { | 
					
						
							|  |  |  |     guest.on(event, function (_, ...args) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |       embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_DISPATCH_EVENT-' + guest.viewInstanceId, event].concat(args)) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     }) | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  |   for (const event of supportedWebViewEvents) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     fn(event) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Dispatch guest's IPC messages to embedder.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   guest.on('ipc-message-host', function (_, [channel, ...args]) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |     embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_IPC_MESSAGE-' + guest.viewInstanceId, channel].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
										 |  |  |   // Autosize.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   guest.on('size-changed', function (_, ...args) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |     embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args)) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-06-07 10:24:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   return id | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Attach the guest to an element of embedder.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const attachGuest = function (embedder, elementInstanceId, guestInstanceId, params) { | 
					
						
							|  |  |  |   let guest, key, oldGuestInstanceId, ref1, webPreferences | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   guest = guestInstances[guestInstanceId].guest | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |   // Destroy the old guest when attaching.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   key = (embedder.getId()) + '-' + elementInstanceId | 
					
						
							|  |  |  |   oldGuestInstanceId = embedderElementsMap[key] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   if (oldGuestInstanceId != null) { | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  |     // Reattachment to the same guest is not currently supported.
 | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     if (oldGuestInstanceId === guestInstanceId) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							|  |  |  |     if (guestInstances[oldGuestInstanceId] == null) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |       return | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     destroyGuest(embedder, oldGuestInstanceId) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							|  |  |  |   webPreferences = { | 
					
						
							|  |  |  |     guestInstanceId: guestInstanceId, | 
					
						
							|  |  |  |     nodeIntegration: (ref1 = params.nodeintegration) != null ? ref1 : false, | 
					
						
							|  |  |  |     plugins: params.plugins, | 
					
						
							| 
									
										
										
										
											2016-05-19 14:32:16 -07:00
										 |  |  |     zoomFactor: params.zoomFactor, | 
					
						
							| 
									
										
										
										
											2016-01-21 15:43:41 +05:30
										 |  |  |     webSecurity: !params.disablewebsecurity, | 
					
						
							| 
									
										
										
										
											2016-06-07 13:49:31 -07:00
										 |  |  |     blinkFeatures: params.blinkfeatures, | 
					
						
							| 
									
										
										
										
											2016-06-07 16:35:23 -07:00
										 |  |  |     disableBlinkFeatures: params.disableblinkfeatures | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-04-21 11:52:10 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   if (params.preload) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     webPreferences.preloadURL = params.preload | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   webViewManager.addGuest(guestInstanceId, elementInstanceId, embedder, guest, webPreferences) | 
					
						
							|  |  |  |   guest.attachParams = params | 
					
						
							|  |  |  |   embedderElementsMap[key] = guestInstanceId | 
					
						
							| 
									
										
										
										
											2016-03-28 17:40:40 -07:00
										 |  |  |   reverseEmbedderElementsMap[guestInstanceId] = key | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Destroy an existing guest instance.
 | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | const destroyGuest = function (embedder, id) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |   webViewManager.removeGuest(embedder, id) | 
					
						
							|  |  |  |   guestInstances[id].guest.destroy() | 
					
						
							|  |  |  |   delete guestInstances[id] | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const key = reverseEmbedderElementsMap[id] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   if (key != null) { | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  |     delete reverseEmbedderElementsMap[id] | 
					
						
							|  |  |  |     return delete embedderElementsMap[key] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-06 16:21:26 -07:00
										 |  |  | ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', function (event, params, requestId) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |   event.sender.send('ELECTRON_RESPONSE_' + requestId, createGuest(event.sender, params)) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-06 16:21:26 -07:00
										 |  |  | ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_ATTACH_GUEST', function (event, elementInstanceId, guestInstanceId, params) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |   attachGuest(event.sender, elementInstanceId, guestInstanceId, params) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-06 16:21:26 -07:00
										 |  |  | ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_DESTROY_GUEST', function (event, id) { | 
					
						
							| 
									
										
										
										
											2016-05-19 15:28:08 -07:00
										 |  |  |   destroyGuest(event.sender, id) | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-06 16:21:26 -07:00
										 |  |  | ipcMain.on('ELECTRON_GUEST_VIEW_MANAGER_SET_SIZE', function (event, id, params) { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  |   const guestInstance = guestInstances[id] | 
					
						
							|  |  |  |   return guestInstance != null ? guestInstance.guest.setSize(params) : void 0 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | }) | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Returns WebContents from its guest id.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | exports.getGuest = function (id) { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  |   const guestInstance = guestInstances[id] | 
					
						
							|  |  |  |   return guestInstance != null ? guestInstance.guest : void 0 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-14 10:35:29 -08:00
										 |  |  | // Returns the embedder of the guest.
 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | exports.getEmbedder = function (id) { | 
					
						
							| 
									
										
										
										
											2016-06-07 10:29:24 -07:00
										 |  |  |   const guestInstance = guestInstances[id] | 
					
						
							|  |  |  |   return guestInstance != null ? guestInstance.embedder : void 0 | 
					
						
							| 
									
										
										
										
											2016-03-24 13:15:04 -07:00
										 |  |  | } |