This commit is contained in:
Milan Burda 2018-12-12 22:31:16 +01:00 коммит произвёл Charles Kerr
Родитель 1152fecb75
Коммит c65a0d90b8
5 изменённых файлов: 17 добавлений и 20 удалений

Просмотреть файл

@ -70,7 +70,6 @@ filenames = {
"lib/renderer/inspector.js", "lib/renderer/inspector.js",
"lib/renderer/ipc-renderer-internal.js", "lib/renderer/ipc-renderer-internal.js",
"lib/renderer/remote.js", "lib/renderer/remote.js",
"lib/renderer/override.js",
"lib/renderer/security-warnings.js", "lib/renderer/security-warnings.js",
"lib/renderer/web-frame-init.js", "lib/renderer/web-frame-init.js",
"lib/renderer/window-setup.js", "lib/renderer/window-setup.js",

Просмотреть файл

@ -138,7 +138,7 @@ const plainObjectToMeta = function (obj) {
} }
// Convert Error into meta data. // Convert Error into meta data.
const exceptionToMeta = function (sender, contextId, error) { const exceptionToMeta = function (error) {
return { return {
type: 'exception', type: 'exception',
value: errorUtils.serialize(error) value: errorUtils.serialize(error)
@ -275,7 +275,7 @@ const handleRemoteCommand = function (channel, handler) {
try { try {
returnValue = handler(event, contextId, ...args) returnValue = handler(event, contextId, ...args)
} catch (error) { } catch (error) {
returnValue = exceptionToMeta(event.sender, contextId, error) returnValue = exceptionToMeta(error)
} }
if (returnValue !== undefined) { if (returnValue !== undefined) {

Просмотреть файл

@ -311,7 +311,9 @@ exports.getCurrentWindow = () => {
// Get current WebContents object. // Get current WebContents object.
exports.getCurrentWebContents = () => { exports.getCurrentWebContents = () => {
return metaToValue(ipcRenderer.sendSync('ELECTRON_BROWSER_CURRENT_WEB_CONTENTS', contextId)) const command = 'ELECTRON_BROWSER_CURRENT_WEB_CONTENTS'
const meta = ipcRenderer.sendSync(command, contextId)
return metaToValue(meta)
} }
// Get a global object in browser. // Get a global object in browser.

Просмотреть файл

@ -37,13 +37,15 @@ let preloadScript = null
let preloadScripts = [] let preloadScripts = []
let isBackgroundPage = false let isBackgroundPage = false
let appPath = null let appPath = null
let guestInstanceId = null
let openerId = null
for (const arg of process.argv) { for (const arg of process.argv) {
if (arg.indexOf('--guest-instance-id=') === 0) { if (arg.indexOf('--guest-instance-id=') === 0) {
// This is a guest web view. // This is a guest web view.
process.guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1)) guestInstanceId = parseInt(arg.substr(arg.indexOf('=') + 1))
} else if (arg.indexOf('--opener-id=') === 0) { } else if (arg.indexOf('--opener-id=') === 0) {
// This is a guest BrowserWindow. // This is a guest BrowserWindow.
process.openerId = parseInt(arg.substr(arg.indexOf('=') + 1)) openerId = parseInt(arg.substr(arg.indexOf('=') + 1))
} else if (arg.indexOf('--node-integration=') === 0) { } else if (arg.indexOf('--node-integration=') === 0) {
nodeIntegration = arg.substr(arg.indexOf('=') + 1) === 'true' nodeIntegration = arg.substr(arg.indexOf('=') + 1) === 'true'
} else if (arg.indexOf('--preload=') === 0) { } else if (arg.indexOf('--preload=') === 0) {
@ -59,6 +61,9 @@ for (const arg of process.argv) {
} }
} }
const hiddenPage = process.argv.includes('--hidden-page')
const usesNativeWindowOpen = process.argv.includes('--native-window-open')
// The webContents preload script is loaded after the session preload scripts. // The webContents preload script is loaded after the session preload scripts.
if (preloadScript) { if (preloadScript) {
preloadScripts.push(preloadScript) preloadScripts.push(preloadScript)
@ -77,13 +82,13 @@ if (window.location.protocol === 'chrome-devtools:') {
nodeIntegration = false nodeIntegration = false
} else { } else {
// Override default web functions. // Override default web functions.
require('@electron/internal/renderer/override') require('@electron/internal/renderer/window-setup')(ipcRenderer, guestInstanceId, openerId, hiddenPage, usesNativeWindowOpen)
// Inject content scripts. // Inject content scripts.
require('@electron/internal/renderer/content-scripts-injector') require('@electron/internal/renderer/content-scripts-injector')
// Load webview tag implementation. // Load webview tag implementation.
if (webviewTag && process.guestInstanceId == null) { if (webviewTag && guestInstanceId == null) {
require('@electron/internal/renderer/web-view/web-view') require('@electron/internal/renderer/web-view/web-view')
require('@electron/internal/renderer/web-view/web-view-attributes') require('@electron/internal/renderer/web-view/web-view-attributes')
} }
@ -162,11 +167,11 @@ require('@electron/internal/renderer/security-warnings')(nodeIntegration)
// Report focus/blur events of webview to browser. // Report focus/blur events of webview to browser.
// Note that while Chromium content APIs have observer for focus/blur, they // Note that while Chromium content APIs have observer for focus/blur, they
// unfortunately do not work for webview. // unfortunately do not work for webview.
if (process.guestInstanceId) { if (guestInstanceId) {
window.addEventListener('focus', () => { window.addEventListener('focus', () => {
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_FOCUS_CHANGE', true, process.guestInstanceId) ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_FOCUS_CHANGE', true, guestInstanceId)
}) })
window.addEventListener('blur', () => { window.addEventListener('blur', () => {
ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_FOCUS_CHANGE', false, process.guestInstanceId) ipcRenderer.send('ELECTRON_GUEST_VIEW_MANAGER_FOCUS_CHANGE', false, guestInstanceId)
}) })
} }

Просмотреть файл

@ -1,9 +0,0 @@
'use strict'
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
const { guestInstanceId, openerId } = process
const hiddenPage = process.argv.includes('--hidden-page')
const usesNativeWindowOpen = process.argv.includes('--native-window-open')
require('@electron/internal/renderer/window-setup')(ipcRenderer, guestInstanceId, openerId, hiddenPage, usesNativeWindowOpen)