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

Unified Diff: chrome/common/extensions/features/simple_feature.cc

Issue 15091002: Lazily load API schemas from resource files and convert all APIs to features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos tests Created 7 years, 6 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
Index: chrome/common/extensions/features/simple_feature.cc
diff --git a/chrome/common/extensions/features/simple_feature.cc b/chrome/common/extensions/features/simple_feature.cc
index 9fc02471ab886fdd02f640eaddf766607d7b3a18..b04632d20949045ab6c71327871c8940c9c5272e 100644
--- a/chrome/common/extensions/features/simple_feature.cc
+++ b/chrome/common/extensions/features/simple_feature.cc
@@ -141,6 +141,7 @@ void ParseURLPatterns(const DictionaryValue* value,
URLPatternSet* set) {
const ListValue* matches = NULL;
if (value->GetList(key, &matches)) {
+ set->ClearPatterns();
for (size_t i = 0; i < matches->GetSize(); ++i) {
std::string pattern;
CHECK(matches->GetString(i, &pattern));
@@ -187,7 +188,9 @@ SimpleFeature::SimpleFeature()
platform_(UNSPECIFIED_PLATFORM),
min_manifest_version_(0),
max_manifest_version_(0),
- channel_(VersionInfo::CHANNEL_UNKNOWN) {
+ channel_(VersionInfo::CHANNEL_UNKNOWN),
+ has_parent_(false),
+ channel_has_been_set_(false) {
}
SimpleFeature::SimpleFeature(const SimpleFeature& other)
@@ -199,7 +202,9 @@ SimpleFeature::SimpleFeature(const SimpleFeature& other)
platform_(other.platform_),
min_manifest_version_(other.min_manifest_version_),
max_manifest_version_(other.max_manifest_version_),
- channel_(other.channel_) {
+ channel_(other.channel_),
+ has_parent_(other.has_parent_),
+ channel_has_been_set_(other.channel_has_been_set_) {
}
SimpleFeature::~SimpleFeature() {
@@ -214,7 +219,9 @@ bool SimpleFeature::Equals(const SimpleFeature& other) const {
platform_ == other.platform_ &&
min_manifest_version_ == other.min_manifest_version_ &&
max_manifest_version_ == other.max_manifest_version_ &&
- channel_ == other.channel_;
+ channel_ == other.channel_ &&
+ has_parent_ == other.has_parent_ &&
+ channel_has_been_set_ == other.channel_has_been_set_;
}
std::string SimpleFeature::Parse(const DictionaryValue* value) {
@@ -234,10 +241,21 @@ std::string SimpleFeature::Parse(const DictionaryValue* value) {
ParseEnum<VersionInfo::Channel>(
value, "channel", &channel_,
g_mappings.Get().channels);
+
+ no_parent_ = false;
+ value->GetBoolean("noparent", &no_parent_);
+
+ // The "trunk" channel uses VersionInfo::CHANNEL_UNKNOWN, so we need to keep
+ // track of whether the channel has been set or not separately.
+ channel_has_been_set_ |= value->HasKey("channel");
+ if (!channel_has_been_set_ && dependencies_.empty())
+ return name() + ": Must supply a value for channel or dependencies.";
+
if (matches_.is_empty() && contexts_.count(WEB_PAGE_CONTEXT) != 0) {
return name() + ": Allowing web_page contexts requires supplying a value " +
"for matches.";
}
+
return std::string();
}
@@ -288,7 +306,7 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
if (max_manifest_version_ != 0 && manifest_version > max_manifest_version_)
return CreateAvailability(INVALID_MAX_MANIFEST_VERSION, type);
- if (channel_ < Feature::GetCurrentChannel())
+ if (channel_has_been_set_ && channel_ < Feature::GetCurrentChannel())
return CreateAvailability(UNSUPPORTED_CHANNEL, type);
return CreateAvailability(IS_AVAILABLE, type);
« no previous file with comments | « chrome/common/extensions/features/simple_feature.h ('k') | chrome/common/extensions/features/simple_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698