webview: fix partition attribute
This commit is contained in:
parent
c65ccb6857
commit
d180d3b168
7 changed files with 74 additions and 13 deletions
|
@ -1,3 +1,4 @@
|
|||
crypto = require 'crypto'
|
||||
ipc = require 'ipc'
|
||||
webContents = require 'web-contents'
|
||||
webViewManager = null # Doesn't exist in early initialization.
|
||||
|
@ -38,12 +39,21 @@ moveLastToFirst = (list) ->
|
|||
getNextInstanceId = (webContents) ->
|
||||
++nextInstanceId
|
||||
|
||||
# Generate URL encoded partition id.
|
||||
getPartitionId = (partition='default') ->
|
||||
persist = partition.startsWith('persist:')
|
||||
# Guest site url will be chrome-guest://fake-host/{persist}?{partitionId}
|
||||
partitionId = "chrome-guest://fake-host/"
|
||||
partitionId += if persist then 'persist?' else '?'
|
||||
partitionId += crypto.createHash('sha256').update(partition).digest('hex')
|
||||
|
||||
# Create a new guest instance.
|
||||
createGuest = (embedder, params) ->
|
||||
webViewManager ?= process.atomBinding 'web_view_manager'
|
||||
|
||||
id = getNextInstanceId embedder
|
||||
guest = webContents.create {isGuest: true, embedder}
|
||||
partitionId = getPartitionId params.partition
|
||||
guest = webContents.create {isGuest: true, partition: partitionId, embedder}
|
||||
guestInstances[id] = {guest, embedder}
|
||||
|
||||
# Destroy guest when the embedder is gone or navigated.
|
||||
|
@ -120,6 +130,7 @@ attachGuest = (embedder, elementInstanceId, guestInstanceId, params) ->
|
|||
plugins: params.plugins
|
||||
disableWebSecurity: params.disablewebsecurity
|
||||
preloadUrl: params.preload ? ''
|
||||
partitionId: getPartitionId(params.partition)
|
||||
|
||||
guest.attachParams = params
|
||||
embedderElementsMap[key] = guestInstanceId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue