summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 10:30:14 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-16 10:30:14 +0000
commit37daf5b742a67987acb231645a88988f9a903377 (patch)
treea6c719df45f2105446a75f5790f91ceef19c8a84
parentf2d75329c6ef6b2e9addcd9f65d0ef3b26b2126b (diff)
downloadchromium_src-37daf5b742a67987acb231645a88988f9a903377.zip
chromium_src-37daf5b742a67987acb231645a88988f9a903377.tar.gz
chromium_src-37daf5b742a67987acb231645a88988f9a903377.tar.bz2
DevTools: Add support for dumping objects into the console.
Review URL: http://codereview.chromium.org/126132 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18484 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.cc29
-rw-r--r--webkit/glue/devtools/debugger_agent_impl.h6
-rw-r--r--webkit/glue/devtools/js/devtools.js36
-rw-r--r--webkit/glue/devtools/js/dom_agent.js18
-rw-r--r--webkit/glue/devtools/js/inject.js126
-rw-r--r--webkit/glue/devtools/js/inject_dispatch.js13
-rw-r--r--webkit/glue/devtools/tools_agent.h12
-rw-r--r--webkit/glue/webdevtoolsagent_impl.cc60
-rw-r--r--webkit/glue/webdevtoolsagent_impl.h7
9 files changed, 190 insertions, 117 deletions
diff --git a/webkit/glue/devtools/debugger_agent_impl.cc b/webkit/glue/devtools/debugger_agent_impl.cc
index 41ee6d1..4fb5f243 100644
--- a/webkit/glue/devtools/debugger_agent_impl.cc
+++ b/webkit/glue/devtools/debugger_agent_impl.cc
@@ -9,7 +9,6 @@
#include <wtf/Vector.h>
#include "Document.h"
-#include "Node.h"
#include "Page.h"
#undef LOG
@@ -30,7 +29,6 @@
using WebCore::DOMWindow;
using WebCore::Document;
using WebCore::Frame;
-using WebCore::Node;
using WebCore::Page;
using WebCore::String;
using WebCore::V8ClassIndex;
@@ -154,7 +152,6 @@ void DebuggerAgentImpl::ResetUtilityContext(
String DebuggerAgentImpl::ExecuteUtilityFunction(
v8::Handle<v8::Context> context,
const String &function_name,
- Node* node,
const String& json_args,
String* exception) {
v8::HandleScope scope;
@@ -163,20 +160,17 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
v8::Handle<v8::Function> function = v8::Local<v8::Function>::Cast(
context->Global()->Get(v8::String::New("devtools$$dispatch")));
- v8::Handle<v8::Value> node_wrapper =
- V8Proxy::ToV8Object(V8ClassIndex::NODE, node);
v8::Handle<v8::String> function_name_wrapper = v8::Handle<v8::String>(
v8::String::New(function_name.utf8().data()));
v8::Handle<v8::String> json_args_wrapper = v8::Handle<v8::String>(
v8::String::New(json_args.utf8().data()));
v8::Handle<v8::Value> args[] = {
function_name_wrapper,
- node_wrapper,
json_args_wrapper
};
v8::TryCatch try_catch;
- v8::Handle<v8::Value> res_obj = function->Call(context->Global(), 3, args);
+ v8::Handle<v8::Value> res_obj = function->Call(context->Global(), 2, args);
if (try_catch.HasCaught()) {
*exception = WebCore::ToWebCoreString(try_catch.Message()->Get());
return "";
@@ -186,27 +180,6 @@ String DebuggerAgentImpl::ExecuteUtilityFunction(
}
}
-String DebuggerAgentImpl::EvaluateJavaScript(
- Frame* frame,
- const String &source_code,
- bool* is_exception) {
- v8::HandleScope scope;
- v8::Handle<v8::Context> context = V8Proxy::GetContext(frame);
- v8::Context::Scope context_scope(context);
- v8::Local<v8::String> code = v8ExternalString(source_code);
-
- V8Proxy* proxy = V8Proxy::retrieve(frame);
- v8::TryCatch try_catch;
- v8::Handle<v8::Script> script = proxy->CompileScript(code, "", 0);
- v8::Local<v8::Value> object = proxy->RunScript(script, true);
- if (try_catch.HasCaught()) {
- *is_exception = true;
- return WebCore::ToWebCoreString(try_catch.Message()->Get());
- } else {
- return WebCore::toWebCoreStringWithNullCheck(object);
- }
-}
-
WebCore::Page* DebuggerAgentImpl::GetPage() {
return web_view_impl_->page();
}
diff --git a/webkit/glue/devtools/debugger_agent_impl.h b/webkit/glue/devtools/debugger_agent_impl.h
index 55d5ec8..4d57b91 100644
--- a/webkit/glue/devtools/debugger_agent_impl.h
+++ b/webkit/glue/devtools/debugger_agent_impl.h
@@ -54,15 +54,9 @@ class DebuggerAgentImpl : public DebuggerAgent {
WebCore::String ExecuteUtilityFunction(
v8::Handle<v8::Context> context,
const WebCore::String& function_name,
- WebCore::Node* node,
const WebCore::String& json_args,
WebCore::String* exception);
- WebCore::String EvaluateJavaScript(
- WebCore::Frame* frame,
- const WebCore::String& source_code,
- bool* is_exception);
-
WebCore::Page* GetPage();
WebDevToolsAgentImpl* webdevtools_agent() { return webdevtools_agent_; };
diff --git a/webkit/glue/devtools/js/devtools.js b/webkit/glue/devtools/js/devtools.js
index b1aede6..651ca94 100644
--- a/webkit/glue/devtools/js/devtools.js
+++ b/webkit/glue/devtools/js/devtools.js
@@ -75,8 +75,12 @@ devtools.ToolsAgent.prototype.reset = function() {
* result.
*/
devtools.ToolsAgent.prototype.evaluateJavaScript = function(script, callback) {
- var callbackId = devtools.Callback.wrap(callback);
- RemoteToolsAgent.EvaluateJavaScript(callbackId, script);
+ var callbackId = devtools.Callback.wrap(function(result) {
+ var pair = JSON.parse(result);
+ callback(pair[0], pair[1]);
+ });
+ RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
+ 'evaluate', JSON.stringify([script]));
};
@@ -907,9 +911,28 @@ WebInspector.UIString = function(string) {
}
return result;
};
+
+ // This is needed to evaluate 'instanceof' against win.Node, etc.
+ // Need a real window, not just InspectorController.inspectedWindow wrapper.
+ var oldType = Object.type;
+ Object.type = function(obj) {
+ return oldType.call(this, obj, window);
+ };
})();
+Object.sortedProperties = function(obj) {
+ var properties = [];
+ for (var prop in obj) {
+ if (prop != '___devtools_id') {
+ properties.push(prop);
+ }
+ }
+ properties.sort();
+ return properties;
+}
+
+
// Highlight extension content scripts in the scripts list.
(function () {
var original = WebInspector.ScriptsPanel.prototype._addScriptToFilesMenu;
@@ -924,3 +947,12 @@ WebInspector.UIString = function(string) {
return result;
};
})();
+
+
+WebInspector.Console.prototype._formatobject = function(object, elem) {
+ var wrapper = {};
+ wrapper.id_ = object.___devtools_id;
+ wrapper.protoDepth_ = -1;
+ var section = new WebInspector.SidebarObjectPropertiesSection(wrapper, null);
+ elem.appendChild(section.element);
+};
diff --git a/webkit/glue/devtools/js/dom_agent.js b/webkit/glue/devtools/js/dom_agent.js
index 2092d6d..f9304b7 100644
--- a/webkit/glue/devtools/js/dom_agent.js
+++ b/webkit/glue/devtools/js/dom_agent.js
@@ -840,8 +840,8 @@ devtools.DomAgent.prototype.getNodePropertiesAsync = function(nodeId,
path, protoDepth, callback) {
var callbackId = this.utilityFunctionCallbackWrapper_(callback);
RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
- 'getProperties', nodeId,
- JSON.stringify([path, protoDepth]));
+ 'getProperties',
+ JSON.stringify([nodeId, path, protoDepth]));
};
@@ -854,7 +854,7 @@ devtools.DomAgent.prototype.getNodePrototypesAsync = function(nodeId,
callback) {
var callbackId = this.utilityFunctionCallbackWrapper_(callback);
RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
- 'getPrototypes', nodeId, '[]');
+ 'getPrototypes', JSON.stringify([nodeId]));
};
@@ -869,8 +869,7 @@ devtools.DomAgent.prototype.getNodeStylesAsync = function(node,
var callbackId = this.utilityFunctionCallbackWrapper_(callback);
RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
'getStyles',
- node.id_,
- JSON.stringify([authorOnly]));
+ JSON.stringify([node.id_, authorOnly]));
};
@@ -886,8 +885,7 @@ devtools.DomAgent.prototype.toggleNodeStyleAsync = function(
var callbackId = this.utilityFunctionCallbackWrapper_(callback);
RemoteToolsAgent.ExecuteUtilityFunction(callbackId,
'toggleNodeStyle',
- style.nodeId_,
- JSON.stringify([style.id_, enabled, name]));
+ JSON.stringify([style.nodeId_, style.id_, enabled, name]));
};
@@ -904,8 +902,7 @@ devtools.DomAgent.prototype.applyStyleTextAsync = function(
RemoteToolsAgent.ExecuteUtilityFunction(
callbackId,
'applyStyleText',
- style.nodeId_,
- JSON.stringify([style.id_, name, styleText]));
+ JSON.stringify([style.nodeId_, style.id_, name, styleText]));
};
@@ -922,8 +919,7 @@ devtools.DomAgent.prototype.setStylePropertyAsync = function(
RemoteToolsAgent.ExecuteUtilityFunction(
callbackId,
'setStyleProperty',
- node.id_,
- JSON.stringify([name, value]));
+ JSON.stringify([node.id_, name, value]));
};
diff --git a/webkit/glue/devtools/js/inject.js b/webkit/glue/devtools/js/inject.js
index 251501a..7a88f30 100644
--- a/webkit/glue/devtools/js/inject.js
+++ b/webkit/glue/devtools/js/inject.js
@@ -28,20 +28,50 @@ devtools.Injected = function() {
* @private
*/
this.styles_ = [];
+
+ /**
+ * This cache contains mapping from object it to an object instance for
+ * all results of the evaluation / console logs.
+ */
+ this.cachedConsoleObjects_ = {};
+
+ /**
+ * Last id for the cache above.
+ */
+ this.lastCachedConsoleObjectId_ = 1;
+};
+
+
+/**
+ * Returns object for given id. This can be either node wrapper for
+ * integer ids or evaluation results that recide in cached console
+ * objects cache for arbitrary keys.
+ * @param {number|string} id Id to get object for.
+ * @return {Object} resolved object.
+ */
+devtools.Injected.prototype.getObjectForId_ = function(id) {
+ if (typeof id == 'number') {
+ return DevToolsAgentHost.getNodeForId(id);
+ }
+ return this.cachedConsoleObjects_[id];
};
/**
* Returns array of properties for a given node on a given path.
- * @param {Node} node Node to get property value for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @param {Array.<string>} path Path to the nested object.
* @param {number} protoDepth Depth of the actual proto to inspect.
* @return {Array.<Object>} Array where each property is represented
* by the tree entries [{string} type, {string} name, {Object} value].
*/
-devtools.Injected.prototype.getProperties = function(node, path, protoDepth) {
+devtools.Injected.prototype.getProperties =
+ function(nodeId, path, protoDepth) {
var result = [];
- var obj = node;
+ var obj = this.getObjectForId_(nodeId);
+ if (!obj) {
+ return [];
+ }
// Follow the path.
for (var i = 0; obj && i < path.length; ++i) {
@@ -73,8 +103,7 @@ devtools.Injected.prototype.getProperties = function(node, path, protoDepth) {
if (type == 'string') {
var str = obj[name];
result.push(str.length > 99 ? str.substr(0, 99) + '...' : str);
- } else if (type != 'object' && type != 'array' &&
- type != 'function') {
+ } else if (type != 'object' && type != 'function') {
result.push(obj[name]);
} else {
result.push(undefined);
@@ -86,10 +115,15 @@ devtools.Injected.prototype.getProperties = function(node, path, protoDepth) {
/**
* Returns array of prototypes for a given node.
- * @param {Node} node Node to get prorotypes for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @return {Array<string>} Array of proto names.
*/
-devtools.Injected.prototype.getPrototypes = function(node) {
+devtools.Injected.prototype.getPrototypes = function(nodeId) {
+ var node = DevToolsAgentHost.getNodeForId(nodeId);
+ if (!node) {
+ return [];
+ }
+
var result = [];
for (var prototype = node; prototype; prototype = prototype.__proto__) {
var description = Object.prototype.toString.call(prototype);
@@ -101,13 +135,18 @@ devtools.Injected.prototype.getPrototypes = function(node) {
/**
* Returns style information that is used in devtools.js.
- * @param {Node} node Node to get prorotypes for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @param {boolean} authorOnly Determines whether only author styles need to
* be added.
* @return {string} Style collection descriptor.
*/
-devtools.Injected.prototype.getStyles = function(node, authorOnly) {
- if (!node.nodeType == Node.ELEMENT_NODE) {
+devtools.Injected.prototype.getStyles = function(nodeId, authorOnly) {
+ var node = DevToolsAgentHost.getNodeForId(nodeId);
+ if (!node) {
+ return {};
+ }
+
+ if (node.nodeType != Node.ELEMENT_NODE) {
return {};
}
var matchedRules = window.getMatchedCSSRules(node, '', false);
@@ -182,8 +221,6 @@ devtools.Injected.prototype.getStyleForId_ = function(node, id) {
};
-
-
/**
* Converts given style into serializable object.
* @param {CSSStyleDeclaration} style Style to serialize.
@@ -224,13 +261,18 @@ devtools.Injected.prototype.serializeStyle_ = function(style, opt_bind) {
/**
* Toggles style with given id on/off.
- * @param {Node} node Node to get prorotypes for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @param {number} styleId Id of style to toggle.
* @param {boolean} enabled Determines value to toggle to,
* @param {string} name Name of the property.
*/
-devtools.Injected.prototype.toggleNodeStyle = function(node, styleId, enabled,
- name) {
+devtools.Injected.prototype.toggleNodeStyle = function(nodeId, styleId,
+ enabled, name) {
+ var node = DevToolsAgentHost.getNodeForId(nodeId);
+ if (!node) {
+ return false;
+ }
+
var style = this.getStyleForId_(node, styleId);
if (!style) {
return false;
@@ -273,14 +315,19 @@ devtools.Injected.prototype.toggleNodeStyle = function(node, styleId, enabled,
/**
* Applies given text to a style.
- * @param {Node} node Node to get prorotypes for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @param {number} styleId Id of style to toggle.
* @param {string} name Style element name.
* @param {string} styleText New style text.
* @return {boolean} True iff style has been edited successfully.
*/
-devtools.Injected.prototype.applyStyleText = function(node, styleId,
+devtools.Injected.prototype.applyStyleText = function(nodeId, styleId,
name, styleText) {
+ var node = DevToolsAgentHost.getNodeForId(nodeId);
+ if (!node) {
+ return false;
+ }
+
var style = this.getStyleForId_(node, styleId);
if (!style) {
return false;
@@ -341,13 +388,18 @@ devtools.Injected.prototype.applyStyleText = function(node, styleId,
/**
* Sets style property with given name to a value.
- * @param {Node} node Node to get prorotypes for.
+ * @param {number} nodeId Id of node to get prorotypes for.
* @param {string} name Style element name.
* @param {string} value Value.
* @return {boolean} True iff style has been edited successfully.
*/
-devtools.Injected.prototype.setStyleProperty = function(node,
+devtools.Injected.prototype.setStyleProperty = function(nodeId,
name, value) {
+ var node = DevToolsAgentHost.getNodeForId(nodeId);
+ if (!node) {
+ return false;
+ }
+
node.style.setProperty(name, value, "");
return true;
};
@@ -461,3 +513,39 @@ devtools.Injected.prototype.getUniqueStyleProperties_ = function(style) {
}
return properties;
};
+
+
+/**
+ * Caches console object for subsequent calls to getConsoleObjectProperties.
+ * @param {Object} obj Object to cache.
+ * @return {Object} console object wrapper.
+ */
+devtools.Injected.prototype.wrapConsoleObject = function(obj) {
+ var type = typeof obj;
+ if (type == 'object' || type == 'function') {
+ var objId = '#consoleobj#' + this.lastCachedConsoleObjectId_++;
+ this.cachedConsoleObjects_[objId] = obj;
+ var result = { ___devtools_id : objId };
+ // Loop below fills dummy object with properties for completion.
+ for (var name in obj) {
+ result[name] = '';
+ }
+ return result;
+ } else {
+ return obj;
+ }
+};
+
+
+/**
+ * Caches console object for subsequent calls to getConsoleObjectProperties.
+ * @param {Object} obj Object to cache.
+ * @return {string} console object id.
+ */
+devtools.Injected.prototype.evaluate = function(expression) {
+ try {
+ return [ this.wrapConsoleObject(window.eval(expression)), false ];
+ } catch (e) {
+ return [ e.toString(), true ];
+ }
+};
diff --git a/webkit/glue/devtools/js/inject_dispatch.js b/webkit/glue/devtools/js/inject_dispatch.js
index c50b123..e02784f 100644
--- a/webkit/glue/devtools/js/inject_dispatch.js
+++ b/webkit/glue/devtools/js/inject_dispatch.js
@@ -21,13 +21,11 @@ var devtools$$obj = new devtools.Injected();
/**
* Main dispatch method, all calls from the host go through this one.
* @param {string} functionName Function to call
- * @param {Node} node Node context of the call.
* @param {string} json_args JSON-serialized call parameters.
* @return {string} JSON-serialized result of the dispatched call.
*/
-function devtools$$dispatch(functionName, node, json_args) {
+function devtools$$dispatch(functionName, json_args) {
var params = JSON.parse(json_args);
- params.splice(0, 0, node);
var result = devtools$$obj[functionName].apply(devtools$$obj, params);
return JSON.stringify(result);
};
@@ -53,14 +51,9 @@ var dispatch = function(method, var_args) {
// Skip first argument since it is serializable.
// Method has index 0, first argument has index 1. Skip both.
for (var i = 2; i < args.length; ++i) {
- var type = typeof args[i];
- if (type == 'object') {
- args[i] = Object.prototype.toString(args[i]);
- } else if (type == 'function') {
- args[i] = args[i].toString();
- }
+ args[i] = devtools$$obj.wrapConsoleObject(args[i]);
}
}
var call = JSON.stringify(args);
- RemoteWebInspector.dispatch(call);
+ DevToolsAgentHost.dispatch(call);
};
diff --git a/webkit/glue/devtools/tools_agent.h b/webkit/glue/devtools/tools_agent.h
index af8b639..88c9a9d 100644
--- a/webkit/glue/devtools/tools_agent.h
+++ b/webkit/glue/devtools/tools_agent.h
@@ -16,13 +16,9 @@
/* Clears Dom Node highlight. */ \
METHOD0(HideDOMNodeHighlight) \
\
- /* Executes JavaScript in the context of the inspected window. */ \
- METHOD2(EvaluateJavaScript, int /* call_id */, String /* JS expression */) \
- \
/* Requests that utility js function is executed with the given args. */ \
- METHOD4(ExecuteUtilityFunction, int /* call_id */, \
- String /* function_name */, int /* context_node_id */, \
- String /* json_args */) \
+ METHOD3(ExecuteUtilityFunction, int /* call_id */, \
+ String /* function_name */, String /* json_args */) \
\
/* Clears cached console messages. */ \
METHOD0(ClearConsoleMessages) \
@@ -41,10 +37,6 @@ DEFINE_RPC_CLASS(ToolsAgent, TOOLS_AGENT_STRUCT)
/* Updates focused node on the client. */ \
METHOD1(UpdateFocusedNode, int /* node_id */) \
\
- /* Response message to EvaluateJavaScript. */ \
- METHOD3(DidEvaluateJavaScript, int /* call_id */, String /* result */, \
- bool /* isException */) \
- \
/* Updates focused node on the client. */ \
METHOD2(FrameNavigate, std::string /* url */, bool /* top_level */) \
\
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) {
diff --git a/webkit/glue/webdevtoolsagent_impl.h b/webkit/glue/webdevtoolsagent_impl.h
index 99fb3b5..60ca0fe 100644
--- a/webkit/glue/webdevtoolsagent_impl.h
+++ b/webkit/glue/webdevtoolsagent_impl.h
@@ -44,11 +44,9 @@ class WebDevToolsAgentImpl
// ToolsAgent implementation.
virtual void HighlightDOMNode(int node_id);
virtual void HideDOMNodeHighlight();
- virtual void EvaluateJavaScript(int call_id, const String& js);
virtual void ExecuteUtilityFunction(
int call_id,
const WebCore::String& function_name,
- int node_id,
const WebCore::String& json_args);
virtual void ClearConsoleMessages();
virtual void GetResourceContent(
@@ -83,6 +81,9 @@ class WebDevToolsAgentImpl
private:
static v8::Handle<v8::Value> JsDispatchOnClient(const v8::Arguments& args);
+ static v8::Handle<v8::Value> JsGetNodeForId(const v8::Arguments& args);
+
+ void InitDevToolsAgentHost();
int host_id_;
WebDevToolsAgentDelegate* delegate_;
@@ -98,7 +99,7 @@ class WebDevToolsAgentImpl
// TODO(pfeldman): This should not be needed once GC styles issue is fixed
// for matching rules.
v8::Persistent<v8::Context> utility_context_;
- OwnPtr<BoundObject> web_inspector_stub_;
+ OwnPtr<BoundObject> devtools_agent_host_;
DISALLOW_COPY_AND_ASSIGN(WebDevToolsAgentImpl);
};