summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/devtools_agent.h
blob: 7d3c4a1791d3776f31b69edccc5156d1aa9d5b2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_RENDERER_DEVTOOLS_AGENT_H_
#define CHROME_RENDERER_DEVTOOLS_AGENT_H_

#include <string>

#include "webkit/glue/webdevtoolsagent_delegate.h"

namespace IPC {
class Message;
}

class RenderView;
class WebDevToolsAgent;

// DevToolsAgent belongs to the inspectable RenderView and provides Glue's
// agents with the communication capabilities. All messages from/to Glue's
// agents infrastructure are flowing through this comminucation agent.
// There is a corresponding DevToolsClient object on the client side.
class DevToolsAgent : public WebDevToolsAgentDelegate {
 public:
  DevToolsAgent(int routing_id, RenderView* view);
  virtual ~DevToolsAgent();

  // IPC message interceptor. Called on the Render thread.
  virtual bool OnMessageReceived(const IPC::Message& message);

  // WebDevToolsAgentDelegate implementation
  virtual void SendMessageToClient(const std::string& raw_msg);

 private:
  WebDevToolsAgent* GetWebAgent();

  void OnAttach();
  void OnDetach();
  void OnRpcMessage(const std::string& raw_msg);
  void OnInspectElement(int x, int y);

  int routing_id_; //  View routing id that we can access from IO thread.
  RenderView* view_;

  DISALLOW_COPY_AND_ASSIGN(DevToolsAgent);
};

#endif  // CHROME_RENDERER_DEVTOOLS_AGENT_H_