]> khamidou — GitHub mirrors - electron.git/commitdiff
Redirect BrowserWindow's "will-navigate" event to WebContents
authorCheng Zhao <zcbenz@gmail.com>
Wed, 17 Dec 2014 22:56:51 +0000 (14:56 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 17 Dec 2014 22:56:51 +0000 (14:56 -0800)
atom/browser/api/atom_api_window.cc
atom/browser/api/lib/browser-window.coffee

index 4f663bc63d6b9d72ea58840b11cca29a4e46786f..126344aec7186db6d677493a2546dcf9addb3f0b 100644 (file)
@@ -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) {
index 3d89659444c6f8939f9cb1730a395787d6196450..49608ca54d802617f9f19e7352a97f57a3e7d424 100644 (file)
@@ -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', =>