Merge branch 'master' into native-window-open

This commit is contained in:
Ryohei Ikegami 2017-04-27 12:03:55 +09:00
commit 1d73e84a29
59 changed files with 989 additions and 241 deletions

View file

@ -5,7 +5,7 @@ const {isSameOrigin} = process.atomBinding('v8_util')
const parseFeaturesString = require('../common/parse-features-string')
const hasProp = {}.hasOwnProperty
const frameToGuest = {}
const frameToGuest = new Map()
// Copy attribute of |parent| to |child| if it is not defined in |child|.
const mergeOptions = function (child, parent, visited) {
@ -48,11 +48,16 @@ const mergeBrowserWindowOptions = function (embedder, options) {
options.webPreferences.nodeIntegration = false
}
// Enable context isolation on child window if enable on parent window
// Enable context isolation on child window if enabled on parent window
if (embedder.getWebPreferences().contextIsolation === true) {
options.webPreferences.contextIsolation = true
}
// Disable JavaScript on child window if disabled on parent window
if (embedder.getWebPreferences().javascript === false) {
options.webPreferences.javascript = false
}
// Sets correct openerId here to give correct options to 'new-window' event handler
options.webPreferences.openerId = embedder.id
@ -87,10 +92,10 @@ const setupGuest = function (embedder, frameName, guest, options) {
guest.once('closed', closedByUser)
}
if (frameName) {
frameToGuest[frameName] = guest
frameToGuest.set(frameName, guest)
guest.frameName = frameName
guest.once('closed', function () {
delete frameToGuest[frameName]
frameToGuest.delete(frameName)
})
}
return guestId
@ -98,7 +103,7 @@ const setupGuest = function (embedder, frameName, guest, options) {
// Create a new guest created by |embedder| with |options|.
const createGuest = function (embedder, url, frameName, options, postData) {
let guest = frameToGuest[frameName]
let guest = frameToGuest.get(frameName)
if (frameName && (guest != null)) {
guest.loadURL(url)
return guest.webContents.id
@ -186,7 +191,7 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, url, frameName,
const options = {}
const ints = ['x', 'y', 'width', 'height', 'minWidth', 'maxWidth', 'minHeight', 'maxHeight', 'zoomFactor']
const webPreferences = ['zoomFactor', 'nodeIntegration', 'preload']
const webPreferences = ['zoomFactor', 'nodeIntegration', 'preload', 'javascript', 'contextIsolation']
const disposition = 'new-window'
// Used to store additional features
@ -197,6 +202,10 @@ ipcMain.on('ELECTRON_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, url, frameName,
if (value === undefined) {
additionalFeatures.push(key)
} else {
// Don't allow webPreferences to be set since it must be an object
// that cannot be directly overridden
if (key === 'webPreferences') return
if (webPreferences.includes(key)) {
if (options.webPreferences == null) {
options.webPreferences = {}