From fefeb3975793d520ce9cd9d768f3f898f30149bb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 27 Oct 2014 19:14:17 +0800 Subject: [PATCH] Add "frameName" as paramter for "new-window" event --- atom/browser/api/atom_api_web_contents.cc | 2 +- atom/browser/api/lib/web-contents.coffee | 4 ++-- atom/renderer/lib/guest-view-internal.coffee | 2 +- atom/renderer/lib/override.coffee | 6 +++--- docs/api/web-view-tag.md | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 5487234eb14..87cec5d5880 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -88,7 +88,7 @@ bool WebContents::ShouldCreateWebContents( content::SessionStorageNamespace* session_storage_namespace) { base::ListValue args; args.AppendString(target_url.spec()); - args.AppendString(partition_id); + args.AppendString(frame_name); Emit("new-window", args); return false; } diff --git a/atom/browser/api/lib/web-contents.coffee b/atom/browser/api/lib/web-contents.coffee index 8ddcf361eb6..f27a0689ac7 100644 --- a/atom/browser/api/lib/web-contents.coffee +++ b/atom/browser/api/lib/web-contents.coffee @@ -3,8 +3,8 @@ binding = process.atomBinding 'web_contents' ipc = require 'ipc' # Routed window.open messages. -ipc.on 'ATOM_SHELL_WEB_CONTENTS_WINDOW_OPEN', (event, url, name, features) -> - event.sender.emit 'new-window', url, name, features +ipc.on 'ATOM_SHELL_WEB_CONTENTS_WINDOW_OPEN', (event, args...) -> + event.sender.emit 'new-window', event, args... module.exports.wrap = (webContents) -> return null unless webContents.isAlive() diff --git a/atom/renderer/lib/guest-view-internal.coffee b/atom/renderer/lib/guest-view-internal.coffee index 24a57ea1faf..e5e64d0a806 100644 --- a/atom/renderer/lib/guest-view-internal.coffee +++ b/atom/renderer/lib/guest-view-internal.coffee @@ -10,7 +10,7 @@ WEB_VIEW_EVENTS = 'did-stop-loading': [] 'did-get-redirect-request': ['oldUrl', 'newUrl', 'isMainFrame'] 'console-message': ['level', 'message', 'line', 'sourceId'] - 'new-window': ['url', 'partitionId'] + 'new-window': ['url', 'frameName'] 'close': [] 'crashed': [] 'destroyed': [] diff --git a/atom/renderer/lib/override.coffee b/atom/renderer/lib/override.coffee index e876e10bace..9ea9f0c8870 100644 --- a/atom/renderer/lib/override.coffee +++ b/atom/renderer/lib/override.coffee @@ -2,13 +2,13 @@ process = global.process ipc = require 'ipc' remote = require 'remote' -if process.guestInstanceId? +unless process.guestInstanceId? # Override default window.close. window.close = -> remote.getCurrentWindow().close() # Make the browser window or guest view emit "new-window" event. -window.open = (url, name='', features='') -> +window.open = (url, frameName='', features='') -> options = {} for feature in features.split ',' [name, value] = feature.split '=' @@ -25,7 +25,7 @@ window.open = (url, name='', features='') -> options.width ?= 800 options.height ?= 600 - ipc.send 'ATOM_SHELL_WEB_CONTENTS_WINDOW_OPEN', url, name, features + ipc.send 'ATOM_SHELL_WEB_CONTENTS_WINDOW_OPEN', url, frameName, options # Use the dialog API to implement alert(). window.alert = (message, title='') -> diff --git a/docs/api/web-view-tag.md b/docs/api/web-view-tag.md index a7b908dee97..dc4859fee46 100644 --- a/docs/api/web-view-tag.md +++ b/docs/api/web-view-tag.md @@ -237,7 +237,7 @@ webview.addEventListener('console-message', function(e) { ### new-window * `url` String -* `partitionId` String +* `frameName` String Fired when the guest page attempts to open a new browser window.