chore: misc cleanup (#16037)
This commit is contained in:
parent
1152fecb75
commit
c65a0d90b8
5 changed files with 17 additions and 20 deletions
|
@ -70,7 +70,6 @@ filenames = {
|
|||
"lib/renderer/inspector.js",
|
||||
"lib/renderer/ipc-renderer-internal.js",
|
||||
"lib/renderer/remote.js",
|
||||
"lib/renderer/override.js",
|
||||
"lib/renderer/security-warnings.js",
|
||||
"lib/renderer/web-frame-init.js",
|
||||
"lib/renderer/window-setup.js",
|
||||
|
|
|
@ -138,7 +138,7 @@ const plainObjectToMeta = function (obj) {
|
|||
}
|
||||
|
||||
// Convert Error into meta data.
|
||||
const exceptionToMeta = function (sender, contextId, error) {
|
||||
const exceptionToMeta = function (error) {
|
||||
return {
|
||||
type: 'exception',
|
||||
value: errorUtils.serialize(error)
|
||||
|
@ -275,7 +275,7 @@ const handleRemoteCommand = function (channel, handler) {
|
|||
try {
|
||||
returnValue = handler(event, contextId, ...args)
|
||||
} catch (error) {
|
||||
returnValue = exceptionToMeta(event.sender, contextId, error)
|
||||
returnValue = exceptionToMeta(error)
|
||||
}
|
||||
|
||||
if (returnValue !== undefined) {
|
||||
|
|
|
@ -311,7 +311,9 @@ exports.getCurrentWindow = () => {
|
|||
|
||||
// Get current WebContents object.
|
||||
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.
|
||||
|
|
|
@ -37,13 +37,15 @@ let preloadScript = null
|
|||
let preloadScripts = []
|
||||
let isBackgroundPage = false
|
||||
let appPath = null
|
||||
let guestInstanceId = null
|
||||
let openerId = null
|
||||
for (const arg of process.argv) {
|
||||
if (arg.indexOf('--guest-instance-id=') === 0) {
|
||||
// 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) {
|
||||
// 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) {
|
||||
nodeIntegration = arg.substr(arg.indexOf('=') + 1) === 'true'
|
||||
} 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.
|
||||
if (preloadScript) {
|
||||
preloadScripts.push(preloadScript)
|
||||
|
@ -77,13 +82,13 @@ if (window.location.protocol === 'chrome-devtools:') {
|
|||
nodeIntegration = false
|
||||
} else {
|
||||
// Override default web functions.
|
||||
require('@electron/internal/renderer/override')
|
||||
require('@electron/internal/renderer/window-setup')(ipcRenderer, guestInstanceId, openerId, hiddenPage, usesNativeWindowOpen)
|
||||
|
||||
// Inject content scripts.
|
||||
require('@electron/internal/renderer/content-scripts-injector')
|
||||
|
||||
// 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-attributes')
|
||||
}
|
||||
|
@ -162,11 +167,11 @@ require('@electron/internal/renderer/security-warnings')(nodeIntegration)
|
|||
// Report focus/blur events of webview to browser.
|
||||
// Note that while Chromium content APIs have observer for focus/blur, they
|
||||
// unfortunately do not work for webview.
|
||||
if (process.guestInstanceId) {
|
||||
if (guestInstanceId) {
|
||||
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', () => {
|
||||
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)
|
Loading…
Reference in a new issue