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

Unified Diff: extensions/browser/extension_error.h

Issue 22938005: Add ErrorConsole UI for Extension Install Warnings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dc_ec_install_warnings
Patch Set: Dan's Created 7 years, 4 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.h
diff --git a/extensions/browser/extension_error.h b/extensions/browser/extension_error.h
index 1cd4a7b69bfd6f6252f0b71bf75786f923fcb684..1b3d7a97d4e00642b5f6793f03ce58de36748936 100644
--- a/extensions/browser/extension_error.h
+++ b/extensions/browser/extension_error.h
@@ -10,21 +10,31 @@
#include "base/compiler_specific.h"
#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
+namespace base {
+class DictionaryValue;
+}
+
namespace extensions {
class ExtensionError {
public:
enum Type {
- MANIFEST_PARSING_ERROR,
- JAVASCRIPT_RUNTIME_ERROR
+ MANIFEST_ERROR,
+ RUNTIME_ERROR
};
virtual ~ExtensionError();
+ // Serializes the ExtensionError into JSON format.
+ virtual scoped_ptr<base::DictionaryValue> ToValue() const;
+
virtual std::string PrintForTest() const;
+ bool IsEqual(const ExtensionError* rhs) const;
+
Type type() const { return type_; }
const base::string16& source() const { return source_; }
const base::string16& message() const { return message_; }
@@ -38,6 +48,8 @@ class ExtensionError {
const base::string16& source,
const base::string16& message);
+ virtual bool IsEqualImpl(const ExtensionError* rhs) const = 0;
+
// Which type of error this is.
Type type_;
// The ID of the extension which caused the error.
@@ -54,18 +66,34 @@ class ExtensionError {
DISALLOW_COPY_AND_ASSIGN(ExtensionError);
};
-class ManifestParsingError : public ExtensionError {
+class ManifestError : public ExtensionError {
public:
- ManifestParsingError(const std::string& extension_id,
- const base::string16& message);
- virtual ~ManifestParsingError();
+ ManifestError(const std::string& extension_id,
+ const base::string16& message,
+ const base::string16& manifest_key,
+ const base::string16& manifest_specific);
+ virtual ~ManifestError();
+
+ virtual scoped_ptr<base::DictionaryValue> ToValue() const OVERRIDE;
virtual std::string PrintForTest() const OVERRIDE;
+
+ const base::string16& manifest_key() const { return manifest_key_; }
+ const base::string16& manifest_specific() const { return manifest_specific_; }
private:
- DISALLOW_COPY_AND_ASSIGN(ManifestParsingError);
+ virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE;
+
+ // If present, this indicates the feature in the manifest which caused the
+ // error.
+ base::string16 manifest_key_;
+ // If present, this is a more-specific location of the error - for instance,
+ // a specific permission which is incorrect, rather than simply "permissions".
+ base::string16 manifest_specific_;
+
+ DISALLOW_COPY_AND_ASSIGN(ManifestError);
};
-class JavascriptRuntimeError : public ExtensionError {
+class RuntimeError : public ExtensionError {
public:
struct StackFrame {
size_t line_number;
@@ -84,15 +112,17 @@ class JavascriptRuntimeError : public ExtensionError {
const base::string16& frame_function /* can be empty */);
~StackFrame();
+
+ bool operator==(const StackFrame& rhs) const;
};
typedef std::vector<StackFrame> StackTrace;
- JavascriptRuntimeError(bool from_incognito,
- const base::string16& source,
- const base::string16& message,
- logging::LogSeverity level,
- const base::string16& details);
- virtual ~JavascriptRuntimeError();
+ RuntimeError(bool from_incognito,
+ const base::string16& source,
+ const base::string16& message,
+ logging::LogSeverity level,
+ const base::string16& details);
+ virtual ~RuntimeError();
virtual std::string PrintForTest() const OVERRIDE;
@@ -102,18 +132,20 @@ class JavascriptRuntimeError : public ExtensionError {
}
const StackTrace& stack_trace() const { return stack_trace_; }
private:
+ virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE;
+
// Parse the JSON |details| passed to the error. This includes a stack trace
// and an execution context url.
void ParseDetails(const base::string16& details);
// Try to determine the ID of the extension. This may be obtained through the
// reported source, or through the execution context url.
- void DetermineExtensionID();
+ void DetermineExtensionId();
logging::LogSeverity level_;
base::string16 execution_context_url_;
StackTrace stack_trace_;
- DISALLOW_COPY_AND_ASSIGN(JavascriptRuntimeError);
+ DISALLOW_COPY_AND_ASSIGN(RuntimeError);
};
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698