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

Unified Diff: extensions/browser/extension_error.cc

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/extension_error.h ('k') | extensions/browser/manifest_highlighter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/extension_error.cc
diff --git a/extensions/browser/extension_error.cc b/extensions/browser/extension_error.cc
index b372885e2dd67676ac773b1093cae143460d8f04..272028e933e0e6ed1bb664e26349f9b4221c2a01 100644
--- a/extensions/browser/extension_error.cc
+++ b/extensions/browser/extension_error.cc
@@ -11,30 +11,20 @@
#include "url/gurl.h"
using base::string16;
+using base::DictionaryValue;
namespace extensions {
-namespace {
-
-const char kLineNumberKey[] = "lineNumber";
-const char kColumnNumberKey[] = "columnNumber";
-const char kURLKey[] = "url";
-const char kFunctionNameKey[] = "functionName";
-const char kExecutionContextURLKey[] = "executionContextURL";
-const char kStackTraceKey[] = "stackTrace";
-
-// Try to retrieve an extension ID from a |url|. On success, returns true and
-// populates |extension_id| with the ID. On failure, returns false and leaves
-// extension_id untouched.
-bool GetExtensionIDFromGURL(const GURL& url, std::string* extension_id) {
- if (url.SchemeIs(kExtensionScheme)) {
- *extension_id = url.host();
- return true;
- }
- return false;
-}
+////////////////////////////////////////////////////////////////////////////////
+// ExtensionError
-} // namespace
+// Static JSON keys.
+const char ExtensionError::kExtensionIdKey[] = "extensionId";
+const char ExtensionError::kFromIncognitoKey[] = "fromIncognito";
+const char ExtensionError::kLevelKey[] = "level";
+const char ExtensionError::kMessageKey[] = "message";
+const char ExtensionError::kSourceKey[] = "source";
+const char ExtensionError::kTypeKey[] = "type";
ExtensionError::ExtensionError(Type type,
const std::string& extension_id,
@@ -54,6 +44,20 @@ ExtensionError::ExtensionError(Type type,
ExtensionError::~ExtensionError() {
}
+scoped_ptr<DictionaryValue> ExtensionError::ToValue() const {
+ // TODO(rdevlin.cronin): Use ValueBuilder when it's moved from
+ // chrome/common/extensions.
+ scoped_ptr<DictionaryValue> value(new DictionaryValue);
+ value->SetInteger(kTypeKey, static_cast<int>(type_));
+ value->SetString(kExtensionIdKey, extension_id_);
+ value->SetBoolean(kFromIncognitoKey, from_incognito_);
+ value->SetInteger(kLevelKey, static_cast<int>(level_));
+ value->SetString(kSourceKey, source_);
+ value->SetString(kMessageKey, message_);
+
+ return value.Pass();
+}
+
std::string ExtensionError::PrintForTest() const {
return std::string("Extension Error:") +
"\n OTR: " + std::string(from_incognito_ ? "true" : "false") +
@@ -72,6 +76,13 @@ bool ExtensionError::IsEqual(const ExtensionError* rhs) const {
IsEqualImpl(rhs);
}
+////////////////////////////////////////////////////////////////////////////////
+// ManifestError
+
+// Static JSON keys.
+const char ManifestError::kManifestKeyKey[] = "manifestKey";
+const char ManifestError::kManifestSpecificKey[] = "manifestSpecific";
+
ManifestError::ManifestError(const std::string& extension_id,
const string16& message,
const string16& manifest_key,
@@ -89,6 +100,15 @@ ManifestError::ManifestError(const std::string& extension_id,
ManifestError::~ManifestError() {
}
+scoped_ptr<DictionaryValue> ManifestError::ToValue() const {
+ scoped_ptr<DictionaryValue> value = ExtensionError::ToValue();
+ if (!manifest_key_.empty())
+ value->SetString(kManifestKeyKey, manifest_key_);
+ if (!manifest_specific_.empty())
+ value->SetString(kManifestSpecificKey, manifest_specific_);
+ return value.Pass();
+}
+
std::string ManifestError::PrintForTest() const {
return ExtensionError::PrintForTest() +
"\n Type: ManifestError";
« no previous file with comments | « extensions/browser/extension_error.h ('k') | extensions/browser/manifest_highlighter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698