| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/extension_error.h" | 5 #include "extensions/browser/extension_error.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "extensions/common/constants.h" | 10 #include "extensions/common/constants.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 stack_trace_(stack_trace), | 151 stack_trace_(stack_trace), |
| 152 render_view_id_(render_view_id), | 152 render_view_id_(render_view_id), |
| 153 render_process_id_(render_process_id) { | 153 render_process_id_(render_process_id) { |
| 154 CleanUpInit(); | 154 CleanUpInit(); |
| 155 } | 155 } |
| 156 | 156 |
| 157 RuntimeError::~RuntimeError() { | 157 RuntimeError::~RuntimeError() { |
| 158 } | 158 } |
| 159 | 159 |
| 160 scoped_ptr<DictionaryValue> RuntimeError::ToValue() const { | 160 scoped_ptr<DictionaryValue> RuntimeError::ToValue() const { |
| 161 // The items which are to be written into value are also described in |
| 162 // chrome/browser/resources/extensions/extension_error_overlay.js in @typedef |
| 163 // for RuntimeError and StackTrace. Please update them whenever you add or |
| 164 // remove any keys here. |
| 161 scoped_ptr<DictionaryValue> value = ExtensionError::ToValue(); | 165 scoped_ptr<DictionaryValue> value = ExtensionError::ToValue(); |
| 162 value->SetString(kContextUrlKey, context_url_.spec()); | 166 value->SetString(kContextUrlKey, context_url_.spec()); |
| 163 value->SetInteger(kRenderViewIdKey, render_view_id_); | 167 value->SetInteger(kRenderViewIdKey, render_view_id_); |
| 164 value->SetInteger(kRenderProcessIdKey, render_process_id_); | 168 value->SetInteger(kRenderProcessIdKey, render_process_id_); |
| 165 | 169 |
| 166 base::ListValue* trace_value = new base::ListValue; | 170 base::ListValue* trace_value = new base::ListValue; |
| 167 for (StackTrace::const_iterator iter = stack_trace_.begin(); | 171 for (StackTrace::const_iterator iter = stack_trace_.begin(); |
| 168 iter != stack_trace_.end(); ++iter) { | 172 iter != stack_trace_.end(); ++iter) { |
| 169 DictionaryValue* frame_value = new DictionaryValue; | 173 DictionaryValue* frame_value = new DictionaryValue; |
| 170 frame_value->SetInteger(kLineNumberKey, iter->line_number); | 174 frame_value->SetInteger(kLineNumberKey, iter->line_number); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // other systems), the source won't match up with the final entry in the stack | 228 // other systems), the source won't match up with the final entry in the stack |
| 225 // trace. (For instance, in a browser action error, the source is the page - | 229 // trace. (For instance, in a browser action error, the source is the page - |
| 226 // sometimes the background page - but the error is thrown from the script.) | 230 // sometimes the background page - but the error is thrown from the script.) |
| 227 // Make the source match the stack trace, since that is more likely the cause | 231 // Make the source match the stack trace, since that is more likely the cause |
| 228 // of the error. | 232 // of the error. |
| 229 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) | 233 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) |
| 230 source_ = stack_trace_[0].source; | 234 source_ = stack_trace_[0].source; |
| 231 } | 235 } |
| 232 | 236 |
| 233 } // namespace extensions | 237 } // namespace extensions |
| OLD | NEW |