fix: detach webview instead of destroying it

Chromium no longer cleans up everything when a guest webcontents is
destroyed, we have to force detaching it and let Chromium destroy everything.
This commit is contained in:
Cheng Zhao 2019-01-12 15:50:33 +09:00 committed by Jeremy Apthorp
parent 5e043812ef
commit 03d499bf34
7 changed files with 21 additions and 6 deletions

View file

@ -470,9 +470,9 @@ WebContents::~WebContents() {
RenderViewDeleted(web_contents()->GetRenderViewHost());
if (type_ == WEB_VIEW) {
DCHECK(!web_contents()->GetOuterWebContents())
<< "Should never manually destroy an attached webview";
// For webview simply destroy the WebContents immediately.
// TODO(zcbenz): Add an internal API for webview instead of using
// destroy(), so we don't have to add a special branch here.
DestroyWebContents(false /* async */);
} else if (type_ == BROWSER_WINDOW && owner_window()) {
// For BrowserWindow we should close the window and clean up everything
@ -2150,6 +2150,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("startDrag", &WebContents::StartDrag)
.SetMethod("isGuest", &WebContents::IsGuest)
.SetMethod("attachToIframe", &WebContents::AttachToIframe)
.SetMethod("detachFromOuterFrame", &WebContents::DetachFromOuterFrame)
.SetMethod("isOffscreen", &WebContents::IsOffScreen)
#if BUILDFLAG(ENABLE_OSR)
.SetMethod("startPainting", &WebContents::StartPainting)