| 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 #ifndef CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_EXTENSION_ERROR_H_ | 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_EXTENSION_ERROR_H_ | 6 #define EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 | 14 |
| 15 namespace extensions { | 15 namespace extensions { |
| 16 | 16 |
| 17 class ExtensionError { | 17 class ExtensionError { |
| 18 public: | 18 public: |
| 19 enum Type { | 19 enum Type { |
| 20 MANIFEST_PARSING_ERROR, | 20 MANIFEST_PARSING_ERROR, |
| 21 JAVASCRIPT_RUNTIME_ERROR | 21 JAVASCRIPT_RUNTIME_ERROR |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 virtual ~ExtensionError(); | 24 virtual ~ExtensionError(); |
| 25 | 25 |
| 26 virtual std::string PrintForTest() const; | 26 virtual std::string PrintForTest() const; |
| 27 | 27 |
| 28 Type type() const { return type_; } | 28 Type type() const { return type_; } |
| 29 const base::string16& source() const { return source_; } | 29 const base::string16& source() const { return source_; } |
| 30 const base::string16& message() const { return message_; } | 30 const base::string16& message() const { return message_; } |
| 31 const std::string& extension_id() const { return extension_id_; } | 31 const std::string& extension_id() const { return extension_id_; } |
| 32 bool from_incognito() const { return from_incognito_; } | 32 bool from_incognito() const { return from_incognito_; } |
| 33 | 33 |
| 34 protected: | 34 protected: |
| 35 ExtensionError(Type type, | 35 ExtensionError(Type type, |
| 36 const std::string& extension_id, |
| 36 bool from_incognito, | 37 bool from_incognito, |
| 37 const base::string16& source, | 38 const base::string16& source, |
| 38 const base::string16& message); | 39 const base::string16& message); |
| 39 | 40 |
| 40 // Which type of error this is. | 41 // Which type of error this is. |
| 41 Type type_; | 42 Type type_; |
| 43 // The ID of the extension which caused the error. |
| 44 std::string extension_id_; |
| 42 // Whether or not the error was caused while incognito. | 45 // Whether or not the error was caused while incognito. |
| 43 bool from_incognito_; | 46 bool from_incognito_; |
| 44 // The source for the error; this can be a script, web page, or manifest file. | 47 // The source for the error; this can be a script, web page, or manifest file. |
| 45 // This is stored as a string (rather than a url) since it can be a Chrome | 48 // This is stored as a string (rather than a url) since it can be a Chrome |
| 46 // script file (e.g., event_bindings.js). | 49 // script file (e.g., event_bindings.js). |
| 47 base::string16 source_; | 50 base::string16 source_; |
| 48 // The error message itself. | 51 // The error message itself. |
| 49 base::string16 message_; | 52 base::string16 message_; |
| 50 // The ID of the extension which caused the error. This may be absent, since | |
| 51 // we can't always know the id (such as when a manifest fails to parse). | |
| 52 std::string extension_id_; | |
| 53 | 53 |
| 54 DISALLOW_COPY_AND_ASSIGN(ExtensionError); | 54 DISALLOW_COPY_AND_ASSIGN(ExtensionError); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class ManifestParsingError : public ExtensionError { | 57 class ManifestParsingError : public ExtensionError { |
| 58 public: | 58 public: |
| 59 ManifestParsingError(bool from_incognito, | 59 ManifestParsingError(const std::string& extension_id, |
| 60 const base::string16& source, | 60 const base::string16& message); |
| 61 const base::string16& message, | |
| 62 size_t line_number); | |
| 63 virtual ~ManifestParsingError(); | 61 virtual ~ManifestParsingError(); |
| 64 | 62 |
| 65 virtual std::string PrintForTest() const OVERRIDE; | 63 virtual std::string PrintForTest() const OVERRIDE; |
| 66 | |
| 67 size_t line_number() const { return line_number_; } | |
| 68 private: | 64 private: |
| 69 size_t line_number_; | |
| 70 | |
| 71 DISALLOW_COPY_AND_ASSIGN(ManifestParsingError); | 65 DISALLOW_COPY_AND_ASSIGN(ManifestParsingError); |
| 72 }; | 66 }; |
| 73 | 67 |
| 74 class JavascriptRuntimeError : public ExtensionError { | 68 class JavascriptRuntimeError : public ExtensionError { |
| 75 public: | 69 public: |
| 76 struct StackFrame { | 70 struct StackFrame { |
| 77 size_t line_number; | 71 size_t line_number; |
| 78 size_t column_number; | 72 size_t column_number; |
| 79 // This is stored as a string (rather than a url) since it can be a | 73 // This is stored as a string (rather than a url) since it can be a |
| 80 // Chrome script file (e.g., event_bindings.js). | 74 // Chrome script file (e.g., event_bindings.js). |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 111 |
| 118 logging::LogSeverity level_; | 112 logging::LogSeverity level_; |
| 119 base::string16 execution_context_url_; | 113 base::string16 execution_context_url_; |
| 120 StackTrace stack_trace_; | 114 StackTrace stack_trace_; |
| 121 | 115 |
| 122 DISALLOW_COPY_AND_ASSIGN(JavascriptRuntimeError); | 116 DISALLOW_COPY_AND_ASSIGN(JavascriptRuntimeError); |
| 123 }; | 117 }; |
| 124 | 118 |
| 125 } // namespace extensions | 119 } // namespace extensions |
| 126 | 120 |
| 127 #endif // CHROME_BROWSER_EXTENSIONS_ERROR_CONSOLE_EXTENSION_ERROR_H_ | 121 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ |
| OLD | NEW |