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

Unified Diff: extensions/common/features/simple_feature.h

Issue 2150193002: [Extensions] Add a SimpleFeature::Validate function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Istiaque's Created 4 years, 5 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/common/features/permission_feature.cc ('k') | extensions/common/features/simple_feature.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature.h
diff --git a/extensions/common/features/simple_feature.h b/extensions/common/features/simple_feature.h
index 373f6e54743da0beb7cacaa8d9be97f9b34272c5..3aec062f63a82c2f5d219f5b49fb204c40018361 100644
--- a/extensions/common/features/simple_feature.h
+++ b/extensions/common/features/simple_feature.h
@@ -47,10 +47,13 @@ class SimpleFeature : public Feature {
~SimpleFeature() override;
// Parses the JSON representation of a feature into the fields of this object.
- // Unspecified values in the JSON are not modified in the object. This allows
- // us to implement inheritance by parsing one value after another. Returns
- // the error found, or an empty string on success.
- virtual std::string Parse(const base::DictionaryValue* dictionary);
+ // Note: Validate() should be called after this.
+ void Parse(const base::DictionaryValue* dictionary);
+
+ // Checks whether the feature is valid. Invalid features should not be used.
+ // Subclasses can override to implement specific checking, but should always
+ // call this method as well.
+ virtual bool Validate(std::string* error);
Availability IsAvailableToContext(const Extension* extension,
Context context) const {
@@ -153,7 +156,9 @@ class SimpleFeature : public Feature {
FRIEND_TEST_ALL_PREFIXES(ManifestUnitTest, Extension);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, Blacklist);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, CommandLineSwitch);
+ FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, ComplexFeatureAvailability);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, Context);
+ FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, FeatureValidation);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, HashedIdBlacklist);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, HashedIdWhitelist);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, Inheritance);
@@ -168,6 +173,7 @@ class SimpleFeature : public Feature {
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, ParsePlatforms);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, ParseWhitelist);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, Platform);
+ FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, SimpleFeatureAvailability);
FRIEND_TEST_ALL_PREFIXES(SimpleFeatureTest, Whitelist);
// Holds String to Enum value mappings.
@@ -200,6 +206,7 @@ class SimpleFeature : public Feature {
bool component_extensions_auto_granted_;
std::string command_line_switch_;
std::unique_ptr<version_info::Channel> channel_;
+ bool internal_;
DISALLOW_COPY_AND_ASSIGN(SimpleFeature);
};
« no previous file with comments | « extensions/common/features/permission_feature.cc ('k') | extensions/common/features/simple_feature.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698