Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1371)

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 1072523002: Devtools: allow multiple custom formatters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Test added Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index b50f9b2b9e5a1905358d4a9376bbff901cd716e9..e7677586bcf4d6dd8e86fde3f48c667c25df44ca 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -1306,21 +1306,28 @@ InjectedScript.RemoteObject.prototype = {
_customPreview: function(object, objectGroupName)
{
try {
- var formatter = inspectedWindow["devtoolsFormatter"];
- if (!formatter)
+ var formatters = inspectedWindow["devtoolsFormatters"];
+ if (!formatters || !isArrayLike(formatters))
return null;
- var formatted = formatter.header(object);
- if (!formatted)
- return null;
+ for (var i = 0; i < formatters.length; ++i) {
+ try {
+ var formatted = formatters[i].header(object);
+ if (!formatted)
+ continue;
- var hasBody = formatter.hasBody(object);
- injectedScript._substituteObjectTagsInCustomPreview(objectGroupName, formatted);
- return {header: JSON.stringify(formatted), hasBody: !!hasBody};
+ var hasBody = formatters[i].hasBody(object);
+ injectedScript._substituteObjectTagsInCustomPreview(objectGroupName, formatted);
+ var formatterObjectId = injectedScript._bind(formatters[i], objectGroupName);
+ return {header: JSON.stringify(formatted), hasBody: !!hasBody, formatterObjectId: formatterObjectId};
+ } catch (e) {
+ inspectedWindow.console.error("Custom Formatter Failed: " + e);
+ }
+ }
} catch (e) {
inspectedWindow.console.error("Custom Formatter Failed: " + e);
- return null;
}
+ return null;
},
/**

Powered by Google App Engine
This is Rietveld 408576698