From cddce77ea4e3bb8d98646eff4fff589d285f080d Mon Sep 17 00:00:00 2001 From: deepak1556 Date: Tue, 10 Jan 2017 16:43:16 +0530 Subject: [PATCH] force attach devtools client when requested by inspectable webcontents --- brightray/browser/inspectable_web_contents.h | 2 +- brightray/browser/inspectable_web_contents_impl.cc | 10 ++++++---- brightray/browser/inspectable_web_contents_impl.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/brightray/browser/inspectable_web_contents.h b/brightray/browser/inspectable_web_contents.h index 01e9c6d274..86324115ac 100644 --- a/brightray/browser/inspectable_web_contents.h +++ b/brightray/browser/inspectable_web_contents.h @@ -38,7 +38,7 @@ class InspectableWebContents { virtual void ShowDevTools() = 0; virtual void CloseDevTools() = 0; virtual bool IsDevToolsViewShowing() = 0; - virtual void AttachTo(const scoped_refptr&) = 0; + virtual void AttachTo(scoped_refptr) = 0; virtual void Detach() = 0; virtual void CallClientFunction(const std::string& function_name, const base::Value* arg1 = nullptr, diff --git a/brightray/browser/inspectable_web_contents_impl.cc b/brightray/browser/inspectable_web_contents_impl.cc index 4affb2f786..3ad0895298 100644 --- a/brightray/browser/inspectable_web_contents_impl.cc +++ b/brightray/browser/inspectable_web_contents_impl.cc @@ -279,8 +279,8 @@ void InspectableWebContentsImpl::ShowDevTools() { Observe(devtools_web_contents_.get()); devtools_web_contents_->SetDelegate(this); - agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()); - agent_host_->AttachClient(this); + AttachTo(std::move( + content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()))); devtools_web_contents_->GetController().LoadURL( GetDevToolsURL(can_dock_), @@ -304,11 +304,13 @@ bool InspectableWebContentsImpl::IsDevToolsViewShowing() { return devtools_web_contents_ && view_->IsDevToolsViewShowing(); } -void InspectableWebContentsImpl::AttachTo(const scoped_refptr& host) { +void InspectableWebContentsImpl::AttachTo( + scoped_refptr host) { if (agent_host_.get()) Detach(); agent_host_ = host; - agent_host_->AttachClient(this); + // Terminate existing debugging connections and start debugging. + agent_host_->ForceAttachClient(this); } void InspectableWebContentsImpl::Detach() { diff --git a/brightray/browser/inspectable_web_contents_impl.h b/brightray/browser/inspectable_web_contents_impl.h index d25f1be5f9..818481efbf 100644 --- a/brightray/browser/inspectable_web_contents_impl.h +++ b/brightray/browser/inspectable_web_contents_impl.h @@ -54,7 +54,7 @@ class InspectableWebContentsImpl : void ShowDevTools() override; void CloseDevTools() override; bool IsDevToolsViewShowing() override; - void AttachTo(const scoped_refptr&) override; + void AttachTo(scoped_refptr) override; void Detach() override; void CallClientFunction(const std::string& function_name, const base::Value* arg1,