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.
5 #ifndef CONTENT_RENDERER_DEVTOOLS_AGENT_H_
6 #define CONTENT_RENDERER_DEVTOOLS_AGENT_H_
10 #include "base/basictypes.h"
11 #include "content/public/common/console_message_level.h"
12 #include "content/public/renderer/render_view_observer.h"
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDevToolsAgentClient.h"
18 class WebDevToolsAgent
;
21 // DevToolsAgent belongs to the inspectable RenderView and provides Glue's
22 // agents with the communication capabilities. All messages from/to Glue's
23 // agents infrastructure are flowing through this communication agent.
24 // There is a corresponding DevToolsClient object on the client side.
25 class DevToolsAgent
: public content::RenderViewObserver
,
26 public WebKit::WebDevToolsAgentClient
{
28 explicit DevToolsAgent(RenderViewImpl
* render_view
);
29 virtual ~DevToolsAgent();
31 // Returns agent instance for its host id.
32 static DevToolsAgent
* FromHostId(int host_id
);
34 WebKit::WebDevToolsAgent
* GetWebAgent();
39 friend class DevToolsAgentFilter
;
41 // RenderView::Observer implementation.
42 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
44 // WebDevToolsAgentClient implementation
45 virtual void sendMessageToInspectorFrontend(const WebKit::WebString
& data
);
47 virtual int hostIdentifier();
48 virtual void saveAgentRuntimeState(const WebKit::WebString
& state
);
49 virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop
*
50 createClientMessageLoop();
51 virtual void clearBrowserCache();
52 virtual void clearBrowserCookies();
55 void OnReattach(const std::string
& agent_state
);
57 void OnDispatchOnInspectorBackend(const std::string
& message
);
58 void OnInspectElement(int x
, int y
);
59 void OnAddMessageToConsole(content::ConsoleMessageLevel level
,
60 const std::string
& message
);
61 void ContinueProgram();
62 void OnSetupDevToolsClient();
66 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent
);
69 #endif // CONTENT_RENDERER_DEVTOOLS_AGENT_H_