@@ -5,32 +5,35 @@ const v8Util = process.electronBinding('v8_util');
55const ipcRenderer = v8Util . getHiddenValue < Electron . IpcRenderer > ( global , 'ipc' ) ;
66const internal = false ;
77
8- ipcRenderer . send = function ( channel , ...args ) {
9- return ipc . send ( internal , channel , args ) ;
10- } ;
11-
12- ipcRenderer . sendSync = function ( channel , ...args ) {
13- return ipc . sendSync ( internal , channel , args ) [ 0 ] ;
14- } ;
15-
16- ipcRenderer . sendToHost = function ( channel , ...args ) {
17- return ipc . sendToHost ( channel , args ) ;
18- } ;
19-
20- ipcRenderer . sendTo = function ( webContentsId , channel , ...args ) {
21- return ipc . sendTo ( internal , false , webContentsId , channel , args ) ;
22- } ;
23-
24- ipcRenderer . invoke = async function ( channel , ...args ) {
25- const { error, result } = await ipc . invoke ( internal , channel , args ) ;
26- if ( error ) {
27- throw new Error ( `Error invoking remote method '${ channel } ': ${ error } ` ) ;
28- }
29- return result ;
30- } ;
31-
32- ipcRenderer . postMessage = function ( channel : string , message : any , transferables : any ) {
33- return ipc . postMessage ( channel , message , transferables ) ;
34- } ;
8+ // TODO(MarshallOfSound): Remove if statement when isolated_bundle and content_script_bundle are gone
9+ if ( ! ipcRenderer . send ) {
10+ ipcRenderer . send = function ( channel , ...args ) {
11+ return ipc . send ( internal , channel , args ) ;
12+ } ;
13+
14+ ipcRenderer . sendSync = function ( channel , ...args ) {
15+ return ipc . sendSync ( internal , channel , args ) [ 0 ] ;
16+ } ;
17+
18+ ipcRenderer . sendToHost = function ( channel , ...args ) {
19+ return ipc . sendToHost ( channel , args ) ;
20+ } ;
21+
22+ ipcRenderer . sendTo = function ( webContentsId , channel , ...args ) {
23+ return ipc . sendTo ( internal , false , webContentsId , channel , args ) ;
24+ } ;
25+
26+ ipcRenderer . invoke = async function ( channel , ...args ) {
27+ const { error, result } = await ipc . invoke ( internal , channel , args ) ;
28+ if ( error ) {
29+ throw new Error ( `Error invoking remote method '${ channel } ': ${ error } ` ) ;
30+ }
31+ return result ;
32+ } ;
33+
34+ ipcRenderer . postMessage = function ( channel : string , message : any , transferables : any ) {
35+ return ipc . postMessage ( channel , message , transferables ) ;
36+ } ;
37+ }
3538
3639export default ipcRenderer ;
0 commit comments