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) {
|
||||
if (!isWebViewTagEnabledCache.has(contents)) {
|
||||
const value = contents.getLastWebPreferences().webviewTag
|
||||
isWebViewTagEnabledCache.set(contents, value)
|
||||
const webPreferences = contents.getLastWebPreferences() || {}
|
||||
isWebViewTagEnabledCache.set(contents, !!webPreferences.webviewTag)
|
||||
}
|
||||
|
||||
return isWebViewTagEnabledCache.get(contents)
|
||||
|
@ -437,3 +437,4 @@ const getEmbedder = function (guestInstanceId) {
|
|||
}
|
||||
|
||||
exports.getGuestForWebContents = getGuestForWebContents
|
||||
exports.isWebViewTagEnabled = isWebViewTagEnabled
|
||||
|
|
|
@ -504,6 +504,7 @@ ipcMain.on('ELECTRON_BROWSER_SANDBOX_LOAD', function (event) {
|
|||
preloadSrc,
|
||||
preloadError,
|
||||
isRemoteModuleEnabled: event.sender._isRemoteModuleEnabled(),
|
||||
isWebViewTagEnabled: guestViewManager.isWebViewTagEnabled(event.sender),
|
||||
process: {
|
||||
arch: process.arch,
|
||||
platform: process.platform,
|
||||
|
|
|
@ -29,7 +29,7 @@ Object.setPrototypeOf(process, EventEmitter.prototype)
|
|||
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
|
||||
|
||||
const {
|
||||
preloadSrc, preloadError, isRemoteModuleEnabled, process: processProps
|
||||
preloadSrc, preloadError, isRemoteModuleEnabled, isWebViewTagEnabled, process: processProps
|
||||
} = ipcRenderer.sendSync('ELECTRON_BROWSER_SANDBOX_LOAD')
|
||||
|
||||
process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
||||
|
@ -125,7 +125,7 @@ if (binding.guestInstanceId) {
|
|||
process.guestInstanceId = parseInt(binding.guestInstanceId)
|
||||
}
|
||||
|
||||
if (!process.guestInstanceId && hasSwitch('webview-tag')) {
|
||||
if (!process.guestInstanceId && isWebViewTagEnabled) {
|
||||
// don't allow recursive `<webview>`
|
||||
require('@electron/internal/renderer/web-view/web-view').setupWebView(window)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue