From: Cheng Zhao Date: Wed, 17 Dec 2014 22:56:51 +0000 (-0800) Subject: Redirect BrowserWindow's "will-navigate" event to WebContents X-Git-Tag: v0.20.1~1^2~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=c2975d2bccab6a8538ad1e148b64aee75c4dc46b;p=electron.git Redirect BrowserWindow's "will-navigate" event to WebContents --- diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index 4f663bc6..126344ae 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 3d896594..49608ca5 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', =>