Move closing logic to api::BrowserWindow
Closing a BrowserWindow is essentially closing a WebContents, the logic should not be in NativeWindow.
This commit is contained in:
parent
66fab65a1a
commit
aa3eafcea1
8 changed files with 103 additions and 143 deletions
|
@ -446,6 +446,8 @@ void WebContents::InitWithSessionAndOptions(v8::Isolate* isolate,
|
|||
WebContents::~WebContents() {
|
||||
// The destroy() is called.
|
||||
if (managed_web_contents()) {
|
||||
managed_web_contents()->GetView()->SetDelegate(nullptr);
|
||||
|
||||
// For webview we need to tell content module to do some cleanup work before
|
||||
// destroying it.
|
||||
if (type_ == WEB_VIEW)
|
||||
|
@ -457,7 +459,8 @@ WebContents::~WebContents() {
|
|||
DestroyWebContents(false /* async */);
|
||||
} else {
|
||||
if (type_ == BROWSER_WINDOW && owner_window()) {
|
||||
owner_window()->CloseContents(nullptr);
|
||||
for (ExtendedWebContentsObserver& observer : observers_)
|
||||
observer.OnCloseContents();
|
||||
} else {
|
||||
DestroyWebContents(true /* async */);
|
||||
}
|
||||
|
@ -565,9 +568,10 @@ void WebContents::MoveContents(content::WebContents* source,
|
|||
|
||||
void WebContents::CloseContents(content::WebContents* source) {
|
||||
Emit("close");
|
||||
|
||||
if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
|
||||
owner_window()->CloseContents(source);
|
||||
if (managed_web_contents())
|
||||
managed_web_contents()->GetView()->SetDelegate(nullptr);
|
||||
for (ExtendedWebContentsObserver& observer : observers_)
|
||||
observer.OnCloseContents();
|
||||
}
|
||||
|
||||
void WebContents::ActivateContents(content::WebContents* source) {
|
||||
|
@ -640,8 +644,6 @@ void WebContents::RendererUnresponsive(
|
|||
|
||||
void WebContents::RendererResponsive(content::WebContents* source) {
|
||||
Emit("responsive");
|
||||
if ((type_ == BROWSER_WINDOW || type_ == OFF_SCREEN) && owner_window())
|
||||
owner_window()->RendererResponsive(source);
|
||||
for (ExtendedWebContentsObserver& observer : observers_)
|
||||
observer.OnRendererResponsive();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue