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

Unified Diff: extensions/browser/extension_error.cc

Issue 23624002: Add UI for RuntimeErrors in the ErrorConsole (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_merge
Patch Set: Created 7 years, 3 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: extensions/browser/extension_error.cc
diff --git a/extensions/browser/extension_error.cc b/extensions/browser/extension_error.cc
index 272028e933e0e6ed1bb664e26349f9b4221c2a01..f981414f78b8044e0b0c2e65b8044ce72402e569 100644
--- a/extensions/browser/extension_error.cc
+++ b/extensions/browser/extension_error.cc
@@ -120,6 +120,17 @@ bool ManifestError::IsEqualImpl(const ExtensionError* rhs) const {
return true;
}
+////////////////////////////////////////////////////////////////////////////////
+// RuntimeError
+
+// Static JSON keys.
+const char RuntimeError::kColumnNumberKey[] = "columnNumber";
+const char RuntimeError::kContextUrlKey[] = "contextUrl";
+const char RuntimeError::kFunctionNameKey[] = "functionName";
+const char RuntimeError::kLineNumberKey[] = "lineNumber";
+const char RuntimeError::kStackTraceKey[] = "stackTrace";
+const char RuntimeError::kUrlKey[] = "url";
+
RuntimeError::RuntimeError(bool from_incognito,
const string16& source,
const string16& message,
@@ -140,6 +151,26 @@ RuntimeError::RuntimeError(bool from_incognito,
RuntimeError::~RuntimeError() {
}
+scoped_ptr<DictionaryValue> RuntimeError::ToValue() const {
+ scoped_ptr<DictionaryValue> value = ExtensionError::ToValue();
+ value->SetString(kContextUrlKey, context_url_.spec());
+
+ ListValue* trace_value = new ListValue;
+ for (StackTrace::const_iterator iter = stack_trace_.begin();
+ iter != stack_trace_.end(); ++iter) {
+ DictionaryValue* frame_value = new DictionaryValue;
+ frame_value->SetInteger(kLineNumberKey, iter->line_number);
+ frame_value->SetInteger(kColumnNumberKey, iter->column_number);
+ frame_value->SetString(kUrlKey, iter->source);
+ frame_value->SetString(kFunctionNameKey, iter->function);
+ trace_value->Append(frame_value);
+ }
+
+ value->Set(kStackTraceKey, trace_value);
+
+ return value.Pass();
+}
+
std::string RuntimeError::PrintForTest() const {
std::string result = ExtensionError::PrintForTest() +
"\n Type: RuntimeError"

Powered by Google App Engine
This is Rietveld 408576698