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

Unified Diff: third_party/WebKit/Source/devtools/front_end/product_registry/ProductNameForURL.js

Issue 2696183005: [Devtools] Added Product Registry module in prep for Network Grouping (Closed)
Patch Set: [Devtools] Added Product Registry module in prep for Network Grouping Created 3 years, 10 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: third_party/WebKit/Source/devtools/front_end/product_registry/ProductNameForURL.js
diff --git a/third_party/WebKit/Source/devtools/front_end/product_registry/ProductNameForURL.js b/third_party/WebKit/Source/devtools/front_end/product_registry/ProductNameForURL.js
new file mode 100644
index 0000000000000000000000000000000000000000..d2f807a26109debdfe8f46c0aaff6c5fd5a0b8c8
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/product_registry/ProductNameForURL.js
@@ -0,0 +1,24 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+/**
+ * @param {!Common.ParsedURL} parsedUrl
+ * @return {?string}
+ */
+ProductRegistry.nameForUrl = function(parsedUrl) {
+ // TODO(allada) This should be expanded to allow paths as as well as domain to find a product.
+ var productsByDomain = ProductRegistry._productsByDomain;
+ var domain = parsedUrl.domain();
pfeldman 2017/02/16 01:48:04 data urls don't have domains.
allada 2017/02/16 04:23:30 Done.
+ var domainParts = domain.split('.');
+ while (domainParts.length > 1) {
+ var subDomain = domainParts.join('.');
+ if (subDomain in productsByDomain && (!productsByDomain[subDomain].exact || subDomain === domain))
+ return productsByDomain[subDomain].name;
+ domainParts.shift();
+ }
+ return null;
+};
+
+// See ProductRegistryData.js for actual data.
+/** @type {!Object<string, !{name: string, exact: boolean}>} */
+ProductRegistry._productsByDomain;

Powered by Google App Engine
This is Rietveld 408576698