Make <a target="_blank"> open window by default

This commit is contained in:
Cheng Zhao 2014-10-27 23:46:25 +08:00
parent f44be28309
commit cc9ff77dd2

View file

@ -1,6 +1,7 @@
EventEmitter = require('events').EventEmitter
IDWeakMap = require 'id-weak-map'
app = require 'app'
ipc = require 'ipc'
wrapWebContents = require('web-contents').wrap
BrowserWindow = process.atomBinding('window').BrowserWindow
@ -23,9 +24,11 @@ BrowserWindow::_init = ->
value: BrowserWindow.windows.add(this)
enumerable: true
# Route the "new-window" event to webContents.
@on 'new-window', (args...) =>
@webContents?.emit 'new-window', args...
# Make new windows requested by links behave like "window.open"
@on 'new-window', (event, url, frameName) =>
event.sender = @webContents
options = show: true, width: 800, height: 600
ipc.emit 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options
# Remove the window from weak map immediately when it's destroyed, since we
# could be iterating windows before GC happened.