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"
16 class WebDevToolsAgent
;
22 // DevToolsAgent belongs to the inspectable RenderView and provides Glue's
23 // agents with the communication capabilities. All messages from/to Glue's
24 // agents infrastructure are flowing through this communication agent.
25 // There is a corresponding DevToolsClient object on the client side.
26 class DevToolsAgent
: public RenderViewObserver
,
27 public WebKit::WebDevToolsAgentClient
{
29 explicit DevToolsAgent(RenderViewImpl
* render_view
);
30 virtual ~DevToolsAgent();
32 // Returns agent instance for its host id.
33 static DevToolsAgent
* FromHostId(int host_id
);
35 WebKit::WebDevToolsAgent
* GetWebAgent();
40 friend class DevToolsAgentFilter
;
42 // RenderView::Observer implementation.
43 virtual bool OnMessageReceived(const IPC::Message
& message
) OVERRIDE
;
45 // WebDevToolsAgentClient implementation
46 virtual void sendMessageToInspectorFrontend(const WebKit::WebString
& data
);
48 virtual int hostIdentifier();
49 virtual void saveAgentRuntimeState(const WebKit::WebString
& state
);
50 virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop
*
51 createClientMessageLoop();
52 virtual void clearBrowserCache();
53 virtual void clearBrowserCookies();
54 virtual void visitAllocatedObjects(AllocatedObjectVisitor
* visitor
);
57 void OnReattach(const std::string
& agent_state
);
59 void OnDispatchOnInspectorBackend(const std::string
& message
);
60 void OnInspectElement(int x
, int y
);
61 void OnAddMessageToConsole(ConsoleMessageLevel level
,
62 const std::string
& message
);
63 void ContinueProgram();
64 void OnSetupDevToolsClient();
68 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent
);
71 } // namespace content
73 #endif // CONTENT_RENDERER_DEVTOOLS_AGENT_H_