Implement desktop capture API on OS X.

This commit is contained in:
Haojian Wu 2015-10-02 17:50:10 +08:00
parent a0638fe801
commit c9fbde321c
12 changed files with 768 additions and 6 deletions

View file

@ -3,17 +3,18 @@ EventEmitter = require('events').EventEmitter
bindings = process.atomBinding 'app'
sessionBindings = process.atomBinding 'session'
downloadItemBindings = process.atomBinding 'download_item'
desktopCapturerBindings = process.atomBinding 'desktop_capturer'
app = bindings.app
app.__proto__ = EventEmitter.prototype
wrapSession = (session) ->
# session is an Event Emitter.
session.__proto__ = EventEmitter.prototype
wrapToEventListener = (item) ->
# item is an Event Emitter.
item.__proto__ = EventEmitter.prototype
wrapDownloadItem = (download_item) ->
# download_item is an Event Emitter.
download_item.__proto__ = EventEmitter.prototype
wrapToEventListener download_item
# Be compatible with old APIs.
download_item.url = download_item.getUrl()
download_item.filename = download_item.getFilename()
@ -58,11 +59,14 @@ app.resolveProxy = -> @defaultSession.resolveProxy.apply @defaultSession, argume
app.on 'activate', (event, hasVisibleWindows) -> @emit 'activate-with-no-open-windows' if not hasVisibleWindows
# Session wrapper.
sessionBindings._setWrapSession wrapSession
sessionBindings._setWrapSession wrapToEventListener
process.once 'exit', sessionBindings._clearWrapSession
downloadItemBindings._setWrapDownloadItem wrapDownloadItem
process.once 'exit', downloadItemBindings._clearWrapDownloadItem
desktopCapturerBindings._setWrapDesktopCapturer wrapToEventListener
process.once 'exit', desktopCapturerBindings._clearWrapDesktopCapturer
# Only one App object pemitted.
module.exports = app