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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "Document.h" | 9 #include "Document.h" |
10 #include "EventListener.h" | 10 #include "EventListener.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 using WebCore::SafeAllocation; | 45 using WebCore::SafeAllocation; |
46 using WebCore::ScriptObject; | 46 using WebCore::ScriptObject; |
47 using WebCore::ScriptState; | 47 using WebCore::ScriptState; |
48 using WebCore::ScriptValue; | 48 using WebCore::ScriptValue; |
49 using WebCore::String; | 49 using WebCore::String; |
50 using WebCore::V8ClassIndex; | 50 using WebCore::V8ClassIndex; |
51 using WebCore::V8DOMWrapper; | 51 using WebCore::V8DOMWrapper; |
52 using WebCore::V8Proxy; | 52 using WebCore::V8Proxy; |
53 using WebKit::WebDataSource; | 53 using WebKit::WebDataSource; |
54 using WebKit::WebFrame; | 54 using WebKit::WebFrame; |
| 55 using WebKit::WebString; |
| 56 using WebKit::WebURL; |
55 using WebKit::WebURLRequest; | 57 using WebKit::WebURLRequest; |
56 | 58 |
57 | |
58 namespace { | 59 namespace { |
59 | 60 |
60 void InspectorBackendWeakReferenceCallback(v8::Persistent<v8::Value> object, | 61 void InspectorBackendWeakReferenceCallback(v8::Persistent<v8::Value> object, |
61 void* parameter) { | 62 void* parameter) { |
62 InspectorBackend* backend = static_cast<InspectorBackend*>(parameter); | 63 InspectorBackend* backend = static_cast<InspectorBackend*>(parameter); |
63 backend->deref(); | 64 backend->deref(); |
64 object.Dispose(); | 65 object.Dispose(); |
65 } | 66 } |
66 | 67 |
67 void SetApuAgentEnabledInUtilityContext(v8::Handle<v8::Context> context, | 68 void SetApuAgentEnabledInUtilityContext(v8::Handle<v8::Context> context, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 | 148 |
148 void WebDevToolsAgentImpl::DidCommitLoadForFrame( | 149 void WebDevToolsAgentImpl::DidCommitLoadForFrame( |
149 WebViewImpl* webview, | 150 WebViewImpl* webview, |
150 WebFrame* frame, | 151 WebFrame* frame, |
151 bool is_new_navigation) { | 152 bool is_new_navigation) { |
152 if (!attached_) { | 153 if (!attached_) { |
153 return; | 154 return; |
154 } | 155 } |
155 WebDataSource* ds = frame->dataSource(); | 156 WebDataSource* ds = frame->dataSource(); |
156 const WebURLRequest& request = ds->request(); | 157 const WebURLRequest& request = ds->request(); |
157 GURL url = ds->hasUnreachableURL() ? | 158 WebURL url = ds->hasUnreachableURL() ? |
158 ds->unreachableURL() : | 159 ds->unreachableURL() : |
159 request.url(); | 160 request.url(); |
160 if (webview->mainFrame() == frame) { | 161 if (webview->mainFrame() == frame) { |
161 ResetInspectorFrontendProxy(); | 162 ResetInspectorFrontendProxy(); |
162 tools_agent_delegate_stub_->FrameNavigate( | 163 tools_agent_delegate_stub_->FrameNavigate( |
163 url.possibly_invalid_spec()); | 164 webkit_glue::WebURLToKURL(url).string()); |
164 SetApuAgentEnabledInUtilityContext(utility_context_, apu_agent_enabled_); | 165 SetApuAgentEnabledInUtilityContext(utility_context_, apu_agent_enabled_); |
165 } | 166 } |
166 UnhideResourcesPanelIfNecessary(); | 167 UnhideResourcesPanelIfNecessary(); |
167 } | 168 } |
168 | 169 |
169 void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) { | 170 void WebDevToolsAgentImpl::WindowObjectCleared(WebFrameImpl* webframe) { |
170 DebuggerAgentManager::SetHostId(webframe, host_id_); | 171 DebuggerAgentManager::SetHostId(webframe, host_id_); |
171 if (attached_) { | 172 if (attached_) { |
172 // Push context id into the client if it is already attached. | 173 // Push context id into the client if it is already attached. |
173 debugger_agent_delegate_stub_->SetContextId(host_id_); | 174 debugger_agent_delegate_stub_->SetContextId(host_id_); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } else { | 245 } else { |
245 ic->stopTimelineProfiler(); | 246 ic->stopTimelineProfiler(); |
246 if (!resource_tracking_was_enabled_) { | 247 if (!resource_tracking_was_enabled_) { |
247 ic->disableResourceTracking(false); | 248 ic->disableResourceTracking(false); |
248 } | 249 } |
249 resource_tracking_was_enabled_ = false; | 250 resource_tracking_was_enabled_ = false; |
250 } | 251 } |
251 } | 252 } |
252 | 253 |
253 void WebDevToolsAgentImpl::DispatchMessageFromClient( | 254 void WebDevToolsAgentImpl::DispatchMessageFromClient( |
254 const std::string& class_name, | 255 const WebString& class_name, |
255 const std::string& method_name, | 256 const WebString& method_name, |
256 const std::string& param1, | 257 const WebString& param1, |
257 const std::string& param2, | 258 const WebString& param2, |
258 const std::string& param3) { | 259 const WebString& param3) { |
259 if (ToolsAgentDispatch::Dispatch( | 260 if (ToolsAgentDispatch::Dispatch( |
260 this, class_name, method_name, param1, param2, param3)) { | 261 this, |
| 262 webkit_glue::WebStringToString(class_name), |
| 263 webkit_glue::WebStringToString(method_name), |
| 264 webkit_glue::WebStringToString(param1), |
| 265 webkit_glue::WebStringToString(param2), |
| 266 webkit_glue::WebStringToString(param3))) { |
261 return; | 267 return; |
262 } | 268 } |
263 | 269 |
264 if (!attached_) { | 270 if (!attached_) { |
265 return; | 271 return; |
266 } | 272 } |
267 | 273 |
268 if (debugger_agent_impl_.get() && | 274 if (debugger_agent_impl_.get() && |
269 DebuggerAgentDispatch::Dispatch( | 275 DebuggerAgentDispatch::Dispatch( |
270 debugger_agent_impl_.get(), class_name, method_name, | 276 debugger_agent_impl_.get(), |
271 param1, param2, param3)) { | 277 webkit_glue::WebStringToString(class_name), |
| 278 webkit_glue::WebStringToString(method_name), |
| 279 webkit_glue::WebStringToString(param1), |
| 280 webkit_glue::WebStringToString(param2), |
| 281 webkit_glue::WebStringToString(param3))) { |
272 return; | 282 return; |
273 } | 283 } |
274 } | 284 } |
275 | 285 |
276 void WebDevToolsAgentImpl::InspectElement(int x, int y) { | 286 void WebDevToolsAgentImpl::InspectElement(int x, int y) { |
277 Node* node = web_view_impl_->GetNodeForWindowPos(x, y); | 287 Node* node = web_view_impl_->GetNodeForWindowPos(x, y); |
278 if (!node) { | 288 if (!node) { |
279 return; | 289 return; |
280 } | 290 } |
281 InspectorController* ic = web_view_impl_->page()->inspectorController(); | 291 InspectorController* ic = web_view_impl_->page()->inspectorController(); |
282 ic->inspect(node); | 292 ic->inspect(node); |
283 } | 293 } |
284 | 294 |
285 void WebDevToolsAgentImpl::SendRpcMessage( | 295 void WebDevToolsAgentImpl::SendRpcMessage( |
286 const std::string& class_name, | 296 const String& class_name, |
287 const std::string& method_name, | 297 const String& method_name, |
288 const std::string& param1, | 298 const String& param1, |
289 const std::string& param2, | 299 const String& param2, |
290 const std::string& param3) { | 300 const String& param3) { |
291 delegate_->SendMessageToClient(class_name, method_name, param1, param2, | 301 delegate_->SendMessageToClient( |
292 param3); | 302 webkit_glue::StringToWebString(class_name), |
| 303 webkit_glue::StringToWebString(method_name), |
| 304 webkit_glue::StringToWebString(param1), |
| 305 webkit_glue::StringToWebString(param2), |
| 306 webkit_glue::StringToWebString(param3)); |
293 } | 307 } |
294 | 308 |
295 void WebDevToolsAgentImpl::InitDevToolsAgentHost() { | 309 void WebDevToolsAgentImpl::InitDevToolsAgentHost() { |
296 devtools_agent_host_.set( | 310 devtools_agent_host_.set( |
297 new BoundObject(utility_context_, this, "DevToolsAgentHost")); | 311 new BoundObject(utility_context_, this, "DevToolsAgentHost")); |
298 devtools_agent_host_->AddProtoFunction( | 312 devtools_agent_host_->AddProtoFunction( |
299 "dispatch", | 313 "dispatch", |
300 WebDevToolsAgentImpl::JsDispatchOnClient); | 314 WebDevToolsAgentImpl::JsDispatchOnClient); |
301 devtools_agent_host_->AddProtoFunction( | 315 devtools_agent_host_->AddProtoFunction( |
302 "dispatchToApu", | 316 "dispatchToApu", |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 return v8::Undefined(); | 402 return v8::Undefined(); |
389 } | 403 } |
390 WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>( | 404 WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>( |
391 v8::External::Cast(*args.Data())->Value()); | 405 v8::External::Cast(*args.Data())->Value()); |
392 agent->apu_agent_delegate_stub_->DispatchToApu(message); | 406 agent->apu_agent_delegate_stub_->DispatchToApu(message); |
393 return v8::Undefined(); | 407 return v8::Undefined(); |
394 } | 408 } |
395 | 409 |
396 // static | 410 // static |
397 void WebDevToolsAgent::ExecuteDebuggerCommand( | 411 void WebDevToolsAgent::ExecuteDebuggerCommand( |
398 const std::string& command, | 412 const WebString& command, |
399 int caller_id) { | 413 int caller_id) { |
400 DebuggerAgentManager::ExecuteDebuggerCommand(command, caller_id); | 414 DebuggerAgentManager::ExecuteDebuggerCommand( |
| 415 webkit_glue::WebStringToString(command), caller_id); |
401 } | 416 } |
402 | 417 |
403 // static | 418 // static |
404 void WebDevToolsAgent::SetMessageLoopDispatchHandler( | 419 void WebDevToolsAgent::SetMessageLoopDispatchHandler( |
405 MessageLoopDispatchHandler handler) { | 420 MessageLoopDispatchHandler handler) { |
406 DebuggerAgentManager::SetMessageLoopDispatchHandler(handler); | 421 DebuggerAgentManager::SetMessageLoopDispatchHandler(handler); |
407 } | 422 } |
OLD | NEW |