Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Unified Diff: content/shell/browser/shell_devtools_frontend.cc

Issue 870883008: Test runner: make inspector tests reuse a single inspector process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | content/shell/browser/webkit_test_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « content/shell/browser/shell_devtools_frontend.h ('k') | content/shell/browser/webkit_test_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698