2019-03-11 23:27:57 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
/* global nodeProcess, isolatedWorld, worldId */
|
|
|
|
|
|
|
|
const { EventEmitter } = require('events')
|
|
|
|
|
2019-04-26 09:55:12 +00:00
|
|
|
process.electronBinding = require('@electron/internal/common/atom-binding-setup').electronBindingSetup(nodeProcess._linkedBinding, 'renderer')
|
2019-03-11 23:27:57 +00:00
|
|
|
|
2019-03-18 19:37:06 +00:00
|
|
|
const v8Util = process.electronBinding('v8_util')
|
2019-03-19 13:45:48 +00:00
|
|
|
|
2019-03-11 23:27:57 +00:00
|
|
|
// The `lib/renderer/ipc-renderer-internal.js` module looks for the ipc object in the
|
|
|
|
// "ipc-internal" hidden value
|
2019-03-19 13:45:48 +00:00
|
|
|
v8Util.setHiddenValue(global, 'ipc-internal', v8Util.getHiddenValue(isolatedWorld, 'ipc-internal'))
|
|
|
|
|
2019-03-11 23:27:57 +00:00
|
|
|
// The process object created by browserify is not an event emitter, fix it so
|
|
|
|
// the API is more compatible with non-sandboxed renderers.
|
|
|
|
for (const prop of Object.keys(EventEmitter.prototype)) {
|
|
|
|
if (process.hasOwnProperty(prop)) {
|
|
|
|
delete process[prop]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Object.setPrototypeOf(process, EventEmitter.prototype)
|
|
|
|
|
|
|
|
const isolatedWorldArgs = v8Util.getHiddenValue(isolatedWorld, 'isolated-world-args')
|
|
|
|
|
|
|
|
if (isolatedWorldArgs) {
|
2019-03-30 01:10:21 +00:00
|
|
|
const { guestInstanceId, isHiddenPage, openerId, usesNativeWindowOpen } = isolatedWorldArgs
|
2019-03-11 23:27:57 +00:00
|
|
|
const { windowSetup } = require('@electron/internal/renderer/window-setup')
|
2019-03-30 01:10:21 +00:00
|
|
|
windowSetup(guestInstanceId, openerId, isHiddenPage, usesNativeWindowOpen)
|
2019-03-11 23:27:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const extensionId = v8Util.getHiddenValue(isolatedWorld, `extension-${worldId}`)
|
|
|
|
|
|
|
|
if (extensionId) {
|
|
|
|
const chromeAPI = require('@electron/internal/renderer/chrome-api')
|
2019-03-26 02:38:35 +00:00
|
|
|
chromeAPI.injectTo(extensionId, window)
|
2019-03-11 23:27:57 +00:00
|
|
|
}
|