diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 15411fb85769..1aa84bb15c48 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -1,14 +1,10 @@ EventEmitter = require('events').EventEmitter -IDWeakMap = process.atomBinding('id_weak_map').IDWeakMap app = require 'app' ipc = require 'ipc' BrowserWindow = process.atomBinding('window').BrowserWindow BrowserWindow::__proto__ = EventEmitter.prototype -# Store all created windows in the weak map. -BrowserWindow.windows = new IDWeakMap - BrowserWindow::_init = -> # Simulate the application menu on platforms other than OS X. if process.platform isnt 'darwin' @@ -31,11 +27,6 @@ BrowserWindow::_init = -> @on 'focus', (event) => app.emit 'browser-window-focus', event, this - # Remove the window from weak map immediately when it's destroyed, since we - # could be iterating windows before GC happened. - @once 'closed', => - BrowserWindow.windows.remove @id if BrowserWindow.windows.has @id - BrowserWindow::setMenu = (menu) -> throw new TypeError('Invalid menu') unless menu is null or menu?.constructor?.name is 'Menu' diff --git a/atom/browser/lib/guest-window-manager.coffee b/atom/browser/lib/guest-window-manager.coffee index aef8b0def24d..e26c93513c9c 100644 --- a/atom/browser/lib/guest-window-manager.coffee +++ b/atom/browser/lib/guest-window-manager.coffee @@ -48,17 +48,14 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', (event, args...) -> event.returnValue = createGuest event.sender, args... ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_CLOSE', (event, guestId) -> - return unless BrowserWindow.windows.has guestId - BrowserWindow.windows.get(guestId).destroy() + BrowserWindow.fromId(guestId)?.destroy() ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_METHOD', (event, guestId, method, args...) -> - return unless BrowserWindow.windows.has guestId - BrowserWindow.windows.get(guestId)[method] args... + BrowserWindow.fromId(guestId)?[method] args... ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_POSTMESSAGE', (event, guestId, message, targetOrigin) -> - return unless BrowserWindow.windows.has guestId - guestContents = BrowserWindow.windows.get(guestId).webContents - if guestContents.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*' + guestContents = BrowserWindow.fromId(guestId)?.webContents + if guestContents?.getUrl().indexOf(targetOrigin) is 0 or targetOrigin is '*' guestContents.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', message, targetOrigin ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, message, targetOrigin) -> @@ -67,5 +64,4 @@ ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPENER_POSTMESSAGE', (event, mess embedder.send 'ATOM_SHELL_GUEST_WINDOW_POSTMESSAGE', message, targetOrigin ipc.on 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WEB_CONTENTS_METHOD', (event, guestId, method, args...) -> - return unless BrowserWindow.windows.has guestId - BrowserWindow.windows.get(guestId).webContents?[method] args... + BrowserWindow.fromId(guestId)?.webContents?[method] args...