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 f40ed896739e7c0811021acde22625bf647b9804..b8f6087cab63633326d5fa8347750ad0b58c6451 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" |
@@ -261,8 +259,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; |
@@ -351,7 +349,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) { |
@@ -403,25 +402,27 @@ void DevToolsUIBindings::HandleMessageFromDevToolsFrontend( |
void DevToolsUIBindings::HandleMessageFromDevToolsFrontendToBackend( |
const std::string& message) { |
- content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
- this, message); |
+ if (agent_host_) |
+ agent_host_->DispatchProtocolMessage(message); |
} |
-// content::DevToolsClientHost implementation --------------------------------- |
-void DevToolsUIBindings::DispatchOnInspectorFrontend( |
- const std::string& message) { |
+// content::DevToolsAgentHostClient 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(); |
@@ -625,8 +626,8 @@ void DevToolsUIBindings::SetDevicesUpdatesEnabled(bool enabled) { |
} |
void DevToolsUIBindings::SendMessageToBrowser(const std::string& message) { |
- content::DevToolsManager::GetInstance()->DispatchOnInspectorBackend( |
- this, message); |
+ if (agent_host_) |
+ agent_host_->DispatchProtocolMessage(message); |
} |
void DevToolsUIBindings::DeviceCountChanged(int count) { |
@@ -780,6 +781,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, |