diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/components/services/content/ServiceWebview.js | 2 | ||||
-rw-r--r-- | src/electron-util.ts | 6 | ||||
-rw-r--r-- | src/index.ts | 12 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/components/services/content/ServiceWebview.js b/src/components/services/content/ServiceWebview.js index f90710c31..38450b98f 100644 --- a/src/components/services/content/ServiceWebview.js +++ b/src/components/services/content/ServiceWebview.js | |||
@@ -109,7 +109,7 @@ class ServiceWebview extends Component { | |||
109 | nodeintegration | 109 | nodeintegration |
110 | webpreferences={`spellcheck=${ | 110 | webpreferences={`spellcheck=${ |
111 | isSpellcheckerEnabled ? 1 : 0 | 111 | isSpellcheckerEnabled ? 1 : 0 |
112 | }, contextIsolation=1, nativeWindowOpen=1, enableRemoteModule=1`} | 112 | }, contextIsolation=1, nativeWindowOpen=1`} |
113 | /> | 113 | /> |
114 | ); | 114 | ); |
115 | } | 115 | } |
diff --git a/src/electron-util.ts b/src/electron-util.ts index 3c395ab10..eede55786 100644 --- a/src/electron-util.ts +++ b/src/electron-util.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | // Enhanced from: https://github.com/dertieran/electron-util/blob/replace-remote/source/api.js | 1 | // Enhanced from: https://github.com/dertieran/electron-util/blob/replace-remote/source/api.js |
2 | 2 | ||
3 | import * as electron from 'electron'; | 3 | import * as electron from 'electron'; |
4 | import { initialize } from '@electron/remote/main'; | 4 | import { initialize, enable } from '@electron/remote/main'; |
5 | 5 | ||
6 | export const initializeRemote = () => { | 6 | export const initializeRemote = () => { |
7 | if (process.type !== 'browser') { | 7 | if (process.type !== 'browser') { |
@@ -13,6 +13,10 @@ export const initializeRemote = () => { | |||
13 | initialize(); | 13 | initialize(); |
14 | }; | 14 | }; |
15 | 15 | ||
16 | export const enableWebContents = (webContents: electron.WebContents) => { | ||
17 | enable(webContents); | ||
18 | } | ||
19 | |||
16 | export const remote = new Proxy( | 20 | export const remote = new Proxy( |
17 | {}, | 21 | {}, |
18 | { | 22 | { |
diff --git a/src/index.ts b/src/index.ts index c61523584..013cf93ce 100644 --- a/src/index.ts +++ b/src/index.ts | |||
@@ -13,7 +13,7 @@ import { emptyDirSync, ensureFileSync } from 'fs-extra'; | |||
13 | import { join } from 'path'; | 13 | import { join } from 'path'; |
14 | import windowStateKeeper from 'electron-window-state'; | 14 | import windowStateKeeper from 'electron-window-state'; |
15 | import ms from 'ms'; | 15 | import ms from 'ms'; |
16 | import { initializeRemote } from './electron-util'; | 16 | import { enableWebContents, initializeRemote } from './electron-util'; |
17 | import { enforceMacOSAppLocation } from './enforce-macos-app-location'; | 17 | import { enforceMacOSAppLocation } from './enforce-macos-app-location'; |
18 | 18 | ||
19 | initializeRemote(); | 19 | initializeRemote(); |
@@ -214,13 +214,18 @@ const createWindow = () => { | |||
214 | webviewTag: true, | 214 | webviewTag: true, |
215 | preload: join(__dirname, 'sentry.js'), | 215 | preload: join(__dirname, 'sentry.js'), |
216 | nativeWindowOpen: true, | 216 | nativeWindowOpen: true, |
217 | // @ts-expect-error Object literal may only specify known properties, and 'enableRemoteModule' does not exist in type 'WebPreferences'. | ||
218 | enableRemoteModule: true, | ||
219 | }, | 217 | }, |
220 | }); | 218 | }); |
221 | 219 | ||
220 | enableWebContents(mainWindow.webContents); | ||
221 | |||
222 | app.on('browser-window-created', (_, window) => { | ||
223 | enableWebContents(window.webContents); | ||
224 | }); | ||
225 | |||
222 | app.on('web-contents-created', (_e, contents) => { | 226 | app.on('web-contents-created', (_e, contents) => { |
223 | if (contents.getType() === 'webview') { | 227 | if (contents.getType() === 'webview') { |
228 | enableWebContents(contents); | ||
224 | contents.on('new-window', event => { | 229 | contents.on('new-window', event => { |
225 | event.preventDefault(); | 230 | event.preventDefault(); |
226 | }); | 231 | }); |
@@ -523,6 +528,7 @@ ipcMain.on('open-browser-window', (_e, { url, serviceId }) => { | |||
523 | nativeWindowOpen: true, | 528 | nativeWindowOpen: true, |
524 | }, | 529 | }, |
525 | }); | 530 | }); |
531 | enableWebContents(child.webContents); | ||
526 | child.show(); | 532 | child.show(); |
527 | child.loadURL(url); | 533 | child.loadURL(url); |
528 | debug('Received open-browser-window', url); | 534 | debug('Received open-browser-window', url); |