invoke WebContentsDestroyed manually when destruction path is async

This commit is contained in:
deepak1556 2017-04-05 11:52:11 +05:30 committed by Cheng Zhao
parent f974a6bda9
commit 9e3b8ade12

View file

@ -418,12 +418,18 @@ WebContents::~WebContents() {
RenderViewDeleted(web_contents()->GetRenderViewHost());
if (type_ == BROWSER_WINDOW && owner_window()) {
owner_window()->CloseContents(nullptr);
} else if (type_ == WEB_VIEW) {
if (type_ == WEB_VIEW) {
DestroyWebContents(false /* async */);
} else {
DestroyWebContents(true /* async */);
if (type_ == BROWSER_WINDOW && owner_window()) {
owner_window()->CloseContents(nullptr);
} else {
DestroyWebContents(true /* async */);
}
// The WebContentsDestroyed will not be called automatically because we
// destroy the webContents in the next tick. So we have to manually
// call it here to make sure "destroyed" event is emitted.
WebContentsDestroyed();
}
}
}