enumerable: true, writable: false, value: id
id
+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
# renderer.
objectsWeakMap.add obj
+ # Also remember all windows.
+ windowsWeakMap.add obj if obj.constructor.name is 'Window'
+
exports.add = (process_id, routing_id, obj) ->
# Some native objects may already been added to objectsWeakMap, be care not
# to add it twice.
exports.get = (id) ->
objectsWeakMap.get id
+exports.getAllWindows = () ->
+ keys = windowsWeakMap.keys()
+ windowsWeakMap.get key for key in keys
+
exports.remove = (process_id, routing_id, storeId) ->
ObjectsStore.forRenderView(process_id, routing_id).remove storeId
catch e
event.result = type: 'error', value: e.message
+ipc.on 'ATOM_INTERNAL_CURRENT_WINDOW', (event, process_id, routing_id) ->
+ try
+ windows = objectsRegistry.getAllWindows()
+ for window in windows
+ break if window.getProcessID() == process_id and
+ window.getRoutingID() == routing_id
+ event.result = new Meta(process_id, routing_id, window)
+ catch e
+ event.result = type: 'error', value: e.message
+
ipc.on 'ATOM_INTERNAL_CONSTRUCTOR', (event, process_id, routing_id, id, args) ->
try
constructor = objectsRegistry.get id
exports.getObject = (id) ->
meta = ipc.sendChannelSync 'ATOM_INTERNAL_REFERENCE', id
metaToValue meta
+
+# Get current window object.
+exports.getCurrentWindow = ->
+ meta = ipc.sendChannelSync 'ATOM_INTERNAL_CURRENT_WINDOW'
+ metaToValue meta