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

Side by Side 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: License Created 7 years, 3 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 unified diff | Download patch
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/extension_error.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_ERROR_H_
6 #define EXTENSIONS_BROWSER_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/memory/scoped_ptr.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "extensions/common/stack_frame.h" 15 #include "extensions/common/stack_frame.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
18 namespace base {
19 class DictionaryValue;
20 }
21
17 namespace extensions { 22 namespace extensions {
18 23
19 class ExtensionError { 24 class ExtensionError {
20 public: 25 public:
21 enum Type { 26 enum Type {
22 MANIFEST_ERROR, 27 MANIFEST_ERROR,
23 RUNTIME_ERROR 28 RUNTIME_ERROR
24 }; 29 };
25 30
26 virtual ~ExtensionError(); 31 virtual ~ExtensionError();
27 32
33 // Serializes the ExtensionError into JSON format.
34 virtual scoped_ptr<base::DictionaryValue> ToValue() const;
35
28 virtual std::string PrintForTest() const; 36 virtual std::string PrintForTest() const;
29 37
30 // Return true if this error and |rhs| are considered equal, and should be 38 // Return true if this error and |rhs| are considered equal, and should be
31 // grouped together. 39 // grouped together.
32 bool IsEqual(const ExtensionError* rhs) const; 40 bool IsEqual(const ExtensionError* rhs) const;
33 41
34 Type type() const { return type_; } 42 Type type() const { return type_; }
35 const std::string& extension_id() const { return extension_id_; } 43 const std::string& extension_id() const { return extension_id_; }
36 bool from_incognito() const { return from_incognito_; } 44 bool from_incognito() const { return from_incognito_; }
37 logging::LogSeverity level() const { return level_; } 45 logging::LogSeverity level() const { return level_; }
38 const base::string16& source() const { return source_; } 46 const base::string16& source() const { return source_; }
39 const base::string16& message() const { return message_; } 47 const base::string16& message() const { return message_; }
40 size_t occurrences() const { return occurrences_; } 48 size_t occurrences() const { return occurrences_; }
41 void set_occurrences(size_t occurrences) { occurrences_ = occurrences; } 49 void set_occurrences(size_t occurrences) { occurrences_ = occurrences; }
42 50
51 // Keys used for retrieving JSON values.
52 static const char kExtensionIdKey[];
53 static const char kFromIncognitoKey[];
54 static const char kLevelKey[];
55 static const char kMessageKey[];
56 static const char kSourceKey[];
57 static const char kTypeKey[];
58
43 protected: 59 protected:
44 ExtensionError(Type type, 60 ExtensionError(Type type,
45 const std::string& extension_id, 61 const std::string& extension_id,
46 bool from_incognito, 62 bool from_incognito,
47 logging::LogSeverity level, 63 logging::LogSeverity level,
48 const base::string16& source, 64 const base::string16& source,
49 const base::string16& message); 65 const base::string16& message);
50 66
51 virtual bool IsEqualImpl(const ExtensionError* rhs) const = 0; 67 virtual bool IsEqualImpl(const ExtensionError* rhs) const = 0;
52 68
(...skipping 18 matching lines...) Expand all
71 }; 87 };
72 88
73 class ManifestError : public ExtensionError { 89 class ManifestError : public ExtensionError {
74 public: 90 public:
75 ManifestError(const std::string& extension_id, 91 ManifestError(const std::string& extension_id,
76 const base::string16& message, 92 const base::string16& message,
77 const base::string16& manifest_key, 93 const base::string16& manifest_key,
78 const base::string16& manifest_specific); 94 const base::string16& manifest_specific);
79 virtual ~ManifestError(); 95 virtual ~ManifestError();
80 96
97 virtual scoped_ptr<base::DictionaryValue> ToValue() const OVERRIDE;
98
81 virtual std::string PrintForTest() const OVERRIDE; 99 virtual std::string PrintForTest() const OVERRIDE;
82 100
83 const base::string16& manifest_key() const { return manifest_key_; } 101 const base::string16& manifest_key() const { return manifest_key_; }
84 const base::string16& manifest_specific() const { return manifest_specific_; } 102 const base::string16& manifest_specific() const { return manifest_specific_; }
103
104 // Keys used for retrieving JSON values.
105 static const char kManifestKeyKey[];
106 static const char kManifestSpecificKey[];
107
85 private: 108 private:
86 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE; 109 virtual bool IsEqualImpl(const ExtensionError* rhs) const OVERRIDE;
87 110
88 // If present, this indicates the feature in the manifest which caused the 111 // If present, this indicates the feature in the manifest which caused the
89 // error. 112 // error.
90 base::string16 manifest_key_; 113 base::string16 manifest_key_;
91 // If present, this is a more-specific location of the error - for instance, 114 // If present, this is a more-specific location of the error - for instance,
92 // a specific permission which is incorrect, rather than simply "permissions". 115 // a specific permission which is incorrect, rather than simply "permissions".
93 base::string16 manifest_specific_; 116 base::string16 manifest_specific_;
94 117
(...skipping 24 matching lines...) Expand all
119 142
120 GURL context_url_; 143 GURL context_url_;
121 StackTrace stack_trace_; 144 StackTrace stack_trace_;
122 145
123 DISALLOW_COPY_AND_ASSIGN(RuntimeError); 146 DISALLOW_COPY_AND_ASSIGN(RuntimeError);
124 }; 147 };
125 148
126 } // namespace extensions 149 } // namespace extensions
127 150
128 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_ 151 #endif // EXTENSIONS_BROWSER_EXTENSION_ERROR_H_
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | extensions/browser/extension_error.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698