diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index db561708086e..bd48cac01579 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -326,10 +326,12 @@ bool WebContents::ShouldCreateWebContents( const GURL& target_url, const std::string& partition_id, content::SessionStorageNamespace* session_storage_namespace) { + auto disposition = (window_container_type == WINDOW_CONTAINER_TYPE_BACKGROUND) + ? "background-tab" : "new-window"; if (type_ == BROWSER_WINDOW) - Emit("-new-window", target_url, frame_name, NEW_FOREGROUND_TAB); + Emit("-new-window", target_url, frame_name, disposition); else - Emit("new-window", target_url, frame_name, NEW_FOREGROUND_TAB); + Emit("new-window", target_url, frame_name, disposition); return false; } diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 7bbf898dafb6..33aea5da4d0c 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -21,14 +21,14 @@ BrowserWindow.prototype._init = function () { } // Make new windows requested by links behave like "window.open" - this.webContents.on('-new-window', (event, url, frameName) => { + this.webContents.on('-new-window', (event, url, frameName, disposition) => { var options options = { show: true, width: 800, height: 600 } - return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options) + return ipcMain.emit('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, disposition, options) }) // window.resizeTo(...) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index bc88337eb062..0426ea51583e 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -80,9 +80,9 @@ var createGuest = function (embedder, url, frameName, options) { } // Routed window.open messages. -ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, options) { +ipcMain.on('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', function (event, url, frameName, disposition, options) { options = mergeBrowserWindowOptions(event.sender, options) - event.sender.emit('new-window', event, url, frameName, 'new-window', options) + event.sender.emit('new-window', event, url, frameName, disposition, options) if ((event.sender.isGuest() && !event.sender.allowPopups) || event.defaultPrevented) { event.returnValue = null } else { diff --git a/lib/renderer/override.js b/lib/renderer/override.js index 07f02566bccc..20c993d0bc5b 100644 --- a/lib/renderer/override.js +++ b/lib/renderer/override.js @@ -100,6 +100,7 @@ window.open = function (url, frameName, features) { // TODO remove hyphenated options in both of the following arrays for 1.0 const ints = ['x', 'y', 'width', 'height', 'min-width', 'minWidth', 'max-width', 'maxWidth', 'min-height', 'minHeight', 'max-height', 'maxHeight', 'zoom-factor', 'zoomFactor'] const webPreferences = ['zoom-factor', 'zoomFactor', 'node-integration', 'nodeIntegration', 'preload'] + const disposition = 'new-window' // Make sure to get rid of excessive whitespace in the property name ref1 = features.split(/,\s*/) @@ -146,7 +147,7 @@ window.open = function (url, frameName, features) { options[name] = parseInt(options[name], 10) } } - guestId = ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, options) + guestId = ipcRenderer.sendSync('ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', url, frameName, disposition, options) if (guestId) { return BrowserWindowProxy.getOrCreate(guestId) } else {