refactor: add emitCustomEvent() helper (#17960)

This commit is contained in:
Milan Burda 2019-05-01 15:07:57 +02:00 committed by Alexey Kuzmin
parent aebad6fd21
commit 6f5c850d60
5 changed files with 35 additions and 48 deletions

View file

@ -1,22 +1,12 @@
'use strict'
const ipcMainUtils = require('@electron/internal/browser/ipc-main-internal-utils')
const { createDesktopCapturer } = process.electronBinding('desktop_capturer')
const eventBinding = process.electronBinding('event')
const deepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b)
let currentlyRunning = []
ipcMainUtils.handle('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', (event, captureWindow, captureScreen, thumbnailSize, fetchWindowIcons) => {
const customEvent = eventBinding.createWithSender(event.sender)
event.sender.emit('desktop-capturer-get-sources', customEvent)
if (customEvent.defaultPrevented) {
return []
}
exports.getSources = (event, captureWindow, captureScreen, thumbnailSize, fetchWindowIcons) => {
const options = {
captureWindow,
captureScreen,
@ -69,7 +59,7 @@ ipcMainUtils.handle('ELECTRON_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', (event, cap
})
return getSources
})
}
const createCapturerEmitHandler = (capturer, request) => {
return function handlEmitOnCapturer (event, name, sources, fetchWindowIcons) {