| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ | 5 #ifndef CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ |
| 6 #define CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ | 6 #define CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "content/common/content_export.h" | |
| 11 #include "content/public/common/console_message_level.h" | 10 #include "content/public/common/console_message_level.h" |
| 12 #include "content/public/renderer/render_frame_observer.h" | 11 #include "content/public/renderer/render_frame_observer.h" |
| 13 #include "third_party/WebKit/public/web/WebDevToolsAgentClient.h" | 12 #include "third_party/WebKit/public/web/WebDevToolsAgentClient.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 class WebDevToolsAgent; | 15 class WebDevToolsAgent; |
| 17 } | 16 } |
| 18 | 17 |
| 19 namespace content { | 18 namespace content { |
| 20 | 19 |
| 21 class RenderFrameImpl; | 20 class RenderFrameImpl; |
| 22 | 21 |
| 23 // DevToolsAgent belongs to the inspectable RenderFrameImpl and communicates | 22 // DevToolsAgent belongs to the inspectable RenderFrameImpl and communicates |
| 24 // with WebDevToolsAgent. There is a corresponding DevToolsAgentHost | 23 // with WebDevToolsAgent. There is a corresponding DevToolsAgentHost |
| 25 // on the browser side. | 24 // on the browser side. |
| 26 class CONTENT_EXPORT DevToolsAgent | 25 class DevToolsAgent : public RenderFrameObserver, |
| 27 : public RenderFrameObserver, | 26 public blink::WebDevToolsAgentClient { |
| 28 NON_EXPORTED_BASE(public blink::WebDevToolsAgentClient) { | |
| 29 public: | 27 public: |
| 30 explicit DevToolsAgent(RenderFrameImpl* frame); | 28 explicit DevToolsAgent(RenderFrameImpl* frame); |
| 31 ~DevToolsAgent() override; | 29 ~DevToolsAgent() override; |
| 32 | 30 |
| 33 // Returns agent instance for its routing id. | 31 // Returns agent instance for its routing id. |
| 34 static DevToolsAgent* FromRoutingId(int routing_id); | 32 static DevToolsAgent* FromRoutingId(int routing_id); |
| 35 | 33 |
| 36 static void SendChunkedProtocolMessage( | 34 static void SendChunkedProtocolMessage( |
| 37 IPC::Sender* sender, | 35 IPC::Sender* sender, |
| 38 int routing_id, | 36 int routing_id, |
| 39 int call_id, | 37 int call_id, |
| 40 const std::string& message, | 38 const std::string& message, |
| 41 const std::string& post_state); | 39 const std::string& post_state); |
| 42 | 40 |
| 43 blink::WebDevToolsAgent* GetWebAgent(); | 41 blink::WebDevToolsAgent* GetWebAgent(); |
| 44 | 42 |
| 45 bool IsAttached(); | 43 bool IsAttached(); |
| 46 | 44 |
| 47 private: | 45 private: |
| 48 friend class DevToolsAgentTest; | |
| 49 | |
| 50 // RenderFrameObserver implementation. | 46 // RenderFrameObserver implementation. |
| 51 bool OnMessageReceived(const IPC::Message& message) override; | 47 bool OnMessageReceived(const IPC::Message& message) override; |
| 52 void WidgetWillClose() override; | |
| 53 | 48 |
| 54 // WebDevToolsAgentClient implementation. | 49 // WebDevToolsAgentClient implementation. |
| 55 void sendProtocolMessage(int call_id, | 50 void sendProtocolMessage(int call_id, |
| 56 const blink::WebString& response, | 51 const blink::WebString& response, |
| 57 const blink::WebString& state) override; | 52 const blink::WebString& state) override; |
| 58 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* | 53 blink::WebDevToolsAgentClient::WebKitClientMessageLoop* |
| 59 createClientMessageLoop() override; | 54 createClientMessageLoop() override; |
| 60 void willEnterDebugLoop() override; | 55 void willEnterDebugLoop() override; |
| 61 void didExitDebugLoop() override; | 56 void didExitDebugLoop() override; |
| 62 | 57 |
| 63 void enableTracing(const blink::WebString& category_filter) override; | 58 void enableTracing(const blink::WebString& category_filter) override; |
| 64 void disableTracing() override; | 59 void disableTracing() override; |
| 65 | 60 |
| 66 void OnAttach(const std::string& host_id); | 61 void OnAttach(const std::string& host_id); |
| 67 void OnReattach(const std::string& host_id, | 62 void OnReattach(const std::string& host_id, |
| 68 const std::string& agent_state); | 63 const std::string& agent_state); |
| 69 void OnDetach(); | 64 void OnDetach(); |
| 70 void OnDispatchOnInspectorBackend(const std::string& message); | 65 void OnDispatchOnInspectorBackend(const std::string& message); |
| 71 void OnInspectElement(const std::string& host_id, int x, int y); | 66 void OnInspectElement(const std::string& host_id, int x, int y); |
| 72 void OnAddMessageToConsole(ConsoleMessageLevel level, | 67 void OnAddMessageToConsole(ConsoleMessageLevel level, |
| 73 const std::string& message); | 68 const std::string& message); |
| 74 void ContinueProgram(); | 69 void ContinueProgram(); |
| 75 void OnSetupDevToolsClient(); | 70 void OnSetupDevToolsClient(); |
| 76 | 71 |
| 77 bool is_attached_; | 72 bool is_attached_; |
| 78 bool is_devtools_client_; | 73 bool is_devtools_client_; |
| 79 bool paused_in_mouse_move_; | 74 bool paused_in_mouse_move_; |
| 80 bool paused_; | |
| 81 RenderFrameImpl* frame_; | 75 RenderFrameImpl* frame_; |
| 82 | 76 |
| 83 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); | 77 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); |
| 84 }; | 78 }; |
| 85 | 79 |
| 86 } // namespace content | 80 } // namespace content |
| 87 | 81 |
| 88 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ | 82 #endif // CONTENT_RENDERER_DEVTOOLS_DEVTOOLS_AGENT_H_ |
| OLD | NEW |