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

Unified Diff: third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js

Issue 2796703002: [Devtools] Execution context in console shows product experiment (Closed)
Patch Set: changes Created 3 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: third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
diff --git a/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js b/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
new file mode 100644
index 0000000000000000000000000000000000000000..bbd1a2953265c33107223bc2aa6a16346c4624ad
--- /dev/null
+++ b/third_party/WebKit/Source/devtools/front_end/console_frame_product_lookup/ConsoleFrameProductLookup.js
@@ -0,0 +1,45 @@
+// 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.
+/**
+ * @implements {Console.ConsoleFrameNameLookupInterface}
+ */
+ConsoleFrameProductLookup.ProductLookup = class {
+ /**
+ * @override
+ * @param {!SDK.ResourceTreeFrame} frame
+ * @return {?string}
+ */
+ nameForFrame(frame) {
+ var name;
+ if (frame.url)
+ name = ProductRegistry.nameForUrl(new Common.ParsedURL(frame.url));
+ if (name)
+ return name;
+ // We are not caching the frame url result because it may change.
+ var symbol = ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol;
+ if (symbol in frame)
+ return frame[symbol];
+ frame[symbol] = ConsoleFrameProductLookup.ProductLookup._lookupFrameStacktraceName(frame);
+ return frame[symbol];
+ }
+
+ /**
+ * @param {!SDK.ResourceTreeFrame} frame
+ * @return {?string}
+ */
+ static _lookupFrameStacktraceName(frame) {
+ var name;
+ for (var stackTrace = frame.creationStackTrace(); stackTrace; stackTrace = frame.parent) {
+ for (var callFrame of stackTrace.callFrames) {
+ if (callFrame.url)
+ name = ProductRegistry.nameForUrl(new Common.ParsedURL(callFrame.url));
+ if (name)
+ return name;
+ }
+ }
+ return null;
+ }
+};
+
+ConsoleFrameProductLookup.ProductLookup._consoleProductFrameNameSymbol = Symbol('ConsoleProductFrameName');

Powered by Google App Engine
This is Rietveld 408576698