Fix crash when closing docked devtools by clicking close button.

We need to send ack for the close message, so we should destroy web contents
after the beforeunload event has fired.
This commit is contained in:
Cheng Zhao 2014-07-13 10:08:28 +08:00
parent 9d4e977c01
commit 46e765f79b
2 changed files with 6 additions and 1 deletions

View file

@ -176,7 +176,7 @@ void InspectableWebContentsImpl::ActivateWindow() {
}
void InspectableWebContentsImpl::CloseWindow() {
CloseDevTools();
devtools_web_contents()->GetMainFrame()->DispatchBeforeUnload(false);
}
void InspectableWebContentsImpl::SetContentsResizingStrategy(
@ -305,4 +305,8 @@ void InspectableWebContentsImpl::HandleKeyboardEvent(
delegate->HandleKeyboardEvent(source, event);
}
void InspectableWebContentsImpl::CloseContents(content::WebContents* source) {
CloseDevTools();
}
} // namespace brightray

View file

@ -109,6 +109,7 @@ class InspectableWebContentsImpl :
virtual void HandleKeyboardEvent(
content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE;
virtual void CloseContents(content::WebContents* source) OVERRIDE;
scoped_ptr<content::WebContents> web_contents_;
scoped_ptr<content::DevToolsClientHost> frontend_host_;