diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 21:08:30 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-03 21:08:30 +0000 |
commit | b191e2d3d6f5040a766ceb4c5d136a1a5edf1ad0 (patch) | |
tree | 89690fee087dbda21d3da91acadf8fb7db31065b /extensions | |
parent | fb53f2673d110adf08933a86d6371c07d44d9dad (diff) | |
download | chromium_src-b191e2d3d6f5040a766ceb4c5d136a1a5edf1ad0.zip chromium_src-b191e2d3d6f5040a766ceb4c5d136a1a5edf1ad0.tar.gz chromium_src-b191e2d3d6f5040a766ceb4c5d136a1a5edf1ad0.tar.bz2 |
Catch ManifestErrors with ErrorConsole; Add Browsertests
Add backend support for catching manifest install warnings with the ErrorConsole. Forked from https://codereview.chromium.org/22938005 in order to reduce size and separate backend and frontend CLs.
BUG=21734
Review URL: https://chromiumcodereview.appspot.com/23684015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/extension_error.cc | 8 | ||||
-rw-r--r-- | extensions/browser/extension_error.h | 14 | ||||
-rw-r--r-- | extensions/common/manifest.cc | 4 | ||||
-rw-r--r-- | extensions/common/manifest_constants.cc | 8 | ||||
-rw-r--r-- | extensions/common/manifest_constants.h | 5 |
5 files changed, 34 insertions, 5 deletions
diff --git a/extensions/browser/extension_error.cc b/extensions/browser/extension_error.cc index 9b1e95f..b372885 100644 --- a/extensions/browser/extension_error.cc +++ b/extensions/browser/extension_error.cc @@ -73,13 +73,17 @@ bool ExtensionError::IsEqual(const ExtensionError* rhs) const { } ManifestError::ManifestError(const std::string& extension_id, - const string16& message) + const string16& message, + const string16& manifest_key, + const string16& manifest_specific) : ExtensionError(ExtensionError::MANIFEST_ERROR, extension_id, false, // extensions can't be installed while incognito. logging::LOG_WARNING, // All manifest errors are warnings. base::FilePath(kManifestFilename).AsUTF16Unsafe(), - message) { + message), + manifest_key_(manifest_key), + manifest_specific_(manifest_specific) { } ManifestError::~ManifestError() { diff --git a/extensions/browser/extension_error.h b/extensions/browser/extension_error.h index 6ee7791..ceb1504 100644 --- a/extensions/browser/extension_error.h +++ b/extensions/browser/extension_error.h @@ -73,13 +73,25 @@ class ExtensionError { class ManifestError : public ExtensionError { public: ManifestError(const std::string& extension_id, - const base::string16& message); + const base::string16& message, + const base::string16& manifest_key, + const base::string16& manifest_specific); virtual ~ManifestError(); 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: 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); }; diff --git a/extensions/common/manifest.cc b/extensions/common/manifest.cc index eaaaf76..85b5d98 100644 --- a/extensions/common/manifest.cc +++ b/extensions/common/manifest.cc @@ -160,8 +160,8 @@ bool Manifest::ValidateManifest( it.Advance()) { if (!provider->GetFeature(it.key())) { warnings->push_back(InstallWarning( - base::StringPrintf("Unrecognized manifest key '%s'.", - it.key().c_str()), + ErrorUtils::FormatErrorMessage( + manifest_errors::kUnrecognizedManifestKey, it.key()), it.key())); } } diff --git a/extensions/common/manifest_constants.cc b/extensions/common/manifest_constants.cc index 3ba2a63..0402c40 100644 --- a/extensions/common/manifest_constants.cc +++ b/extensions/common/manifest_constants.cc @@ -149,4 +149,12 @@ const char kWebURLs[] = "app.urls"; } // namespace manifest_keys +namespace manifest_errors { + +const char kPermissionUnknownOrMalformed[] = + "Permission '*' is unknown or URL pattern is malformed."; +const char kUnrecognizedManifestKey[] = "Unrecognized manifest key '*'."; + +} // namespace manifest_errors + } // namespace extensions diff --git a/extensions/common/manifest_constants.h b/extensions/common/manifest_constants.h index ff4ca85..e08348e 100644 --- a/extensions/common/manifest_constants.h +++ b/extensions/common/manifest_constants.h @@ -153,6 +153,11 @@ namespace manifest_keys { extern const char kWebURLs[]; } // namespace manifest_keys +namespace manifest_errors { +extern const char kPermissionUnknownOrMalformed[]; +extern const char kUnrecognizedManifestKey[]; +} // namespace manifest_errors + } // namespace extensions #endif // EXTENSIONS_COMMON_MANIFEST_CONSTANTS_H_ |