api: Add webContent.create() to create detached WebContents

This commit is contained in:
Cheng Zhao 2014-10-23 14:04:13 +08:00
parent c72d769ff0
commit d34cff2eef
5 changed files with 78 additions and 9 deletions

View file

@ -1,4 +1,5 @@
EventEmitter = require('events').EventEmitter
binding = process.atomBinding 'web_contents'
ipc = require 'ipc'
module.exports.wrap = (webContents) ->
@ -40,3 +41,11 @@ module.exports.wrap = (webContents) ->
ipc.emit channel, event, args...
webContents
module.exports.create = (options={}) ->
webContents = @wrap binding.create(options)
# Ensure the webContents is destroyed on exit.
process.on 'exit', -> webContents.destroy()
webContents