Chromium Code Reviews| Index: content/shell/browser/shell_devtools_frontend.cc |
| diff --git a/content/shell/browser/shell_devtools_frontend.cc b/content/shell/browser/shell_devtools_frontend.cc |
| index 42ffa70e0354b191cbc11bb62c2a5d5ba100f8a6..67fbaf4cc615461f6119389baeaf7473c99739e7 100644 |
| --- a/content/shell/browser/shell_devtools_frontend.cc |
| +++ b/content/shell/browser/shell_devtools_frontend.cc |
| @@ -5,6 +5,7 @@ |
| #include "content/shell/browser/shell_devtools_frontend.h" |
| #include "base/command_line.h" |
| +#include "base/debug/stack_trace.h" |
|
jochen (gone - plz use gerrit)
2015/02/03 11:28:35
not needed?
pfeldman
2015/02/03 11:34:38
Done.
|
| #include "base/json/json_reader.h" |
| #include "base/json/json_writer.h" |
| #include "base/strings/string_number_conversions.h" |
| @@ -60,13 +61,28 @@ void ShellDevToolsFrontend::Focus() { |
| } |
| void ShellDevToolsFrontend::InspectElementAt(int x, int y) { |
| - agent_host_->InspectElement(x, y); |
| + if (agent_host_) |
| + agent_host_->InspectElement(x, y); |
| } |
| void ShellDevToolsFrontend::Close() { |
| frontend_shell_->Close(); |
| } |
| +void ShellDevToolsFrontend::SwitchToTarget(WebContents* inspected_contents) { |
| + DisconnectFromTarget(); |
| + frontend_shell_->Reload(); |
| + agent_host_ = DevToolsAgentHost::GetOrCreateFor(inspected_contents); |
| + agent_host_->AttachClient(this); |
| +} |
| + |
| +void ShellDevToolsFrontend::DisconnectFromTarget() { |
| + if (!agent_host_) |
| + return; |
| + agent_host_->DetachClient(); |
| + agent_host_ = nullptr; |
| +} |
| + |
| ShellDevToolsFrontend::ShellDevToolsFrontend(Shell* frontend_shell, |
| DevToolsAgentHost* agent_host) |
| : WebContentsObserver(frontend_shell->web_contents()), |
| @@ -82,17 +98,21 @@ void ShellDevToolsFrontend::RenderViewCreated( |
| if (!frontend_host_) { |
| frontend_host_.reset( |
| DevToolsFrontendHost::Create(web_contents()->GetMainFrame(), this)); |
| - agent_host_->AttachClient(this); |
| + if (agent_host_) |
| + agent_host_->AttachClient(this); |
| } |
| } |
| void ShellDevToolsFrontend::WebContentsDestroyed() { |
| - agent_host_->DetachClient(); |
| + if (agent_host_) |
| + agent_host_->DetachClient(); |
| delete this; |
| } |
| void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( |
| const std::string& message) { |
| + if (!agent_host_) |
| + return; |
| std::string method; |
| int id = 0; |
| base::ListValue* params = NULL; |
| @@ -127,7 +147,8 @@ void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontend( |
| void ShellDevToolsFrontend::HandleMessageFromDevToolsFrontendToBackend( |
| const std::string& message) { |
| - agent_host_->DispatchProtocolMessage(message); |
| + if (agent_host_) |
| + agent_host_->DispatchProtocolMessage(message); |
| } |
| void ShellDevToolsFrontend::DispatchProtocolMessage( |