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

Unified Diff: Source/core/page/Chrome.cpp

Issue 18822004: Extension Error Piping - Blink: WebKit Side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 5 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/page/Chrome.cpp
diff --git a/Source/core/page/Chrome.cpp b/Source/core/page/Chrome.cpp
index aaafe0ebaca7f7a83b90f6167c48b921af469ab6..a0ef3095ab95446323d43a5dfa7143a4adad6d4a 100644
--- a/Source/core/page/Chrome.cpp
+++ b/Source/core/page/Chrome.cpp
@@ -27,6 +27,8 @@
#include "core/dom/Document.h"
#include "core/html/HTMLInputElement.h"
#include "core/inspector/InspectorInstrumentation.h"
+#include "core/inspector/ScriptCallFrame.h"
+#include "core/inspector/ScriptCallStack.h"
#include "core/page/ChromeClient.h"
#include "core/page/Frame.h"
#include "core/page/FrameTree.h"
@@ -36,6 +38,7 @@
#include "core/platform/ColorChooser.h"
#include "core/platform/DateTimeChooser.h"
#include "core/platform/FileChooser.h"
+#include "core/platform/JSONValues.h"
#include "core/platform/graphics/FloatRect.h"
#include "core/platform/network/DNS.h"
#include "core/rendering/HitTestResult.h"
@@ -440,4 +443,52 @@ void Chrome::notifyPopupOpeningObservers() const
observers[i]->willOpenPopup();
}
+static const char kLineNumberKey[] = "lineNumber";
+static const char kColumnNumberKey[] = "columnNumber";
+static const char kURLKey[] = "url";
+static const char kFunctionNameKey[] = "functionName";
+static const char kStackTraceKey[] = "stackTrace";
+static const char kExecutionContextURLKey[] = "executionContextURL";
+
+static String generateConsoleMessageDetailsImpl(PassRefPtr<JSONArray> stackTrace
+, const String& executionContextURL)
+{
+ RefPtr<JSONObject> details = JSONObject::create();
+ details->setArray(kStackTraceKey, stackTrace);
+ details->setString(kExecutionContextURLKey, executionContextURL);
+ return details->toJSONString();
+}
+
+String Chrome::generateConsoleMessageDetails(size_t lineNumber, size_t columnNumber, const String& sourceURL, const String& functionName, const String& executionContextURL)
abarth-chromium 2013/07/19 03:04:07 This isn't the right file for this code. Chrome.c
+{
+ RefPtr<JSONObject> stackFrame = JSONObject::create();
+ stackFrame->setNumber(kLineNumberKey, lineNumber);
pfeldman 2013/08/07 13:30:21 Why another format? You should either pass stack t
+ stackFrame->setNumber(kColumnNumberKey, columnNumber);
+ stackFrame->setString(kURLKey, sourceURL);
+ stackFrame->setString(kFunctionNameKey, functionName);
+
+ RefPtr<JSONArray> simpleStackTrace = JSONArray::create();
+ simpleStackTrace->pushObject(stackFrame);
+
+ return generateConsoleMessageDetailsImpl(simpleStackTrace, executionContextURL);
+}
+
+String Chrome::generateConsoleMessageDetails(PassRefPtr<ScriptCallStack> callStack, const String& executionContextURL)
+{
+ RefPtr<JSONArray> stackTrace = JSONArray::create();
+ for (size_t i = 0; i < callStack->size(); ++i) {
+ const ScriptCallFrame& frame = callStack->at(i);
+ RefPtr<JSONObject> stackFrame = JSONObject::create();
+
+ stackFrame->setNumber(kLineNumberKey, frame.lineNumber());
+ stackFrame->setNumber(kColumnNumberKey, frame.columnNumber());
+ stackFrame->setString(kURLKey, frame.sourceURL());
+ stackFrame->setString(kFunctionNameKey, frame.functionName());
+
+ stackTrace->pushObject(stackFrame);
+ }
+
+ return generateConsoleMessageDetailsImpl(stackTrace, executionContextURL);
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698