Browse Source

Destroy web contents when preventing default

Kevin Sawicki 8 years ago
parent
commit
8f63fdb278
1 changed files with 4 additions and 2 deletions
  1. 4 2
      atom/browser/api/atom_api_web_contents.cc

+ 4 - 2
atom/browser/api/atom_api_web_contents.cc

@@ -419,9 +419,11 @@ void WebContents::AddNewContents(content::WebContents* source,
   v8::Locker locker(isolate());
   v8::HandleScope handle_scope(isolate());
   auto api_web_contents = CreateFrom(isolate(), new_contents);
-  Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
+  if (Emit("-add-new-contents", api_web_contents, disposition, user_gesture,
       initial_rect.x(), initial_rect.y(), initial_rect.width(),
-      initial_rect.height());
+      initial_rect.height())) {
+    api_web_contents->DestroyWebContents();
+  }
 }
 
 content::WebContents* WebContents::OpenURLFromTab(