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

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

Issue 265503003: Enable file_handlers and chrome.app.runtime for QuickOffice. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: With blacklist, test Created 6 years, 8 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: extensions/common/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index 8ef18f8ff64b4e62c1bf48c9096fd2c9f2ca40cc..c5ba7ae13644593b80123c52e30dee7de01467bd 100644
--- a/extensions/common/features/simple_feature.cc
+++ b/extensions/common/features/simple_feature.cc
@@ -237,6 +237,7 @@ void SimpleFeature::AddFilter(scoped_ptr<SimpleFeatureFilter> filter) {
std::string SimpleFeature::Parse(const base::DictionaryValue* value) {
ParseURLPatterns(value, "matches", &matches_);
+ ParseSet(value, "blacklist", &blacklist_);
ParseSet(value, "whitelist", &whitelist_);
ParseSet(value, "dependencies", &dependencies_);
ParseEnumSet<Manifest::Type>(value, "extension_types", &extension_types_,
@@ -292,6 +293,11 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
if (location == Manifest::COMPONENT)
return CreateAvailability(IS_AVAILABLE, type);
+ if (!blacklist_.empty()) {
not at google - send to devlin 2014/05/01 20:55:06 the !blacklist_.empty() check isn't really necessa
benwells 2014/05/02 00:58:52 Done.
+ if (IsIdInBlacklist(extension_id))
+ return CreateAvailability(FOUND_IN_BLACKLIST, type);
+ }
+
if (!whitelist_.empty()) {
if (!IsIdInWhitelist(extension_id)) {
// TODO(aa): This is gross. There should be a better way to test the
@@ -375,6 +381,7 @@ std::string SimpleFeature::GetAvailabilityMessage(
case IS_AVAILABLE:
return std::string();
case NOT_FOUND_IN_WHITELIST:
+ case FOUND_IN_BLACKLIST:
return base::StringPrintf(
"'%s' is not allowed for specified extension ID.",
name().c_str());
@@ -466,13 +473,17 @@ bool SimpleFeature::IsInternal() const {
bool SimpleFeature::IsBlockedInServiceWorker() const { return false; }
+bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const {
+ return IsIdInList(extension_id, blacklist_);
+}
+
bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
- return IsIdInWhitelist(extension_id, whitelist_);
+ return IsIdInList(extension_id, whitelist_);
}
// static
-bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id,
- const std::set<std::string>& whitelist) {
+bool SimpleFeature::IsIdInList(const std::string& extension_id,
+ const std::set<std::string>& list) {
// Belt-and-suspenders philosophy here. We should be pretty confident by this
// point that we've validated the extension ID format, but in case something
// slips through, we avoid a class of attack where creative ID manipulation
@@ -480,8 +491,8 @@ bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id,
if (extension_id.length() != 32) // 128 bits / 4 = 32 mpdecimal characters
return false;
- if (whitelist.find(extension_id) != whitelist.end() ||
- whitelist.find(HashExtensionId(extension_id)) != whitelist.end()) {
+ if (list.find(extension_id) != list.end() ||
+ list.find(HashExtensionId(extension_id)) != list.end()) {
return true;
}

Powered by Google App Engine
This is Rietveld 408576698