| 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..0eba61912ca0933afba13d86855db3839fb28658 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_->agent_host_->DetachClient();
|
| 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,23 +404,25 @@ 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::SendMessageFromAgentHost(
|
| + 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() {
|
| - delegate_->InspectedContentsClosing();
|
| -}
|
| -
|
| -void DevToolsUIBindings::ReplacedWithAnotherClient() {
|
| +void DevToolsUIBindings::AgentHostDetached(
|
| + content::DevToolsAgentHost* agent_host,
|
| + content::DevToolsAgentHost::DetachReason reason) {
|
| + DCHECK(agent_host == agent_host_.get());
|
| + if (reason != content::DevToolsAgentHost::DETACHED_BY_CLIENT)
|
| + delegate_->InspectedContentsClosing();
|
| }
|
|
|
| // DevToolsEmbedderMessageDispatcher::Delegate implementation -----------------
|
| @@ -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,15 @@ void DevToolsUIBindings::SetDelegate(Delegate* delegate) {
|
| delegate_.reset(delegate);
|
| }
|
|
|
| +void DevToolsUIBindings::InspectAgentHost(
|
| + content::DevToolsAgentHost* agent_host) {
|
| + if (agent_host_)
|
| + agent_host_->DetachClient();
|
| + agent_host_ = agent_host;
|
| + if (agent_host_)
|
| + agent_host_->AttachClient(this);
|
| +}
|
| +
|
| void DevToolsUIBindings::CallClientFunction(const std::string& function_name,
|
| const base::Value* arg1,
|
| const base::Value* arg2,
|
|
|