Merge pull request #266 from deepak1556/devtools_remote_detach_patch

force attach devtools client when requested by inspectable webcontents
This commit is contained in:
Kevin Sawicki 2017-01-11 17:26:12 -08:00 committed by GitHub
commit cda2e0c181
3 changed files with 8 additions and 6 deletions

View file

@ -38,7 +38,7 @@ class InspectableWebContents {
virtual void ShowDevTools() = 0; virtual void ShowDevTools() = 0;
virtual void CloseDevTools() = 0; virtual void CloseDevTools() = 0;
virtual bool IsDevToolsViewShowing() = 0; virtual bool IsDevToolsViewShowing() = 0;
virtual void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) = 0; virtual void AttachTo(scoped_refptr<content::DevToolsAgentHost>) = 0;
virtual void Detach() = 0; virtual void Detach() = 0;
virtual void CallClientFunction(const std::string& function_name, virtual void CallClientFunction(const std::string& function_name,
const base::Value* arg1 = nullptr, const base::Value* arg1 = nullptr,

View file

@ -279,8 +279,8 @@ void InspectableWebContentsImpl::ShowDevTools() {
Observe(devtools_web_contents_.get()); Observe(devtools_web_contents_.get());
devtools_web_contents_->SetDelegate(this); devtools_web_contents_->SetDelegate(this);
agent_host_ = content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get()); AttachTo(std::move(
agent_host_->AttachClient(this); content::DevToolsAgentHost::GetOrCreateFor(web_contents_.get())));
devtools_web_contents_->GetController().LoadURL( devtools_web_contents_->GetController().LoadURL(
GetDevToolsURL(can_dock_), GetDevToolsURL(can_dock_),
@ -304,11 +304,13 @@ bool InspectableWebContentsImpl::IsDevToolsViewShowing() {
return devtools_web_contents_ && view_->IsDevToolsViewShowing(); return devtools_web_contents_ && view_->IsDevToolsViewShowing();
} }
void InspectableWebContentsImpl::AttachTo(const scoped_refptr<content::DevToolsAgentHost>& host) { void InspectableWebContentsImpl::AttachTo(
scoped_refptr<content::DevToolsAgentHost> host) {
if (agent_host_.get()) if (agent_host_.get())
Detach(); Detach();
agent_host_ = host; agent_host_ = host;
agent_host_->AttachClient(this); // Terminate existing debugging connections and start debugging.
agent_host_->ForceAttachClient(this);
} }
void InspectableWebContentsImpl::Detach() { void InspectableWebContentsImpl::Detach() {

View file

@ -54,7 +54,7 @@ class InspectableWebContentsImpl :
void ShowDevTools() override; void ShowDevTools() override;
void CloseDevTools() override; void CloseDevTools() override;
bool IsDevToolsViewShowing() override; bool IsDevToolsViewShowing() override;
void AttachTo(const scoped_refptr<content::DevToolsAgentHost>&) override; void AttachTo(scoped_refptr<content::DevToolsAgentHost>) override;
void Detach() override; void Detach() override;
void CallClientFunction(const std::string& function_name, void CallClientFunction(const std::string& function_name,
const base::Value* arg1, const base::Value* arg1,