Commit 9da9ab7f authored by alph@chromium.org's avatar alph@chromium.org

DevTools: [timeline tree view] expose human-readable names for chrome extensions

BUG=521224
R=caseq

Review URL: https://codereview.chromium.org/1296453003

git-svn-id: svn://svn.chromium.org/blink/trunk@200780 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e95fe532
...@@ -183,34 +183,38 @@ WebInspector.TimelineTreeView.prototype = { ...@@ -183,34 +183,38 @@ WebInspector.TimelineTreeView.prototype = {
} }
/** /**
* @param {boolean} groupSubdomains
* @param {!WebInspector.TimelineModel.ProfileTreeNode} node * @param {!WebInspector.TimelineModel.ProfileTreeNode} node
* @return {string} * @return {string}
*/ */
function groupByDomain(node) function groupByDomain(groupSubdomains, node)
{
var parsedURL = (WebInspector.TimelineTreeView.eventURL(node.event) || "").asParsedURL();
return parsedURL && parsedURL.host || "";
}
/**
* @param {!WebInspector.TimelineModel.ProfileTreeNode} node
* @return {string}
*/
function groupByDomainSecondLevel(node)
{ {
var parsedURL = (WebInspector.TimelineTreeView.eventURL(node.event) || "").asParsedURL(); var parsedURL = (WebInspector.TimelineTreeView.eventURL(node.event) || "").asParsedURL();
if (!parsedURL) if (!parsedURL)
return ""; return "";
if (parsedURL.scheme === "chrome-extension") {
var url = parsedURL.scheme + "://" + parsedURL.host;
var displayName = executionContextNamesByOrigin.get(url);
return displayName ? WebInspector.UIString("Chrome Extension: %s", displayName) : url;
}
if (!groupSubdomains)
return parsedURL.host;
if (/^[.0-9]+$/.test(parsedURL.host)) if (/^[.0-9]+$/.test(parsedURL.host))
return parsedURL.host; return parsedURL.host;
var domainMatch = /([^.]*\.)?[^.]*$/.exec(parsedURL.host); var domainMatch = /([^.]*\.)?[^.]*$/.exec(parsedURL.host);
return domainMatch && domainMatch[0] || ""; return domainMatch && domainMatch[0] || "";
} }
var executionContextNamesByOrigin = new Map();
var mainTarget = WebInspector.targetManager.mainTarget();
if (mainTarget) {
for (var context of mainTarget.runtimeModel.executionContexts())
executionContextNamesByOrigin.set(context.origin, context.name);
}
var groupByMap = /** @type {!Map<!WebInspector.TimelineTreeView.GroupBy,?function(!WebInspector.TimelineModel.ProfileTreeNode):string>} */ (new Map([ var groupByMap = /** @type {!Map<!WebInspector.TimelineTreeView.GroupBy,?function(!WebInspector.TimelineModel.ProfileTreeNode):string>} */ (new Map([
[WebInspector.TimelineTreeView.GroupBy.None, null], [WebInspector.TimelineTreeView.GroupBy.None, null],
[WebInspector.TimelineTreeView.GroupBy.Domain, groupByDomain], [WebInspector.TimelineTreeView.GroupBy.Domain, groupByDomain.bind(null, false)],
[WebInspector.TimelineTreeView.GroupBy.DomainSecondLevel, groupByDomainSecondLevel], [WebInspector.TimelineTreeView.GroupBy.DomainSecondLevel, groupByDomain.bind(null, true)],
[WebInspector.TimelineTreeView.GroupBy.URL, groupByURL] [WebInspector.TimelineTreeView.GroupBy.URL, groupByURL]
])); ]));
return groupByMap.get(this._groupBySetting.get()) || null; return groupByMap.get(this._groupBySetting.get()) || null;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment