#ifndef CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_IMPL_H_
#define CONTENT_BROWSER_DEBUGGER_DEVTOOLS_MANAGER_IMPL_H_
#include <map>
#include <string>
#include "base/compiler_specific.h"
#include "base/memory/singleton.h"
#include "content/browser/debugger/devtools_agent_host.h"
#include "content/common/content_export.h"
#include "content/public/browser/devtools_client_host.h"
#include "content/public/browser/devtools_manager.h"
class GURL;
namespace IPC {
class Message;
}
namespace content {
class DevToolsAgentHost;
class RenderViewHost;
class CONTENT_EXPORT DevToolsManagerImpl
: public DevToolsAgentHost::CloseListener,
public DevToolsManager {
public:
static DevToolsManagerImpl* GetInstance();
DevToolsManagerImpl();
virtual ~DevToolsManagerImpl();
void DispatchOnInspectorFrontend(DevToolsAgentHost* agent_host,
const std::string& message);
void SaveAgentRuntimeState(DevToolsAgentHost* agent_host,
const std::string& state);
void OnNavigatingToPendingEntry(RenderViewHost* inspected_rvh,
RenderViewHost* dest_rvh,
const GURL& gurl);
void OnCancelPendingNavigation(RenderViewHost* pending,
RenderViewHost* current);
virtual bool DispatchOnInspectorBackend(DevToolsClientHost* from,
const std::string& message) OVERRIDE;
virtual void ContentsReplaced(WebContents* old_contents,
WebContents* new_contents) OVERRIDE;
virtual void CloseAllClientHosts() OVERRIDE;
virtual void AttachClientHost(int client_host_cookie,
DevToolsAgentHost* to_agent) OVERRIDE;
virtual DevToolsClientHost* GetDevToolsClientHostFor(
DevToolsAgentHost* agent_host) OVERRIDE;
virtual DevToolsAgentHost* GetDevToolsAgentHostFor(
DevToolsClientHost* client_host) OVERRIDE;
virtual void RegisterDevToolsClientHostFor(
DevToolsAgentHost* agent_host,
DevToolsClientHost* client_host) OVERRIDE;
virtual void UnregisterDevToolsClientHostFor(
DevToolsAgentHost* agent_host) OVERRIDE;
virtual int DetachClientHost(DevToolsAgentHost* from_agent) OVERRIDE;
virtual void ClientHostClosing(DevToolsClientHost* host) OVERRIDE;
virtual void InspectElement(DevToolsAgentHost* agent_host,
int x, int y) OVERRIDE;
virtual void AddMessageToConsole(DevToolsAgentHost* agent_host,
ConsoleMessageLevel level,
const std::string& message) OVERRIDE;
private:
friend struct DefaultSingletonTraits<DevToolsManagerImpl>;
virtual void AgentHostClosing(DevToolsAgentHost* host) OVERRIDE;
void BindClientHost(DevToolsAgentHost* agent_host,
DevToolsClientHost* client_host);
void UnbindClientHost(DevToolsAgentHost* agent_host,
DevToolsClientHost* client_host);
int DetachClientHost(RenderViewHost* from_rvh);
void AttachClientHost(int client_host_cookie,
RenderViewHost* to_rvh);
typedef std::map<DevToolsAgentHost*, DevToolsClientHost*>
AgentToClientHostMap;
AgentToClientHostMap agent_to_client_host_;
typedef std::map<DevToolsClientHost*, DevToolsAgentHost*>
ClientToAgentHostMap;
ClientToAgentHostMap client_to_agent_host_;
typedef std::map<DevToolsAgentHost*, std::string> AgentRuntimeStates;
AgentRuntimeStates agent_runtime_states_;
typedef std::map<int, std::pair<DevToolsClientHost*, std::string> >
OrphanClientHosts;
OrphanClientHosts orphan_client_hosts_;
int last_orphan_cookie_;
DISALLOW_COPY_AND_ASSIGN(DevToolsManagerImpl);
};
}
#endif