refactor: pass isWebViewTagEnabled via ELECTRON_BROWSER_SANDBOX_LOAD (#16238)
This commit is contained in:
parent
791d6de8b0
commit
5c250455ad
3 changed files with 6 additions and 4 deletions
|
@ -328,8 +328,8 @@ const isWebViewTagEnabledCache = new WeakMap()
|
||||||
|
|
||||||
const isWebViewTagEnabled = function (contents) {
|
const isWebViewTagEnabled = function (contents) {
|
||||||
if (!isWebViewTagEnabledCache.has(contents)) {
|
if (!isWebViewTagEnabledCache.has(contents)) {
|
||||||
const value = contents.getLastWebPreferences().webviewTag
|
const webPreferences = contents.getLastWebPreferences() || {}
|
||||||
isWebViewTagEnabledCache.set(contents, value)
|
isWebViewTagEnabledCache.set(contents, !!webPreferences.webviewTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
return isWebViewTagEnabledCache.get(contents)
|
return isWebViewTagEnabledCache.get(contents)
|
||||||
|
@ -437,3 +437,4 @@ const getEmbedder = function (guestInstanceId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.getGuestForWebContents = getGuestForWebContents
|
exports.getGuestForWebContents = getGuestForWebContents
|
||||||
|
exports.isWebViewTagEnabled = isWebViewTagEnabled
|
||||||
|
|
|
@ -504,6 +504,7 @@ ipcMain.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
|
||||||
preloadSrc,
|
preloadSrc,
|
||||||
preloadError,
|
preloadError,
|
||||||
isRemoteModuleEnabled: event.sender._isRemoteModuleEnabled(),
|
isRemoteModuleEnabled: event.sender._isRemoteModuleEnabled(),
|
||||||
|
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),
|
||||||
process: {
|
process: {
|
||||||
arch: process.arch,
|
arch: process.arch,
|
||||||
platform: process.platform,
|
platform: process.platform,
|
||||||
|
|
|
@ -29,7 +29,7 @@ Object.setPrototypeOf(process, EventEmitter.prototype)
|
||||||
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
|
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
|
||||||
|
|
||||||
const {
|
const {
|
||||||
preloadSrc, preloadError, isRemoteModuleEnabled, process: processProps
|
preloadSrc, preloadError, isRemoteModuleEnabled, isWebViewTagEnabled, process: processProps
|
||||||
} = ipcRenderer.sendSync('ELECTRON_BROWSER_SANDBOX_LOAD')
|
} = ipcRenderer.sendSync('ELECTRON_BROWSER_SANDBOX_LOAD')
|
||||||
|
|
||||||
process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
||||||
|
@ -125,7 +125,7 @@ if (binding.guestInstanceId) {
|
||||||
process.guestInstanceId = parseInt(binding.guestInstanceId)
|
process.guestInstanceId = parseInt(binding.guestInstanceId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.guestInstanceId && hasSwitch('webview-tag')) {
|
if (!process.guestInstanceId && isWebViewTagEnabled) {
|
||||||
// don't allow recursive `<webview>`
|
// don't allow recursive `<webview>`
|
||||||
require('@electron/internal/renderer/web-view/web-view').setupWebView(window)
|
require('@electron/internal/renderer/web-view/web-view').setupWebView(window)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue