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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 message_(message), | 50 message_(message), |
51 occurrences_(1u) { | 51 occurrences_(1u) { |
52 } | 52 } |
53 | 53 |
54 ExtensionError::~ExtensionError() { | 54 ExtensionError::~ExtensionError() { |
55 } | 55 } |
56 | 56 |
57 std::string ExtensionError::PrintForTest() const { | 57 std::string ExtensionError::PrintForTest() const { |
58 return std::string("Extension Error:") + | 58 return std::string("Extension Error:") + |
59 "\n OTR: " + std::string(from_incognito_ ? "true" : "false") + | 59 "\n OTR: " + std::string(from_incognito_ ? "true" : "false") + |
60 "\n Level: " + base::IntToString(static_cast<int>(level_)); | 60 "\n Level: " + base::IntToString(static_cast<int>(level_)) + |
61 "\n Source: " + base::UTF16ToUTF8(source_) + | 61 "\n Source: " + base::UTF16ToUTF8(source_) + |
62 "\n Message: " + base::UTF16ToUTF8(message_) + | 62 "\n Message: " + base::UTF16ToUTF8(message_) + |
63 "\n ID: " + extension_id_; | 63 "\n ID: " + extension_id_; |
64 } | 64 } |
65 | 65 |
66 bool ExtensionError::IsEqual(const ExtensionError* rhs) const { | 66 bool ExtensionError::IsEqual(const ExtensionError* rhs) const { |
67 // We don't check |source_| or |level_| here, since they are constant for | 67 // We don't check |source_| or |level_| here, since they are constant for |
68 // manifest errors. Check them in RuntimeError::IsEqualImpl() instead. | 68 // manifest errors. Check them in RuntimeError::IsEqualImpl() instead. |
69 return type_ == rhs->type_ && | 69 return type_ == rhs->type_ && |
70 extension_id_ == rhs->extension_id_ && | 70 extension_id_ == rhs->extension_id_ && |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 // other systems), the source won't match up with the final entry in the stack | 165 // other systems), the source won't match up with the final entry in the stack |
166 // trace. (For instance, in a browser action error, the source is the page - | 166 // trace. (For instance, in a browser action error, the source is the page - |
167 // sometimes the background page - but the error is thrown from the script.) | 167 // sometimes the background page - but the error is thrown from the script.) |
168 // Make the source match the stack trace, since that is more likely the cause | 168 // Make the source match the stack trace, since that is more likely the cause |
169 // of the error. | 169 // of the error. |
170 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) | 170 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) |
171 source_ = stack_trace_[0].source; | 171 source_ = stack_trace_[0].source; |
172 } | 172 } |
173 | 173 |
174 } // namespace extensions | 174 } // namespace extensions |
OLD | NEW |