refactor: use separate ipc-renderer-internal / ipc-main-internal APIs for Electron internals (#13940)

This commit is contained in:
Milan Burda 2018-10-06 13:48:00 +02:00 committed by Samuel Attard
parent f7122610cc
commit b50f86ef43
49 changed files with 322 additions and 133 deletions

View file

@ -1,6 +1,6 @@
'use strict'
const { ipcMain } = require('electron')
const ipcMain = require('@electron/internal/browser/ipc-main-internal')
const { desktopCapturer } = process.atomBinding('desktop_capturer')
const deepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b)
@ -49,14 +49,16 @@ desktopCapturer.emit = (event, name, sources) => {
})
if (handledWebContents) {
handledWebContents.send(capturerResult(handledRequest.id), result)
handledWebContents._sendInternal(capturerResult(handledRequest.id), result)
}
// Check the queue to see whether there is another identical request & handle
requestsQueue.forEach(request => {
const webContents = request.webContents
if (deepEqual(handledRequest.options, request.options)) {
if (webContents) webContents.send(capturerResult(request.id), result)
if (webContents) {
webContents._sendInternal(capturerResult(request.id), result)
}
} else {
unhandledRequestsQueue.push(request)
}