1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
6#define CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
7
8#include <string>
9
10#include "base/compiler_specific.h"
11#include "content/common/content_export.h"
12#include "content/public/browser/devtools_agent_host.h"
13
14namespace IPC {
15class Message;
16}
17
18namespace content {
19
20// Describes interface for managing devtools agents from the browser process.
21class CONTENT_EXPORT DevToolsAgentHostImpl : public DevToolsAgentHost {
22 public:
23  class CONTENT_EXPORT CloseListener {
24   public:
25    virtual void AgentHostClosing(DevToolsAgentHostImpl*) = 0;
26   protected:
27    virtual ~CloseListener() {}
28  };
29
30  // Informs the hosted agent that a client host has attached.
31  virtual void Attach() = 0;
32
33  // Informs the hosted agent that a client host has detached.
34  virtual void Detach() = 0;
35
36  // Sends a message to the agent hosted by this object.
37  virtual void DispatchOnInspectorBackend(const std::string& message) = 0;
38
39  void set_close_listener(CloseListener* listener) {
40    close_listener_ = listener;
41  }
42
43  // DevToolsAgentHost implementation.
44  virtual bool IsAttached() OVERRIDE;
45
46  virtual void InspectElement(int x, int y) OVERRIDE;
47
48  virtual std::string GetId() OVERRIDE;
49
50  virtual RenderViewHost* GetRenderViewHost() OVERRIDE;
51
52  virtual void DisconnectRenderViewHost() OVERRIDE;
53
54  virtual void ConnectRenderViewHost(RenderViewHost* rvh) OVERRIDE;
55
56 protected:
57  DevToolsAgentHostImpl();
58  virtual ~DevToolsAgentHostImpl();
59
60  void NotifyCloseListener();
61
62 private:
63  CloseListener* close_listener_;
64  const std::string id_;
65};
66
67}  // namespace content
68
69#endif  // CONTENT_BROWSER_DEVTOOLS_DEVTOOLS_AGENT_HOST_IMPL_H_
70