OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/renderer/devtools_agent.h" | 5 #include "chrome/renderer/devtools_agent.h" |
6 | 6 |
7 #include "chrome/common/devtools_messages.h" | 7 #include "chrome/common/devtools_messages.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "chrome/renderer/render_view.h" | 9 #include "chrome/renderer/render_view.h" |
10 #include "webkit/api/public/WebDevToolsAgent.h" | 10 #include "webkit/api/public/WebDevToolsAgent.h" |
11 #include "webkit/api/public/WebPoint.h" | 11 #include "webkit/api/public/WebPoint.h" |
12 #include "webkit/api/public/WebString.h" | 12 #include "webkit/api/public/WebString.h" |
| 13 #include "webkit/glue/glue_util.h" |
13 | 14 |
14 using WebKit::WebDevToolsAgent; | 15 using WebKit::WebDevToolsAgent; |
15 using WebKit::WebPoint; | 16 using WebKit::WebPoint; |
16 using WebKit::WebString; | 17 using WebKit::WebString; |
17 using WebKit::WebView; | 18 using WebKit::WebView; |
18 | 19 |
19 // static | 20 // static |
20 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_; | 21 std::map<int, DevToolsAgent*> DevToolsAgent::agent_for_routing_id_; |
21 | 22 |
22 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* view) | 23 DevToolsAgent::DevToolsAgent(int routing_id, RenderView* render_view) |
23 : routing_id_(routing_id), | 24 : routing_id_(routing_id), |
24 view_(view) { | 25 render_view_(render_view) { |
25 agent_for_routing_id_[routing_id] = this; | 26 agent_for_routing_id_[routing_id] = this; |
26 } | 27 } |
27 | 28 |
28 DevToolsAgent::~DevToolsAgent() { | 29 DevToolsAgent::~DevToolsAgent() { |
29 agent_for_routing_id_.erase(routing_id_); | 30 agent_for_routing_id_.erase(routing_id_); |
30 } | 31 } |
31 | 32 |
32 void DevToolsAgent::OnNavigate() { | 33 void DevToolsAgent::OnNavigate() { |
33 WebDevToolsAgent* web_agent = GetWebAgent(); | 34 WebDevToolsAgent* web_agent = GetWebAgent(); |
34 if (web_agent) { | 35 if (web_agent) { |
(...skipping 22 matching lines...) Expand all Loading... |
57 const WebString& param2, | 58 const WebString& param2, |
58 const WebString& param3) { | 59 const WebString& param3) { |
59 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( | 60 IPC::Message* m = new ViewHostMsg_ForwardToDevToolsClient( |
60 routing_id_, | 61 routing_id_, |
61 DevToolsClientMsg_RpcMessage( | 62 DevToolsClientMsg_RpcMessage( |
62 class_name.utf8(), | 63 class_name.utf8(), |
63 method_name.utf8(), | 64 method_name.utf8(), |
64 param1.utf8(), | 65 param1.utf8(), |
65 param2.utf8(), | 66 param2.utf8(), |
66 param3.utf8())); | 67 param3.utf8())); |
67 view_->Send(m); | 68 render_view_->Send(m); |
68 } | 69 } |
69 | 70 |
70 int DevToolsAgent::hostIdentifier() { | 71 int DevToolsAgent::hostIdentifier() { |
71 return routing_id_; | 72 return routing_id_; |
72 } | 73 } |
73 | 74 |
74 void DevToolsAgent::forceRepaint() { | 75 void DevToolsAgent::forceRepaint() { |
75 view_->GenerateFullRepaint(); | 76 render_view_->GenerateFullRepaint(); |
| 77 } |
| 78 |
| 79 void DevToolsAgent::runtimeFeatureStateChanged(const WebKit::WebString& feature, |
| 80 bool enabled) { |
| 81 render_view_->Send(new ViewHostMsg_DevToolsRuntimeFeatureStateChanged( |
| 82 routing_id_, |
| 83 feature.utf8(), |
| 84 enabled)); |
76 } | 85 } |
77 | 86 |
78 // static | 87 // static |
79 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { | 88 DevToolsAgent* DevToolsAgent::FromHostId(int host_id) { |
80 std::map<int, DevToolsAgent*>::iterator it = | 89 std::map<int, DevToolsAgent*>::iterator it = |
81 agent_for_routing_id_.find(host_id); | 90 agent_for_routing_id_.find(host_id); |
82 if (it != agent_for_routing_id_.end()) { | 91 if (it != agent_for_routing_id_.end()) { |
83 return it->second; | 92 return it->second; |
84 } | 93 } |
85 return NULL; | 94 return NULL; |
86 } | 95 } |
87 | 96 |
88 void DevToolsAgent::OnAttach() { | 97 void DevToolsAgent::OnAttach(const std::vector<std::string>& runtime_features) { |
89 WebDevToolsAgent* web_agent = GetWebAgent(); | 98 WebDevToolsAgent* web_agent = GetWebAgent(); |
90 if (web_agent) { | 99 if (web_agent) { |
91 web_agent->attach(); | 100 web_agent->attach(); |
| 101 for (std::vector<std::string>::const_iterator it = runtime_features.begin(); |
| 102 it != runtime_features.end(); ++it) { |
| 103 web_agent->setRuntimeFeatureEnabled(WebString::fromUTF8(*it), true); |
| 104 } |
92 } | 105 } |
93 } | 106 } |
94 | 107 |
95 void DevToolsAgent::OnDetach() { | 108 void DevToolsAgent::OnDetach() { |
96 WebDevToolsAgent* web_agent = GetWebAgent(); | 109 WebDevToolsAgent* web_agent = GetWebAgent(); |
97 if (web_agent) { | 110 if (web_agent) { |
98 web_agent->detach(); | 111 web_agent->detach(); |
99 } | 112 } |
100 } | 113 } |
101 | 114 |
(...skipping 17 matching lines...) Expand all Loading... |
119 WebDevToolsAgent* web_agent = GetWebAgent(); | 132 WebDevToolsAgent* web_agent = GetWebAgent(); |
120 if (web_agent) { | 133 if (web_agent) { |
121 web_agent->attach(); | 134 web_agent->attach(); |
122 web_agent->inspectElementAt(WebPoint(x, y)); | 135 web_agent->inspectElementAt(WebPoint(x, y)); |
123 } | 136 } |
124 } | 137 } |
125 | 138 |
126 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { | 139 void DevToolsAgent::OnSetApuAgentEnabled(bool enabled) { |
127 WebDevToolsAgent* web_agent = GetWebAgent(); | 140 WebDevToolsAgent* web_agent = GetWebAgent(); |
128 if (web_agent) { | 141 if (web_agent) { |
129 web_agent->setApuAgentEnabled(enabled); | 142 web_agent->setRuntimeFeatureEnabled( |
| 143 webkit_glue::StdStringToWebString("apu-agent"), |
| 144 enabled); |
130 } | 145 } |
131 } | 146 } |
132 | 147 |
133 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { | 148 WebDevToolsAgent* DevToolsAgent::GetWebAgent() { |
134 WebView* web_view = view_->webview(); | 149 WebView* web_view = render_view_->webview(); |
135 if (!web_view) | 150 if (!web_view) |
136 return NULL; | 151 return NULL; |
137 return web_view->devToolsAgent(); | 152 return web_view->devToolsAgent(); |
138 } | 153 } |
OLD | NEW |