Index: chrome/browser/devtools/devtools_ui_bindings.cc |
diff --git a/chrome/browser/devtools/devtools_ui_bindings.cc b/chrome/browser/devtools/devtools_ui_bindings.cc |
index 227419758f6ea5246a5a3821d4c3fa4853d69eb9..a96d6195aaa978bd1c27b181b4fe14bf1c625a63 100644 |
--- a/chrome/browser/devtools/devtools_ui_bindings.cc |
+++ b/chrome/browser/devtools/devtools_ui_bindings.cc |
@@ -32,8 +32,6 @@ |
#include "chrome/common/url_constants.h" |
#include "components/infobars/core/confirm_infobar_delegate.h" |
#include "components/infobars/core/infobar.h" |
-#include "content/public/browser/devtools_client_host.h" |
-#include "content/public/browser/devtools_manager.h" |
#include "content/public/browser/favicon_status.h" |
#include "content/public/browser/invalidate_type.h" |
#include "content/public/browser/navigation_controller.h" |
@@ -263,8 +261,8 @@ void DevToolsUIBindings::FrontendWebContentsObserver::RenderProcessGone( |
case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
case base::TERMINATION_STATUS_PROCESS_CRASHED: |
- content::DevToolsManager::GetInstance()->ClientHostClosing( |
- devtools_bindings_); |
+ if (devtools_bindings_->agent_host_) |
+ devtools_bindings_->Detach(); |
break; |
default: |
break; |
@@ -353,7 +351,8 @@ DevToolsUIBindings::DevToolsUIBindings(content::WebContents* web_contents, |
} |
DevToolsUIBindings::~DevToolsUIBindings() { |
- content::DevToolsManager::GetInstance()->ClientHostClosing(this); |
+ if (agent_host_) |
+ agent_host_->DetachClient(); |
for (IndexingJobsMap::const_iterator jobs_it(indexing_jobs_.begin()); |
jobs_it != indexing_jobs_.end(); ++jobs_it) { |
@@ -405,25 +404,27 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( |
void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( |
const std::string& message) { |
- content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
- this, message); |
+ if (agent_host_) |
+ agent_host_->DispatchOnInspectorBackend(message); |
} |
-// content::DevToolsClientHost implementation --------------------------------- |
-void DevToolsUIBindings::DispatchOnInspectorFrontend( |
- const std::string& message) { |
+// content::DevToolsAgentHost::Client implementation -------------------------- |
+void DevToolsUIBindings::DispatchProtocolMessage( |
+ content::DevToolsAgentHost* agent_host, const std::string& message) { |
+ DCHECK(agent_host == agent_host_.get()); |
base::StringValue message_value(message); |
CallClientFunction("InspectorFrontendAPI.dispatchMessage", |
&message_value, NULL, NULL); |
} |
-void DevToolsUIBindings::InspectedContentsClosing() { |
+void DevToolsUIBindings::AgentHostClosed( |
+ content::DevToolsAgentHost* agent_host, |
+ bool replaced_with_another_client) { |
+ DCHECK(agent_host == agent_host_.get()); |
+ agent_host_ = NULL; |
delegate_->InspectedContentsClosing(); |
} |
-void DevToolsUIBindings::ReplacedWithAnotherClient() { |
-} |
- |
// DevToolsEmbedderMessageDispatcher::Delegate implementation ----------------- |
void DevToolsUIBindings::ActivateWindow() { |
delegate_->ActivateWindow(); |
@@ -632,8 +633,8 @@ void DevToolsUIBindings::SetDevicesUpdatesEnabled(bool enabled) { |
} |
void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { |
- content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
- this, message); |
+ if (agent_host_) |
+ agent_host_->DispatchOnInspectorBackend(message); |
} |
void DevToolsUIBindings::DeviceCountChanged(int count) { |
@@ -787,6 +788,28 @@ void DevToolsUIBindings::SetDelegate(Delegate* delegate) { |
delegate_.reset(delegate); |
} |
+void DevToolsUIBindings::AttachTo(content::DevToolsAgentHost* agent_host) { |
+ DCHECK(!agent_host_); |
+ agent_host_ = agent_host; |
+ agent_host_->AttachClient(this); |
+} |
+ |
+void DevToolsUIBindings::Reattach() { |
+ DCHECK(agent_host_); |
+ agent_host_->DetachClient(); |
+ agent_host_->AttachClient(this); |
+} |
+ |
+void DevToolsUIBindings::Detach() { |
+ DCHECK(agent_host_); |
+ agent_host_->DetachClient(); |
+ agent_host_ = NULL; |
+} |
+ |
+bool DevToolsUIBindings::IsAttachedTo(content::DevToolsAgentHost* agent_host) { |
+ return agent_host_ == agent_host; |
+} |
+ |
void DevToolsUIBindings::CallClientFunction(const std::string& function_name, |
const base::Value* arg1, |
const base::Value* arg2, |