From 60df32aab5106fa375347627517ce066daf4e301 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Wed, 17 Dec 2014 14:55:22 -0800 Subject: [PATCH] Add "will-navigate" event for WebContents --- atom/browser/api/atom_api_web_contents.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 7bd1095b8a9f..10f91c47bcb4 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -111,9 +111,15 @@ content::WebContents* WebContents::OpenURLFromTab( args.AppendString(""); args.AppendInteger(params.disposition); Emit("-new-window", args); - return NULL; + return nullptr; } + // Give user a chance to cancel navigation. + base::ListValue args; + args.AppendString(params.url.spec()); + if (Emit("will-navigate", args)) + return nullptr; + content::NavigationController::LoadURLParams load_url_params(params.url); load_url_params.referrer = params.referrer; load_url_params.transition_type = params.transition;