From 46e765f79b208d2d5fbf561ba8abbb28d8de9802 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sun, 13 Jul 2014 10:08:28 +0800 Subject: [PATCH] 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. --- brightray/browser/inspectable_web_contents_impl.cc | 6 +++++- brightray/browser/inspectable_web_contents_impl.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index e7a1518110..69eda18494 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -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 diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index 1fcfff5537..dd115cdd1e 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -109,6 +109,7 @@ class InspectableWebContentsImpl : virtual void HandleKeyboardEvent( content::WebContents*, const content::NativeWebKeyboardEvent&) OVERRIDE; + virtual void CloseContents(content::WebContents* source) OVERRIDE; scoped_ptr web_contents_; scoped_ptr frontend_host_;