diff --git a/brightray/browser/inspectable_web_contents.h b/brightray/browser/inspectable_web_contents.h index 01e9c6d2741..86324115acd 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 4affb2f786d..3ad08952987 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 d25f1be5f99..818481efbf6 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,