From c2975d2bccab6a8538ad1e148b64aee75c4dc46b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 17 Dec 2014 14:56:51 -0800 Subject: [PATCH] Redirect BrowserWindow's "will-navigate" event to WebContents --- atom/browser/api/atom_api_window.cc | 2 +- atom/browser/api/lib/browser-window.coffee | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 4f663bc63d6b..126344aec718 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -95,7 +95,7 @@ void Window::WillCreatePopupWindow(const base::string16& frame_name, void Window::WillNavigate(bool* prevent_default, const GURL& url) { base::ListValue args; args.AppendString(url.spec()); - *prevent_default = Emit("will-navigate", args); + *prevent_default = Emit("-will-navigate", args); } void Window::WillCloseWindow(bool* prevent_default) { diff --git a/atom/browser/api/lib/browser-window.coffee b/atom/browser/api/lib/browser-window.coffee index 3d89659444c6..49608ca54d80 100644 --- a/atom/browser/api/lib/browser-window.coffee +++ b/atom/browser/api/lib/browser-window.coffee @@ -30,6 +30,10 @@ BrowserWindow::_init = -> options = show: true, width: 800, height: 600 ipc.emit 'ATOM_SHELL_GUEST_WINDOW_MANAGER_WINDOW_OPEN', event, url, frameName, options + # Redirect "will-navigate" to webContents. + @on '-will-navigate', (event, url) => + @webContents.emit 'will-navigate', event, url + # Remove the window from weak map immediately when it's destroyed, since we # could be iterating windows before GC happened. @once 'closed', =>