2021-11-10 00:59:33 +00:00
|
|
|
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal';
|
2024-10-03 03:52:01 +00:00
|
|
|
import type * as securityWarningsModule from '@electron/internal/renderer/security-warnings';
|
|
|
|
import type * as webFrameInitModule from '@electron/internal/renderer/web-frame-init';
|
2021-11-10 00:59:33 +00:00
|
|
|
import type * as webViewInitModule from '@electron/internal/renderer/web-view/web-view-init';
|
|
|
|
import type * as windowSetupModule from '@electron/internal/renderer/window-setup';
|
2024-10-03 03:52:01 +00:00
|
|
|
|
|
|
|
import { ipcRenderer } from 'electron/renderer';
|
2021-11-10 00:59:33 +00:00
|
|
|
|
|
|
|
const { mainFrame } = process._linkedBinding('electron_renderer_web_frame');
|
|
|
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
|
|
|
|
|
|
|
const nodeIntegration = mainFrame.getWebPreference('nodeIntegration');
|
|
|
|
const webviewTag = mainFrame.getWebPreference('webviewTag');
|
|
|
|
const isHiddenPage = mainFrame.getWebPreference('hiddenPage');
|
|
|
|
const isWebView = mainFrame.getWebPreference('isWebView');
|
|
|
|
|
|
|
|
// ElectronApiServiceImpl will look for the "ipcNative" hidden object when
|
|
|
|
// invoking the 'onMessage' callback.
|
|
|
|
v8Util.setHiddenValue(global, 'ipcNative', {
|
2023-08-28 14:29:27 +00:00
|
|
|
onMessage (internal: boolean, channel: string, ports: MessagePort[], args: any[]) {
|
2021-11-10 00:59:33 +00:00
|
|
|
const sender = internal ? ipcRendererInternal : ipcRenderer;
|
2023-08-28 14:29:27 +00:00
|
|
|
sender.emit(channel, { sender, ports }, ...args);
|
2021-11-10 00:59:33 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
switch (window.location.protocol) {
|
|
|
|
case 'devtools:': {
|
|
|
|
// Override some inspector APIs.
|
|
|
|
require('@electron/internal/renderer/inspector');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'chrome-extension:': {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'chrome:': {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
// Override default web functions.
|
|
|
|
const { windowSetup } = require('@electron/internal/renderer/window-setup') as typeof windowSetupModule;
|
2022-01-06 17:28:03 +00:00
|
|
|
windowSetup(isWebView, isHiddenPage);
|
2021-11-10 00:59:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load webview tag implementation.
|
|
|
|
if (process.isMainFrame) {
|
|
|
|
const { webViewInit } = require('@electron/internal/renderer/web-view/web-view-init') as typeof webViewInitModule;
|
|
|
|
webViewInit(webviewTag, isWebView);
|
|
|
|
}
|
|
|
|
|
|
|
|
const { webFrameInit } = require('@electron/internal/renderer/web-frame-init') as typeof webFrameInitModule;
|
2024-10-03 03:52:01 +00:00
|
|
|
|
2021-11-10 00:59:33 +00:00
|
|
|
webFrameInit();
|
|
|
|
|
|
|
|
// Warn about security issues
|
|
|
|
if (process.isMainFrame) {
|
|
|
|
const { securityWarnings } = require('@electron/internal/renderer/security-warnings') as typeof securityWarningsModule;
|
|
|
|
securityWarnings(nodeIntegration);
|
|
|
|
}
|