From aba449e1a6fd9c5e953756ce950589d39eca15c7 Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Mon, 18 May 2015 19:26:03 +0530 Subject: [PATCH] method to reset agent_host --- browser/inspectable_web_contents.h | 5 +++++ browser/inspectable_web_contents_impl.cc | 12 ++++++++++++ browser/inspectable_web_contents_impl.h | 3 +++ 3 files changed, 20 insertions(+) diff --git a/browser/inspectable_web_contents.h b/browser/inspectable_web_contents.h index b0a05d4..7ac1366 100644 --- a/browser/inspectable_web_contents.h +++ b/browser/inspectable_web_contents.h @@ -3,6 +3,10 @@ #include "content/public/browser/web_contents.h" +namespace content { +class DevToolsAgentHost; +} + namespace brightray { class InspectableWebContentsDelegate; @@ -27,6 +31,7 @@ class InspectableWebContents { // Close the DevTools completely instead of just hide it. virtual void CloseDevTools() = 0; virtual bool IsDevToolsViewShowing() = 0; + virtual void AttachTo(const scoped_refptr&) = 0; // The delegate manages its own life. virtual void SetDelegate(InspectableWebContentsDelegate* delegate) = 0; diff --git a/browser/inspectable_web_contents_impl.cc b/browser/inspectable_web_contents_impl.cc index dcd75cd..bdc9f69 100644 --- a/browser/inspectable_web_contents_impl.cc +++ b/browser/inspectable_web_contents_impl.cc @@ -188,6 +188,18 @@ bool InspectableWebContentsImpl::IsDevToolsViewShowing() { return devtools_web_contents_ && view_->IsDevToolsViewShowing(); } +void InspectableWebContentsImpl::AttachTo(const scoped_refptr& host) { + if (agent_host_.get()) + Detach(); + agent_host_ = host; + agent_host_->AttachClient(this); +} + +void InspectableWebContentsImpl::Detach() { + agent_host_->DetachClient(); + agent_host_ = nullptr; +} + gfx::Rect InspectableWebContentsImpl::GetDevToolsBounds() const { return devtools_bounds_; } diff --git a/browser/inspectable_web_contents_impl.h b/browser/inspectable_web_contents_impl.h index 6e6346e..7ef7810 100644 --- a/browser/inspectable_web_contents_impl.h +++ b/browser/inspectable_web_contents_impl.h @@ -48,6 +48,9 @@ class InspectableWebContentsImpl : void ShowDevTools() override; void CloseDevTools() override; bool IsDevToolsViewShowing() override; + void AttachTo(const scoped_refptr&) override; + + void Detach(); // Return the last position and size of devtools window. gfx::Rect GetDevToolsBounds() const;