From: Cheng Zhao Date: Wed, 17 Dec 2014 22:55:22 +0000 (-0800) Subject: Add "will-navigate" event for WebContents X-Git-Tag: v0.20.1~1^2~3 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=60df32aab5106fa375347627517ce066daf4e301;p=electron.git Add "will-navigate" event for WebContents --- diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 7bd1095b..10f91c47 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;