Store frame to guests in map
This commit is contained in:
parent
9643b2a5c5
commit
91a1e5cdfe
1 changed files with 4 additions and 4 deletions
|
@ -5,7 +5,7 @@ const {isSameOrigin} = process.atomBinding('v8_util')
|
||||||
const parseFeaturesString = require('../common/parse-features-string')
|
const parseFeaturesString = require('../common/parse-features-string')
|
||||||
|
|
||||||
const hasProp = {}.hasOwnProperty
|
const hasProp = {}.hasOwnProperty
|
||||||
const frameToGuest = {}
|
const frameToGuest = new Map()
|
||||||
|
|
||||||
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
// Copy attribute of |parent| to |child| if it is not defined in |child|.
|
||||||
const mergeOptions = function (child, parent, visited) {
|
const mergeOptions = function (child, parent, visited) {
|
||||||
|
@ -92,10 +92,10 @@ const setupGuest = function (embedder, frameName, guest, options) {
|
||||||
guest.once('closed', closedByUser)
|
guest.once('closed', closedByUser)
|
||||||
}
|
}
|
||||||
if (frameName) {
|
if (frameName) {
|
||||||
frameToGuest[frameName] = guest
|
frameToGuest.set(frameName, guest)
|
||||||
guest.frameName = frameName
|
guest.frameName = frameName
|
||||||
guest.once('closed', function () {
|
guest.once('closed', function () {
|
||||||
delete frameToGuest[frameName]
|
frameToGuest.delete(frameName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return guestId
|
return guestId
|
||||||
|
@ -103,7 +103,7 @@ const setupGuest = function (embedder, frameName, guest, options) {
|
||||||
|
|
||||||
// Create a new guest created by |embedder| with |options|.
|
// Create a new guest created by |embedder| with |options|.
|
||||||
const createGuest = function (embedder, url, frameName, options, postData) {
|
const createGuest = function (embedder, url, frameName, options, postData) {
|
||||||
let guest = frameToGuest[frameName]
|
let guest = frameToGuest.get(frameName)
|
||||||
if (frameName && (guest != null)) {
|
if (frameName && (guest != null)) {
|
||||||
guest.loadURL(url)
|
guest.loadURL(url)
|
||||||
return guest.webContents.id
|
return guest.webContents.id
|
||||||
|
|
Loading…
Reference in a new issue