Skip to content

Commit

Permalink
refactor: pass isWebViewTagEnabled via ELECTRON_BROWSER_SANDBOX_LOAD (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak authored and alexeykuzmin committed Jan 8, 2019
1 parent 791d6de commit 5c25045
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/browser/guest-view-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -437,3 +437,4 @@ const getEmbedder = function (guestInstanceId) {
}

exports.getGuestForWebContents = getGuestForWebContents
exports.isWebViewTagEnabled = isWebViewTagEnabled
1 change: 1 addition & 0 deletions lib/browser/rpc-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/sandboxed_renderer/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down

0 comments on commit 5c25045

Please sign in to comment.