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" |
11 #include "url/gurl.h" | 11 #include "url/gurl.h" |
12 | 12 |
13 using base::string16; | |
14 using base::DictionaryValue; | 13 using base::DictionaryValue; |
15 | 14 |
16 namespace extensions { | 15 namespace extensions { |
17 | 16 |
18 //////////////////////////////////////////////////////////////////////////////// | 17 //////////////////////////////////////////////////////////////////////////////// |
19 // ExtensionError | 18 // ExtensionError |
20 | 19 |
21 // Static JSON keys. | 20 // Static JSON keys. |
22 const char ExtensionError::kExtensionIdKey[] = "extensionId"; | 21 const char ExtensionError::kExtensionIdKey[] = "extensionId"; |
23 const char ExtensionError::kFromIncognitoKey[] = "fromIncognito"; | 22 const char ExtensionError::kFromIncognitoKey[] = "fromIncognito"; |
24 const char ExtensionError::kLevelKey[] = "level"; | 23 const char ExtensionError::kLevelKey[] = "level"; |
25 const char ExtensionError::kMessageKey[] = "message"; | 24 const char ExtensionError::kMessageKey[] = "message"; |
26 const char ExtensionError::kSourceKey[] = "source"; | 25 const char ExtensionError::kSourceKey[] = "source"; |
27 const char ExtensionError::kTypeKey[] = "type"; | 26 const char ExtensionError::kTypeKey[] = "type"; |
28 | 27 |
29 ExtensionError::ExtensionError(Type type, | 28 ExtensionError::ExtensionError(Type type, |
30 const std::string& extension_id, | 29 const std::string& extension_id, |
31 bool from_incognito, | 30 bool from_incognito, |
32 logging::LogSeverity level, | 31 logging::LogSeverity level, |
33 const string16& source, | 32 const base::string16& source, |
34 const string16& message) | 33 const base::string16& message) |
35 : type_(type), | 34 : type_(type), |
36 extension_id_(extension_id), | 35 extension_id_(extension_id), |
37 from_incognito_(from_incognito), | 36 from_incognito_(from_incognito), |
38 level_(level), | 37 level_(level), |
39 source_(source), | 38 source_(source), |
40 message_(message), | 39 message_(message), |
41 occurrences_(1u) { | 40 occurrences_(1u) { |
42 } | 41 } |
43 | 42 |
44 ExtensionError::~ExtensionError() { | 43 ExtensionError::~ExtensionError() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 } | 76 } |
78 | 77 |
79 //////////////////////////////////////////////////////////////////////////////// | 78 //////////////////////////////////////////////////////////////////////////////// |
80 // ManifestError | 79 // ManifestError |
81 | 80 |
82 // Static JSON keys. | 81 // Static JSON keys. |
83 const char ManifestError::kManifestKeyKey[] = "manifestKey"; | 82 const char ManifestError::kManifestKeyKey[] = "manifestKey"; |
84 const char ManifestError::kManifestSpecificKey[] = "manifestSpecific"; | 83 const char ManifestError::kManifestSpecificKey[] = "manifestSpecific"; |
85 | 84 |
86 ManifestError::ManifestError(const std::string& extension_id, | 85 ManifestError::ManifestError(const std::string& extension_id, |
87 const string16& message, | 86 const base::string16& message, |
88 const string16& manifest_key, | 87 const base::string16& manifest_key, |
89 const string16& manifest_specific) | 88 const base::string16& manifest_specific) |
90 : ExtensionError(ExtensionError::MANIFEST_ERROR, | 89 : ExtensionError(ExtensionError::MANIFEST_ERROR, |
91 extension_id, | 90 extension_id, |
92 false, // extensions can't be installed while incognito. | 91 false, // extensions can't be installed while incognito. |
93 logging::LOG_WARNING, // All manifest errors are warnings. | 92 logging::LOG_WARNING, // All manifest errors are warnings. |
94 base::FilePath(kManifestFilename).AsUTF16Unsafe(), | 93 base::FilePath(kManifestFilename).AsUTF16Unsafe(), |
95 message), | 94 message), |
96 manifest_key_(manifest_key), | 95 manifest_key_(manifest_key), |
97 manifest_specific_(manifest_specific) { | 96 manifest_specific_(manifest_specific) { |
98 } | 97 } |
99 | 98 |
(...skipping 28 matching lines...) Expand all Loading... |
128 const char RuntimeError::kContextUrlKey[] = "contextUrl"; | 127 const char RuntimeError::kContextUrlKey[] = "contextUrl"; |
129 const char RuntimeError::kFunctionNameKey[] = "functionName"; | 128 const char RuntimeError::kFunctionNameKey[] = "functionName"; |
130 const char RuntimeError::kLineNumberKey[] = "lineNumber"; | 129 const char RuntimeError::kLineNumberKey[] = "lineNumber"; |
131 const char RuntimeError::kStackTraceKey[] = "stackTrace"; | 130 const char RuntimeError::kStackTraceKey[] = "stackTrace"; |
132 const char RuntimeError::kUrlKey[] = "url"; | 131 const char RuntimeError::kUrlKey[] = "url"; |
133 const char RuntimeError::kRenderProcessIdKey[] = "renderProcessId"; | 132 const char RuntimeError::kRenderProcessIdKey[] = "renderProcessId"; |
134 const char RuntimeError::kRenderViewIdKey[] = "renderViewId"; | 133 const char RuntimeError::kRenderViewIdKey[] = "renderViewId"; |
135 | 134 |
136 RuntimeError::RuntimeError(const std::string& extension_id, | 135 RuntimeError::RuntimeError(const std::string& extension_id, |
137 bool from_incognito, | 136 bool from_incognito, |
138 const string16& source, | 137 const base::string16& source, |
139 const string16& message, | 138 const base::string16& message, |
140 const StackTrace& stack_trace, | 139 const StackTrace& stack_trace, |
141 const GURL& context_url, | 140 const GURL& context_url, |
142 logging::LogSeverity level, | 141 logging::LogSeverity level, |
143 int render_view_id, | 142 int render_view_id, |
144 int render_process_id) | 143 int render_process_id) |
145 : ExtensionError(ExtensionError::RUNTIME_ERROR, | 144 : ExtensionError(ExtensionError::RUNTIME_ERROR, |
146 !extension_id.empty() ? extension_id : GURL(source).host(), | 145 !extension_id.empty() ? extension_id : GURL(source).host(), |
147 from_incognito, | 146 from_incognito, |
148 level, | 147 level, |
149 source, | 148 source, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 // other systems), the source won't match up with the final entry in the stack | 224 // other systems), the source won't match up with the final entry in the stack |
226 // trace. (For instance, in a browser action error, the source is the page - | 225 // trace. (For instance, in a browser action error, the source is the page - |
227 // sometimes the background page - but the error is thrown from the script.) | 226 // sometimes the background page - but the error is thrown from the script.) |
228 // Make the source match the stack trace, since that is more likely the cause | 227 // Make the source match the stack trace, since that is more likely the cause |
229 // of the error. | 228 // of the error. |
230 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) | 229 if (!stack_trace_.empty() && source_ != stack_trace_[0].source) |
231 source_ = stack_trace_[0].source; | 230 source_ = stack_trace_[0].source; |
232 } | 231 } |
233 | 232 |
234 } // namespace extensions | 233 } // namespace extensions |
OLD | NEW |