From 001d0197de17c07fbde127100b2a78e81871262d Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Wed, 27 Mar 2013 10:59:40 -0400 Subject: [PATCH] Make the devtools close button work --- brightray/browser/inspectable_web_contents_impl.cc | 5 ++++- brightray/browser/inspectable_web_contents_view.h | 1 + brightray/browser/inspectable_web_contents_view_mac.h | 1 + brightray/browser/inspectable_web_contents_view_mac.mm | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index f26579158408..594a0c1fdd0c 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -13,6 +13,7 @@ #include "content/public/browser/devtools_client_host.h" #include "content/public/browser/devtools_http_handler.h" #include "content/public/browser/devtools_manager.h" +#include "content/public/browser/web_contents_view.h" namespace brightray { @@ -60,6 +61,9 @@ void InspectableWebContentsImpl::ChangeAttachedWindowHeight(unsigned height) { } void InspectableWebContentsImpl::CloseWindow() { + view_->CloseDevTools(); + devtools_web_contents_.reset(); + web_contents_->GetView()->Focus(); } void InspectableWebContentsImpl::MoveWindow(int x, int y) { @@ -99,7 +103,6 @@ void InspectableWebContentsImpl::WebContentsDestroyed(content::WebContents*) { Observe(nullptr); agent_host_ = nullptr; frontend_host_.reset(); - devtools_web_contents_.reset(); } void InspectableWebContentsImpl::HandleKeyboardEvent(content::WebContents* source, const content::NativeWebKeyboardEvent& event) { diff --git a/brightray/browser/inspectable_web_contents_view.h b/brightray/browser/inspectable_web_contents_view.h index c64dd36d7396..0d68b4cabee3 100644 --- a/brightray/browser/inspectable_web_contents_view.h +++ b/brightray/browser/inspectable_web_contents_view.h @@ -12,6 +12,7 @@ public: virtual gfx::NativeView GetNativeView() const = 0; virtual void ShowDevTools() = 0; + virtual void CloseDevTools() = 0; }; } diff --git a/brightray/browser/inspectable_web_contents_view_mac.h b/brightray/browser/inspectable_web_contents_view_mac.h index ebe4699e1bed..6a35ac46c3b2 100644 --- a/brightray/browser/inspectable_web_contents_view_mac.h +++ b/brightray/browser/inspectable_web_contents_view_mac.h @@ -17,6 +17,7 @@ public: virtual gfx::NativeView GetNativeView() const OVERRIDE; virtual void ShowDevTools() OVERRIDE; + virtual void CloseDevTools() OVERRIDE; InspectableWebContentsImpl* inspectable_web_contents() { return inspectable_web_contents_; } diff --git a/brightray/browser/inspectable_web_contents_view_mac.mm b/brightray/browser/inspectable_web_contents_view_mac.mm index bb75bc9cb7b5..49e4ad70c7f8 100644 --- a/brightray/browser/inspectable_web_contents_view_mac.mm +++ b/brightray/browser/inspectable_web_contents_view_mac.mm @@ -25,4 +25,8 @@ void InspectableWebContentsViewMac::ShowDevTools() { [view_ setDevToolsVisible:YES]; } +void InspectableWebContentsViewMac::CloseDevTools() { + [view_ setDevToolsVisible:NO]; +} + }