lib/browser/guest-window-manager.js
function (embedder, frameName, guest, options) {
  // When |embedder| is destroyed we should also destroy attached guest, and if
  // guest is closed by user then we should prevent |embedder| from double
  // closing guest.
  const guestId = guest.webContents.id
  const closedByEmbedder = function () {
    guest.removeListener('closed', closedByUser)
    guest.destroy()
  }
  const closedByUser = function () {
    embedder._sendInternal('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + guestId)
    embedder.removeListener('current-render-view-deleted', closedByEmbedder)
  }
  embedder.once('current-render-view-deleted', closedByEmbedder)
  guest.once('closed', closedByUser)
  if (frameName) {
    frameToGuest.set(frameName, guest)
    guest.frameName = frameName
    guest.once('closed', function () {
      frameToGuest.delete(frameName)
    })
  }
  return guestId
}
function (embedder, frameName, guest, options) {
  // When |embedder| is destroyed we should also destroy attached guest, and if
  // guest is closed by user then we should prevent |embedder| from double
  // closing guest.
  const guestId = guest.webContents.id
  const closedByEmbedder = function () {
    guest.removeListener('closed', closedByUser)
    guest.destroy()
  }
  const closedByUser = function () {
    embedder._sendInternal('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + guestId)
    embedder.removeListener('current-render-view-deleted', closedByEmbedder)
  }
  embedder.once('current-render-view-deleted', closedByEmbedder)
  guest.once('closed', closedByUser)
  if (frameName) {
    frameToGuest.set(frameName, guest)
    guest.frameName = frameName
    guest.once('closed', function () {
      frameToGuest.delete(frameName)
    })
  }
  return guestId
}
function ( embedder , frameName , guest , options ) { // When |embedder| is destroyed we should also destroy attached guest, and if // guest is closed by user then we should prevent |embedder| from double // closing guest. const guestId = guest . webContents . id const closedByEmbedder = function ( ) { guest . removeListener ( 'closed' , closedByUser ) guest . destroy ( ) } const closedByUser = function ( ) { embedder . _sendInternal ( 'ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_CLOSED_' + guestId ) embedder . removeListener ( 'current-render-view-deleted' , closedByEmbedder ) } embedder . once ( 'current-render-view-deleted' , closedByEmbedder ) guest . once ( 'closed' , closedByUser ) if ( frameName ) { frameToGuest . set ( frameName , guest ) guest . frameName = frameName guest . once ( 'closed' , function ( ) { frameToGuest . delete ( frameName ) } ) } return guestId }
Setup a new guest with |embedder|
Setup a new guest with |embedder|