Pass "preload" attribute to GuestViewManager
This commit is contained in:
parent
c764b7b023
commit
8d8bfcd120
1 changed files with 14 additions and 0 deletions
|
@ -21,6 +21,7 @@ WEB_VIEW_ATTRIBUTE_MINWIDTH = 'minwidth'
|
||||||
WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'
|
WEB_VIEW_ATTRIBUTE_PARTITION = 'partition'
|
||||||
WEB_VIEW_ATTRIBUTE_NODEINTEGRATION = 'nodeintegration'
|
WEB_VIEW_ATTRIBUTE_NODEINTEGRATION = 'nodeintegration'
|
||||||
WEB_VIEW_ATTRIBUTE_PLUGINS = 'plugins'
|
WEB_VIEW_ATTRIBUTE_PLUGINS = 'plugins'
|
||||||
|
WEB_VIEW_ATTRIBUTE_PRELOAD = 'preload'
|
||||||
AUTO_SIZE_ATTRIBUTES = [
|
AUTO_SIZE_ATTRIBUTES = [
|
||||||
WEB_VIEW_ATTRIBUTE_AUTOSIZE,
|
WEB_VIEW_ATTRIBUTE_AUTOSIZE,
|
||||||
WEB_VIEW_ATTRIBUTE_MAXHEIGHT,
|
WEB_VIEW_ATTRIBUTE_MAXHEIGHT,
|
||||||
|
@ -38,6 +39,8 @@ ERROR_MSG_CONTENTWINDOW_NOT_AVAILABLE = '<webview>: ' +
|
||||||
'contentWindow is not available at this time. It will become available ' +
|
'contentWindow is not available at this time. It will become available ' +
|
||||||
'when the page has finished loading.'
|
'when the page has finished loading.'
|
||||||
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.'
|
ERROR_MSG_INVALID_PARTITION_ATTRIBUTE = 'Invalid partition attribute.'
|
||||||
|
ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE =
|
||||||
|
'Only "file:" or "asar:" protocol is supported in "preload" attribute.'
|
||||||
|
|
||||||
# Represents the state of the storage partition.
|
# Represents the state of the storage partition.
|
||||||
class Partition
|
class Partition
|
||||||
|
@ -379,6 +382,17 @@ class WebView
|
||||||
storagePartitionId: storagePartitionId
|
storagePartitionId: storagePartitionId
|
||||||
nodeIntegration: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_NODEINTEGRATION
|
nodeIntegration: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_NODEINTEGRATION
|
||||||
plugins: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_PLUGINS
|
plugins: @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_PLUGINS
|
||||||
|
if @webviewNode.hasAttribute WEB_VIEW_ATTRIBUTE_PRELOAD
|
||||||
|
preload = @webviewNode.getAttribute WEB_VIEW_ATTRIBUTE_PRELOAD
|
||||||
|
# Get the full path.
|
||||||
|
a = document.createElement 'a'
|
||||||
|
a.href = preload
|
||||||
|
params.preload = a.href
|
||||||
|
# Only support file: or asar: protocol.
|
||||||
|
protocol = params.preload.substr 0, 5
|
||||||
|
unless protocol in ['file:', 'asar:']
|
||||||
|
delete params.preload
|
||||||
|
console.error ERROR_MSG_INVALID_PRELOAD_ATTRIBUTE
|
||||||
guestViewInternal.createGuest 'webview', params, (guestInstanceId) =>
|
guestViewInternal.createGuest 'webview', params, (guestInstanceId) =>
|
||||||
@pendingGuestCreation = false
|
@pendingGuestCreation = false
|
||||||
unless @elementAttached
|
unless @elementAttached
|
||||||
|
|
Loading…
Reference in a new issue