|
@@ -483,16 +483,20 @@ WebContents::~WebContents() {
|
|
|
|
|
|
RenderViewDeleted(web_contents()->GetRenderViewHost());
|
|
|
|
|
|
- if (type_ == BROWSER_WINDOW && owner_window()) {
|
|
|
- for (ExtendedWebContentsObserver& observer : observers_)
|
|
|
- observer.OnCloseContents();
|
|
|
+ if (type_ == WEB_VIEW) {
|
|
|
+ DestroyWebContents(false /* async */);
|
|
|
} else {
|
|
|
- DestroyWebContents(!IsGuest() /* async */);
|
|
|
+ if (type_ == BROWSER_WINDOW && owner_window()) {
|
|
|
+ for (ExtendedWebContentsObserver& observer : observers_)
|
|
|
+ observer.OnCloseContents();
|
|
|
+ } 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();
|
|
|
}
|
|
|
- // 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();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1040,7 +1044,7 @@ bool WebContents::OnMessageReceived(const IPC::Message& message,
|
|
|
// 2. garbage collection;
|
|
|
// 3. user closes the window of webContents;
|
|
|
// 4. the embedder detaches the frame.
|
|
|
-// For webview only #4 will happen, for BrowserWindow both #1 and #3 may
|
|
|
+// For webview both #1 and #4 may happen, for BrowserWindow both #1 and #3 may
|
|
|
// happen. The #2 should never happen for webContents, because webview is
|
|
|
// managed by GuestViewManager, and BrowserWindow's webContents is managed
|
|
|
// by api::BrowserWindow.
|