diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 13:32:44 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-17 13:32:44 +0000 |
commit | 7c8d46dd6dcd73e56cce98a7f12f79f9fbe7e017 (patch) | |
tree | fecd514d27ae13e6ec72ca3b156615c100d54b9c /webkit/glue/webdevtoolsagent_impl.cc | |
parent | 6b0d6339349505d439d296ceec12ae9afc9d4062 (diff) | |
download | chromium_src-7c8d46dd6dcd73e56cce98a7f12f79f9fbe7e017.zip chromium_src-7c8d46dd6dcd73e56cce98a7f12f79f9fbe7e017.tar.gz chromium_src-7c8d46dd6dcd73e56cce98a7f12f79f9fbe7e017.tar.bz2 |
DevTools: Add support for dumping objects into the console. (Take 2).
BUG=13851
Review URL: http://codereview.chromium.org/126270
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18617 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webdevtoolsagent_impl.cc')
-rw-r--r-- | webkit/glue/webdevtoolsagent_impl.cc | 60 |
1 files changed, 32 insertions, 28 deletions
diff --git a/webkit/glue/webdevtoolsagent_impl.cc b/webkit/glue/webdevtoolsagent_impl.cc index c3a6181..cd8e30ac 100644 --- a/webkit/glue/webdevtoolsagent_impl.cc +++ b/webkit/glue/webdevtoolsagent_impl.cc @@ -42,6 +42,8 @@ using WebCore::Node; using WebCore::Page; using WebCore::ScriptValue; using WebCore::String; +using WebCore::V8ClassIndex; +using WebCore::V8Proxy; WebDevToolsAgentImpl::WebDevToolsAgentImpl( WebViewImpl* web_view_impl, @@ -83,21 +85,15 @@ void WebDevToolsAgentImpl::Attach() { // Reuse existing context in case detached/attached. if (utility_context_.IsEmpty()) { debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_); + InitDevToolsAgentHost(); } + dom_agent_impl_->SetDocument(doc); - web_inspector_stub_.set( - new BoundObject(utility_context_, this, "RemoteWebInspector")); - web_inspector_stub_->AddProtoFunction( - "dispatch", - WebDevToolsAgentImpl::JsDispatchOnClient); - web_inspector_stub_->Build(); InspectorController* ic = web_view_impl_->page()->inspectorController(); - // Unhide resources panel if necessary. tools_agent_delegate_stub_->SetResourcesPanelEnabled( ic->resourceTrackingEnabled()); - v8::HandleScope scope; ic->setFrontendProxyObject( scriptStateFromPage(web_view_impl_->page()), @@ -113,7 +109,7 @@ void WebDevToolsAgentImpl::Detach() { InspectorController* ic = web_view_impl_->page()->inspectorController(); ic->setWindowVisible(false, false); HideDOMNodeHighlight(); - web_inspector_stub_.set(NULL); + devtools_agent_host_.set(NULL); debugger_agent_impl_.set(NULL); dom_agent_impl_.set(NULL); attached_ = false; @@ -133,6 +129,9 @@ void WebDevToolsAgentImpl::SetMainFrameDocumentReady(bool ready) { doc = NULL; } debugger_agent_impl_->ResetUtilityContext(doc, &utility_context_); + if (doc) { + InitDevToolsAgentHost(); + } dom_agent_impl_->SetDocument(doc); } @@ -184,31 +183,14 @@ void WebDevToolsAgentImpl::HideDOMNodeHighlight() { } } -void WebDevToolsAgentImpl::EvaluateJavaScript(int call_id, const String& js) { - String result; - bool is_exception = false; - - Page* page = web_view_impl_->page(); - if (page->mainFrame()) { - result = debugger_agent_impl_->EvaluateJavaScript(page->mainFrame(), - js, &is_exception); - } - tools_agent_delegate_stub_->DidEvaluateJavaScript( - call_id, result, is_exception); -} - void WebDevToolsAgentImpl::ExecuteUtilityFunction( int call_id, const String& function_name, - int node_id, const String& json_args) { - Node* node = dom_agent_impl_->GetNodeForId(node_id); String result; String exception; - if (node) { - result = debugger_agent_impl_->ExecuteUtilityFunction(utility_context_, - function_name, node, json_args, &exception); - } + result = debugger_agent_impl_->ExecuteUtilityFunction(utility_context_, + function_name, json_args, &exception); tools_agent_delegate_stub_->DidExecuteUtilityFunction(call_id, result, exception); } @@ -294,6 +276,18 @@ void WebDevToolsAgentImpl::SendRpcMessage( delegate_->SendMessageToClient(class_name, method_name, raw_msg); } +void WebDevToolsAgentImpl::InitDevToolsAgentHost() { + devtools_agent_host_.set( + new BoundObject(utility_context_, this, "DevToolsAgentHost")); + devtools_agent_host_->AddProtoFunction( + "dispatch", + WebDevToolsAgentImpl::JsDispatchOnClient); + devtools_agent_host_->AddProtoFunction( + "getNodeForId", + WebDevToolsAgentImpl::JsGetNodeForId); + devtools_agent_host_->Build(); +} + // static v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchOnClient( const v8::Arguments& args) { @@ -309,6 +303,16 @@ v8::Handle<v8::Value> WebDevToolsAgentImpl::JsDispatchOnClient( } // static +v8::Handle<v8::Value> WebDevToolsAgentImpl::JsGetNodeForId( + const v8::Arguments& args) { + int node_id = static_cast<int>(args[0]->NumberValue()); + WebDevToolsAgentImpl* agent = static_cast<WebDevToolsAgentImpl*>( + v8::External::Cast(*args.Data())->Value()); + Node* node = agent->dom_agent_impl_->GetNodeForId(node_id); + return V8Proxy::ToV8Object(V8ClassIndex::NODE, node); +} + +// static void WebDevToolsAgent::ExecuteDebuggerCommand( const std::string& command, int caller_id) { |