Add options check.

This patch avoids main process never response back to renderer if the options is
invalid.
This commit is contained in:
Haojian Wu 2015-10-19 10:54:12 +08:00
parent 214f8477b3
commit fb4efec55d
4 changed files with 37 additions and 22 deletions

View file

@ -3,8 +3,9 @@ NativeImage = require 'native-image'
getSources = (options, callback) ->
ipc.send 'ATOM_BROWSER_DESKTOP_CAPTURER_GET_SOURCES', options
ipc.once 'ATOM_RENDERER_DESKTOP_CAPTURER_RESULT', (sources) ->
callback ({id: source.id, name: source.name, thumbnail: NativeImage.createFromDataUrl source.thumbnail} for source in sources)
ipc.once 'ATOM_RENDERER_DESKTOP_CAPTURER_RESULT', (error_message, sources) ->
error = if error_message then Error error_message else null
callback error, ({id: source.id, name: source.name, thumbnail: NativeImage.createFromDataUrl source.thumbnail} for source in sources)
module.exports =
getSources: getSources