Index: chrome/browser/extensions/api/debugger/debugger_api.cc |
diff --git a/chrome/browser/extensions/api/debugger/debugger_api.cc b/chrome/browser/extensions/api/debugger/debugger_api.cc |
index aaf3b9411d8511874e5a8af409dd918707a6926f..1bacc59cd46101c407165732caa9e1feec6343de 100644 |
--- a/chrome/browser/extensions/api/debugger/debugger_api.cc |
+++ b/chrome/browser/extensions/api/debugger/debugger_api.cc |
@@ -31,9 +31,7 @@ |
#include "components/infobars/core/confirm_infobar_delegate.h" |
#include "components/infobars/core/infobar.h" |
#include "content/public/browser/devtools_agent_host.h" |
-#include "content/public/browser/devtools_client_host.h" |
#include "content/public/browser/devtools_http_handler.h" |
-#include "content/public/browser/devtools_manager.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_source.h" |
#include "content/public/browser/render_process_host.h" |
@@ -57,9 +55,7 @@ |
#include "ui/base/l10n/l10n_util.h" |
using content::DevToolsAgentHost; |
-using content::DevToolsClientHost; |
using content::DevToolsHttpHandler; |
-using content::DevToolsManager; |
using content::RenderProcessHost; |
using content::RenderViewHost; |
using content::RenderWidgetHost; |
@@ -77,7 +73,7 @@ class ExtensionRegistry; |
// ExtensionDevToolsClientHost ------------------------------------------------ |
-class ExtensionDevToolsClientHost : public DevToolsClientHost, |
+class ExtensionDevToolsClientHost : public content::DevToolsAgentHostClient, |
public content::NotificationObserver, |
public ExtensionRegistryObserver { |
public: |
@@ -91,6 +87,7 @@ class ExtensionDevToolsClientHost : public DevToolsClientHost, |
virtual ~ExtensionDevToolsClientHost(); |
const std::string& extension_id() { return extension_id_; } |
+ DevToolsAgentHost* agent_host() { return agent_host_.get(); } |
void Close(); |
void SendMessageToBackend(DebuggerSendCommandFunction* function, |
const std::string& method, |
@@ -99,10 +96,13 @@ class ExtensionDevToolsClientHost : public DevToolsClientHost, |
// Marks connection as to-be-terminated by the user. |
void MarkAsDismissed(); |
- // DevToolsClientHost interface |
- virtual void InspectedContentsClosing() OVERRIDE; |
- virtual void DispatchOnInspectorFrontend(const std::string& message) OVERRIDE; |
- virtual void ReplacedWithAnotherClient() OVERRIDE; |
+ // DevToolsAgentHostClient interface. |
+ virtual void AgentHostClosed( |
+ DevToolsAgentHost* agent_host, |
+ bool replaced_with_another_client) OVERRIDE; |
+ virtual void DispatchProtocolMessage( |
+ DevToolsAgentHost* agent_host, |
+ const std::string& message) OVERRIDE; |
private: |
void SendDetachedEvent(); |
@@ -289,11 +289,10 @@ void AttachedClientHosts::Remove(ExtensionDevToolsClientHost* client_host) { |
ExtensionDevToolsClientHost* AttachedClientHosts::Lookup( |
DevToolsAgentHost* agent_host, |
const std::string& extension_id) { |
- DevToolsManager* manager = DevToolsManager::GetInstance(); |
for (ClientHosts::iterator it = client_hosts_.begin(); |
it != client_hosts_.end(); ++it) { |
ExtensionDevToolsClientHost* client_host = *it; |
- if (manager->GetDevToolsAgentHostFor(client_host) == agent_host && |
+ if (client_host->agent_host() == agent_host && |
client_host->extension_id() == extension_id) |
return client_host; |
} |
@@ -334,8 +333,7 @@ ExtensionDevToolsClientHost::ExtensionDevToolsClientHost( |
content::NotificationService::AllSources()); |
// Attach to debugger and tell it we are ready. |
- DevToolsManager::GetInstance()->RegisterDevToolsClientHostFor( |
- agent_host_.get(), this); |
+ agent_host_->AttachClient(this); |
if (infobar_) { |
static_cast<ExtensionDevToolsInfoBarDelegate*>( |
@@ -363,18 +361,18 @@ ExtensionDevToolsClientHost::~ExtensionDevToolsClientHost() { |
AttachedClientHosts::GetInstance()->Remove(this); |
} |
-// DevToolsClientHost interface |
-void ExtensionDevToolsClientHost::InspectedContentsClosing() { |
+// DevToolsAgentHostClient implementation. |
+void ExtensionDevToolsClientHost::AgentHostClosed( |
+ DevToolsAgentHost* agent_host, bool replaced_with_another_client) { |
+ DCHECK(agent_host == agent_host_.get()); |
+ if (replaced_with_another_client) |
+ detach_reason_ = OnDetach::REASON_REPLACED_WITH_DEVTOOLS; |
SendDetachedEvent(); |
delete this; |
} |
-void ExtensionDevToolsClientHost::ReplacedWithAnotherClient() { |
- detach_reason_ = OnDetach::REASON_REPLACED_WITH_DEVTOOLS; |
-} |
- |
void ExtensionDevToolsClientHost::Close() { |
- DevToolsManager::GetInstance()->ClientHostClosing(this); |
+ agent_host_->DetachClient(); |
delete this; |
} |
@@ -394,7 +392,7 @@ void ExtensionDevToolsClientHost::SendMessageToBackend( |
std::string json_args; |
base::JSONWriter::Write(&protocol_request, &json_args); |
- DevToolsManager::GetInstance()->DispatchOnInspectorBackend(this, json_args); |
+ agent_host_->DispatchProtocolMessage(json_args); |
} |
void ExtensionDevToolsClientHost::MarkAsDismissed() { |
@@ -442,8 +440,9 @@ void ExtensionDevToolsClientHost::Observe( |
} |
} |
-void ExtensionDevToolsClientHost::DispatchOnInspectorFrontend( |
- const std::string& message) { |
+void ExtensionDevToolsClientHost::DispatchProtocolMessage( |
+ DevToolsAgentHost* agent_host, const std::string& message) { |
+ DCHECK(agent_host == agent_host_.get()); |
if (!EventRouter::Get(profile_)) |
return; |