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_DEVTOOLS_AGENT_H_
6 #define CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_
10 #include "content/common/content_export.h"
11 #include "content/public/common/console_message_level.h"
12 #include "content/public/renderer/render_frame_observer.h"
13 #include "third_party/WebKit/public/web/WebDevToolsAgentClient.h"
16 class WebDevToolsAgent
;
21 class RenderFrameImpl
;
23 // DevToolsAgent belongs to the inspectable RenderFrameImpl and communicates
24 // with WebDevToolsAgent. There is a corresponding DevToolsAgentHost
25 // on the browser side.
26 class CONTENT_EXPORT DevToolsAgent
27 : public RenderFrameObserver
,
28 NON_EXPORTED_BASE(public blink::WebDevToolsAgentClient
) {
30 explicit DevToolsAgent(RenderFrameImpl
* frame
);
31 ~DevToolsAgent() override
;
33 // Returns agent instance for its routing id.
34 static DevToolsAgent
* FromRoutingId(int routing_id
);
36 static void SendChunkedProtocolMessage(
40 const std::string
& message
,
41 const std::string
& post_state
);
43 blink::WebDevToolsAgent
* GetWebAgent();
47 void AddMessageToConsole(ConsoleMessageLevel level
,
48 const std::string
& message
);
51 friend class DevToolsAgentTest
;
53 // RenderFrameObserver implementation.
54 bool OnMessageReceived(const IPC::Message
& message
) override
;
55 void WidgetWillClose() override
;
57 // WebDevToolsAgentClient implementation.
58 void sendProtocolMessage(int call_id
,
59 const blink::WebString
& response
,
60 const blink::WebString
& state
) override
;
61 blink::WebDevToolsAgentClient::WebKitClientMessageLoop
*
62 createClientMessageLoop() override
;
63 void willEnterDebugLoop() override
;
64 void didExitDebugLoop() override
;
66 void enableTracing(const blink::WebString
& category_filter
) override
;
67 void disableTracing() override
;
69 void OnAttach(const std::string
& host_id
);
70 void OnReattach(const std::string
& host_id
,
71 const std::string
& agent_state
);
73 void OnDispatchOnInspectorBackend(const std::string
& message
);
74 void OnInspectElement(const std::string
& host_id
, int x
, int y
);
75 void ContinueProgram();
76 void OnSetupDevToolsClient(const std::string
& compatibility_script
);
79 bool is_devtools_client_
;
80 bool paused_in_mouse_move_
;
82 RenderFrameImpl
* frame_
;
84 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent
);
87 } // namespace content
89 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_