fix: small refactoring regressions (#15206)

* fix: require('@electron/internal/browser/guest-view-manager')

* fix: add missing crashServicePid used by tests
This commit is contained in:
Milan Burda 2018-10-17 21:18:18 +02:00 committed by Shelley Vohr
parent a369a4172b
commit 508551b81b
4 changed files with 9 additions and 4 deletions

View file

@ -382,7 +382,7 @@ handleRemoteCommand('ELECTRON_BROWSER_GUEST_WEB_CONTENTS', function (event, cont
ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, requestId, guestInstanceId, method, args, hasCallback) { ipcMain.on('ELECTRON_BROWSER_ASYNC_CALL_TO_GUEST_VIEW', function (event, requestId, guestInstanceId, method, args, hasCallback) {
new Promise(resolve => { new Promise(resolve => {
const guestViewManager = require('./guest-view-manager') const guestViewManager = require('@electron/internal/browser/guest-view-manager')
const guest = guestViewManager.getGuest(guestInstanceId) const guest = guestViewManager.getGuest(guestInstanceId)
if (guest.hostWebContents !== event.sender) { if (guest.hostWebContents !== event.sender) {
throw new Error('Access denied') throw new Error('Access denied')
@ -434,6 +434,7 @@ const getTempDirectory = function () {
const crashReporterInit = function (options) { const crashReporterInit = function (options) {
const productName = options.productName || electron.app.getName() const productName = options.productName || electron.app.getName()
const crashesDirectory = path.join(getTempDirectory(), `${productName} Crashes`) const crashesDirectory = path.join(getTempDirectory(), `${productName} Crashes`)
let crashServicePid
if (process.platform === 'win32') { if (process.platform === 'win32') {
const env = { const env = {
@ -446,15 +447,18 @@ const crashReporterInit = function (options) {
'--v=1' '--v=1'
] ]
spawn(process.helperExecPath, args, { const crashServiceProcess = spawn(process.helperExecPath, args, {
env, env,
detached: true detached: true
}) })
crashServicePid = crashServiceProcess.pid
} }
return { return {
productName, productName,
crashesDirectory, crashesDirectory,
crashServicePid,
appVersion: electron.app.getVersion() appVersion: electron.app.getVersion()
} }
} }

View file

@ -58,6 +58,7 @@ class CrashReporter {
this.productName = ret.productName this.productName = ret.productName
this.crashesDirectory = ret.crashesDirectory this.crashesDirectory = ret.crashesDirectory
this.crashServicePid = ret.crashServicePid
if (extra == null) extra = {} if (extra == null) extra = {}
if (extra._productName == null) extra._productName = ret.productName if (extra._productName == null) extra._productName = ret.productName

View file

@ -19,7 +19,7 @@ crashReporter.start({
}) })
if (process.platform === 'win32') { if (process.platform === 'win32') {
ipcRenderer.sendSync('crash-service-pid', crashReporter._crashServiceProcess.pid) ipcRenderer.sendSync('crash-service-pid', crashReporter.crashServicePid)
} }
setImmediate(() => { setImmediate(() => {

View file

@ -20,7 +20,7 @@
}) })
if (process.platform === 'win32') { if (process.platform === 'win32') {
ipcRenderer.sendSync('crash-service-pid', crashReporter._crashServiceProcess.pid) ipcRenderer.sendSync('crash-service-pid', crashReporter.crashServicePid)
} }
if (!uploadToServer) { if (!uploadToServer) {