Register guest web view
This commit is contained in:
parent
81599f1535
commit
dacbf7a042
10 changed files with 126 additions and 56 deletions
|
@ -1,5 +1,6 @@
|
|||
ipc = require 'ipc'
|
||||
webContents = require 'web-contents'
|
||||
webViewManager = null # Doesn't exist in early initialization.
|
||||
|
||||
nextInstanceId = 0
|
||||
guestInstances = {}
|
||||
|
@ -10,17 +11,24 @@ getNextInstanceId = (webContents) ->
|
|||
|
||||
# Create a new guest instance.
|
||||
createGuest = (embedder, params) ->
|
||||
webViewManager ?= process.atomBinding 'web_view_manager'
|
||||
|
||||
id = getNextInstanceId embedder
|
||||
guestInstances[id] = webContents.create isGuest: true, guestInstanceId: id
|
||||
guestInstances[id] = webContents.create
|
||||
isGuest: true
|
||||
guestInstanceId: id
|
||||
storagePartitionId: params.storagePartitionId
|
||||
webViewManager.addGuest id, embedder, guestInstances[id]
|
||||
id
|
||||
|
||||
# Destroy an existing guest instance.
|
||||
destroyGuest = (id) ->
|
||||
webViewManager.removeGuest id
|
||||
guestInstances[id].destroy()
|
||||
delete guestInstances[id]
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_CREATE_GUEST', (event, type, params, requestId) ->
|
||||
event.sender.send "ATOM_SHELL_RESPONSE_#{requestId}", createGuest(event.sender)
|
||||
event.sender.send "ATOM_SHELL_RESPONSE_#{requestId}", createGuest(event.sender, params)
|
||||
|
||||
ipc.on 'ATOM_SHELL_GUEST_VIEW_MANAGER_DESTROY_GUEST', (event, guestInstanceId) ->
|
||||
destroyGuest guestInstanceId
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue