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

Unified Diff: chrome/common/extensions/feature.h

Issue 9664053: Re-land 125247: Better error messages when using unsupported manifest features. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/feature.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/feature.h
diff --git a/chrome/common/extensions/feature.h b/chrome/common/extensions/feature.h
index 0a956890be5918ddad00c873c5540ea9f8409dc2..61a96a59382724ce607509221d21d62bec997721 100644
--- a/chrome/common/extensions/feature.h
+++ b/chrome/common/extensions/feature.h
@@ -41,6 +41,19 @@ class Feature {
CHROMEOS_PLATFORM
};
+ // Whether a feature is available in a given situation or not, and if not,
+ // why not.
+ enum Availability {
+ IS_AVAILABLE,
+ NOT_FOUND_IN_WHITELIST,
+ INVALID_TYPE,
+ INVALID_CONTEXT,
+ INVALID_LOCATION,
+ INVALID_PLATFORM,
+ INVALID_MIN_MANIFEST_VERSION,
+ INVALID_MAX_MANIFEST_VERSION
+ };
+
Feature();
~Feature();
@@ -75,13 +88,13 @@ class Feature {
// Returns true if the feature is available to the specified extension. Use
// this overload for features that are not associated with a specific context.
- bool IsAvailable(const Extension* extension) {
+ Availability IsAvailable(const Extension* extension) {
return IsAvailable(extension, UNSPECIFIED_CONTEXT);
}
// Returns true if the feature is available to the specified extension, in the
// specified context type.
- bool IsAvailable(const Extension* extension, Context context) {
+ Availability IsAvailable(const Extension* extension, Context context) {
return IsAvailable(extension->id(), extension->GetType(),
ConvertLocation(extension->location()), context,
GetCurrentPlatform(),
@@ -91,8 +104,9 @@ class Feature {
// Returns true if the feature is available to extensions with the specified
// properties. Use this overload for features that are not associated with a
// specific context, and when a full Extension object is not available.
- bool IsAvailable(const std::string& extension_id, Extension::Type type,
- Location location, int manifest_version) {
+ Availability IsAvailable(const std::string& extension_id,
+ Extension::Type type, Location location,
+ int manifest_version) {
return IsAvailable(extension_id, type, location, UNSPECIFIED_CONTEXT,
GetCurrentPlatform(), manifest_version);
}
@@ -100,9 +114,13 @@ class Feature {
// Returns true if the feature is available to extensions with the specified
// properties, in the specified context type, and on the specified platform.
// This overload is mainly used for testing.
- bool IsAvailable(const std::string& extension_id, Extension::Type type,
- Location location, Context context,
- Platform platform, int manifest_version);
+ Availability IsAvailable(const std::string& extension_id,
+ Extension::Type type, Location location,
+ Context context, Platform platform,
+ int manifest_version);
+
+ // Returns an error message for an Availability code.
+ std::string GetErrorMessage(Availability result);
private:
// For clarify and consistency, we handle the default value of each of these
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698