OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_RENDERER_DEVTOOLS_AGENT_H_ | 5 #ifndef CHROME_RENDERER_DEVTOOLS_AGENT_H_ |
6 #define CHROME_RENDERER_DEVTOOLS_AGENT_H_ | 6 #define CHROME_RENDERER_DEVTOOLS_AGENT_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "chrome/common/devtools_messages.h" | 13 #include "chrome/common/devtools_messages.h" |
14 #include "ipc/ipc_channel.h" | 14 #include "chrome/renderer/render_view_observer.h" |
15 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgentClient.h" | 15 #include "third_party/WebKit/WebKit/chromium/public/WebDevToolsAgentClient.h" |
16 | 16 |
17 namespace WebKit { | 17 namespace WebKit { |
18 class WebDevToolsAgent; | 18 class WebDevToolsAgent; |
19 } | 19 } |
20 | 20 |
21 class RenderView; | |
22 struct DevToolsMessageData; | 21 struct DevToolsMessageData; |
23 | 22 |
24 // DevToolsAgent belongs to the inspectable RenderView and provides Glue's | 23 // DevToolsAgent belongs to the inspectable RenderView and provides Glue's |
25 // agents with the communication capabilities. All messages from/to Glue's | 24 // agents with the communication capabilities. All messages from/to Glue's |
26 // agents infrastructure are flowing through this comminucation agent. | 25 // agents infrastructure are flowing through this communication agent. |
27 // There is a corresponding DevToolsClient object on the client side. | 26 // There is a corresponding DevToolsClient object on the client side. |
28 class DevToolsAgent : public WebKit::WebDevToolsAgentClient, | 27 class DevToolsAgent : public RenderViewObserver, |
29 public IPC::Channel::Listener { | 28 public WebKit::WebDevToolsAgentClient { |
30 public: | 29 public: |
31 DevToolsAgent(int routing_id, RenderView* view); | 30 explicit DevToolsAgent(RenderView* render_view); |
32 virtual ~DevToolsAgent(); | 31 virtual ~DevToolsAgent(); |
33 | 32 |
34 void OnNavigate(); | 33 // Returns agent instance for its host id. |
| 34 static DevToolsAgent* FromHostId(int host_id); |
35 | 35 |
36 // IPC::Channel::Listener implementation. | 36 WebKit::WebDevToolsAgent* GetWebAgent(); |
| 37 |
| 38 private: |
| 39 friend class DevToolsAgentFilter; |
| 40 |
| 41 // RenderView::Observer implementation. |
37 virtual bool OnMessageReceived(const IPC::Message& message); | 42 virtual bool OnMessageReceived(const IPC::Message& message); |
38 | 43 |
39 // WebDevToolsAgentClient implementation | 44 // WebDevToolsAgentClient implementation |
40 virtual void sendMessageToInspectorFrontend(const WebKit::WebString& data); | 45 virtual void sendMessageToInspectorFrontend(const WebKit::WebString& data); |
41 virtual void sendDebuggerOutput(const WebKit::WebString& data); | 46 virtual void sendDebuggerOutput(const WebKit::WebString& data); |
42 | 47 |
43 virtual int hostIdentifier(); | 48 virtual int hostIdentifier(); |
44 virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, | 49 virtual void runtimeFeatureStateChanged(const WebKit::WebString& feature, |
45 bool enabled); | 50 bool enabled); |
46 virtual void runtimePropertyChanged(const WebKit::WebString& name, | 51 virtual void runtimePropertyChanged(const WebKit::WebString& name, |
47 const WebKit::WebString& value); | 52 const WebKit::WebString& value); |
48 virtual WebKit::WebCString debuggerScriptSource(); | 53 virtual WebKit::WebCString debuggerScriptSource(); |
49 virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* | 54 virtual WebKit::WebDevToolsAgentClient::WebKitClientMessageLoop* |
50 createClientMessageLoop(); | 55 createClientMessageLoop(); |
51 virtual bool exposeV8DebuggerProtocol(); | 56 virtual bool exposeV8DebuggerProtocol(); |
52 | 57 |
53 // Returns agent instance for its host id. | |
54 static DevToolsAgent* FromHostId(int host_id); | |
55 | |
56 RenderView* render_view() { return render_view_; } | |
57 | |
58 WebKit::WebDevToolsAgent* GetWebAgent(); | |
59 | |
60 private: | |
61 friend class DevToolsAgentFilter; | |
62 | |
63 void OnAttach(const DevToolsRuntimeProperties& runtime_properties); | 58 void OnAttach(const DevToolsRuntimeProperties& runtime_properties); |
64 void OnDetach(); | 59 void OnDetach(); |
65 void OnFrontendLoaded(); | 60 void OnFrontendLoaded(); |
66 void OnDispatchOnInspectorBackend(const std::string& message); | 61 void OnDispatchOnInspectorBackend(const std::string& message); |
67 void OnInspectElement(int x, int y); | 62 void OnInspectElement(int x, int y); |
| 63 void OnSetApuAgentEnabled(bool enabled); |
| 64 void OnNavigate(); |
68 | 65 |
69 static std::map<int, DevToolsAgent*> agent_for_routing_id_; | 66 static std::map<int, DevToolsAgent*> agent_for_routing_id_; |
70 | 67 |
71 int routing_id_; // View routing id that we can access from IO thread. | |
72 RenderView* render_view_; | |
73 bool expose_v8_debugger_protocol_; | 68 bool expose_v8_debugger_protocol_; |
74 | 69 |
75 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); | 70 DISALLOW_COPY_AND_ASSIGN(DevToolsAgent); |
76 }; | 71 }; |
77 | 72 |
78 #endif // CHROME_RENDERER_DEVTOOLS_AGENT_H_ | 73 #endif // CHROME_RENDERER_DEVTOOLS_AGENT_H_ |
OLD | NEW |