From 72adbf7a2fef7aaef83fb56db9d3e9ddacc99b3a Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Sun, 19 Mar 2017 01:10:30 +0530 Subject: [PATCH] destroy guest webcontents before embedder --- atom/browser/api/atom_api_web_contents.cc | 16 ++++++++-------- atom/browser/api/atom_api_web_contents.h | 3 +++ vendor/brightray | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 6ba23b3c9a..0f188d0d22 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -411,14 +411,18 @@ WebContents::~WebContents() { if (type_ == WEB_VIEW) guest_delegate_->Destroy(); - // The WebContentsDestroyed will not be called automatically because we - // unsubscribe from webContents before destroying it. So we have to manually - // call it here to make sure "destroyed" event is emitted. RenderViewDeleted(web_contents()->GetRenderViewHost()); - WebContentsDestroyed(); + DestroyWebContents(); } } +void WebContents::DestroyWebContents() { + // This event is only for internal use, which is emitted when WebContents is + // being destroyed. + Emit("will-destroy"); + CommonWebContentsDelegate::DestroyWebContents(); +} + bool WebContents::DidAddMessageToConsole(content::WebContents* source, int32_t level, const base::string16& message, @@ -919,10 +923,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) { // be destroyed on close, and WebContentsDestroyed would be called for it, so // we need to make sure the api::WebContents is also deleted. void WebContents::WebContentsDestroyed() { - // This event is only for internal use, which is emitted when WebContents is - // being destroyed. - Emit("will-destroy"); - // Cleanup relationships with other parts. RemoveFromWeakMap(); diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index 2513dc7722..c289503b43 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -76,6 +76,9 @@ class WebContents : public mate::TrackableObject, static void BuildPrototype(v8::Isolate* isolate, v8::Local prototype); + // Notifies to destroy any guest web contents before destroying self. + void DestroyWebContents(); + int64_t GetID() const; int GetProcessID() const; Type GetType() const; diff --git a/vendor/brightray b/vendor/brightray index d0144ba2c9..53aa2cfc8a 160000 --- a/vendor/brightray +++ b/vendor/brightray @@ -1 +1 @@ -Subproject commit d0144ba2c9024d65cdf260abf5c03c742afff3fd +Subproject commit 53aa2cfc8a40627d62bf5be757ff9dea444f80bd