Since we support inheritance of native objects, use js to send messages.
This commit is contained in:
parent
5a0aab2e4f
commit
3d267e2a9f
3 changed files with 8 additions and 19 deletions
|
@ -20,13 +20,6 @@ namespace api {
|
|||
|
||||
EventEmitter::EventEmitter(v8::Handle<v8::Object> wrapper) {
|
||||
Wrap(wrapper);
|
||||
|
||||
// process.emit('ATOM_BROWSER_INTERNAL_NEW', this).
|
||||
v8::Handle<v8::Value> args[] = {
|
||||
v8::String::New("ATOM_BROWSER_INTERNAL_NEW"),
|
||||
wrapper,
|
||||
};
|
||||
node::MakeCallback(node::process, "emit", 2, args);
|
||||
}
|
||||
|
||||
EventEmitter::~EventEmitter() {
|
||||
|
|
|
@ -9,6 +9,9 @@ module.exports = class BrowserWindow extends Window
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
# Remember all BrowserWindows.
|
||||
process.emit 'ATOM_BROWSER_INTERNAL_NEW_BROWSER_WINDOW', this
|
||||
|
||||
toggleDevTools: ->
|
||||
opened = v8Util.getHiddenValue this, 'devtoolsOpened'
|
||||
if opened
|
||||
|
|
|
@ -47,18 +47,11 @@ objectsWeakMap.add = (obj) ->
|
|||
|
||||
windowsWeakMap = new IDWeakMap
|
||||
|
||||
process.on 'ATOM_BROWSER_INTERNAL_NEW', (obj) ->
|
||||
# It's possible that user created a object in browser side and then want to
|
||||
# get it in renderer via remote.getObject. So we must add every native object
|
||||
# created in browser to the weak map even it may not be referenced by the
|
||||
# renderer.
|
||||
objectsWeakMap.add obj
|
||||
|
||||
# Also remember all windows.
|
||||
if obj.constructor is BrowserWindow
|
||||
id = windowsWeakMap.add obj
|
||||
obj.on 'destroyed', ->
|
||||
windowsWeakMap.remove id
|
||||
process.on 'ATOM_BROWSER_INTERNAL_NEW_BROWSER_WINDOW', (obj) ->
|
||||
# Remember all windows.
|
||||
id = windowsWeakMap.add obj
|
||||
obj.on 'destroyed', ->
|
||||
windowsWeakMap.remove id
|
||||
|
||||
exports.add = (processId, routingId, obj) ->
|
||||
# Some native objects may already been added to objectsWeakMap, be care not
|
||||
|
|
Loading…
Reference in a new issue