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

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

Issue 2116293003: extensions: Generate hash of extension ID at a higher level Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/simple_feature.h ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/common/features/simple_feature.cc
diff --git a/extensions/common/features/simple_feature.cc b/extensions/common/features/simple_feature.cc
index 9abc1b4f39224eed5f27a682b50d65fa06c18f43..00c0e196833c1de8e507ec00bdb6f854990d64b1 100644
--- a/extensions/common/features/simple_feature.cc
+++ b/extensions/common/features/simple_feature.cc
@@ -35,13 +35,14 @@ std::string* g_whitelisted_extension_id = NULL;
Feature::Availability IsAvailableToManifestForBind(
const std::string& extension_id,
+ const std::string& hashed_id,
Manifest::Type type,
Manifest::Location location,
int manifest_version,
Feature::Platform platform,
const Feature* feature) {
- return feature->IsAvailableToManifest(
- extension_id, type, location, manifest_version, platform);
+ return feature->IsAvailableToManifest(extension_id, hashed_id, type, location,
+ manifest_version, platform);
}
Feature::Availability IsAvailableToContextForBind(const Extension* extension,
@@ -363,6 +364,7 @@ std::string SimpleFeature::Parse(const base::DictionaryValue* dictionary) {
Feature::Availability SimpleFeature::IsAvailableToManifest(
const std::string& extension_id,
+ const std::string& hashed_id,
Manifest::Type type,
Manifest::Location location,
int manifest_version,
@@ -378,7 +380,7 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
return CreateAvailability(INVALID_TYPE, type);
}
- if (IsIdInBlacklist(extension_id))
+ if (IsIdInBlacklist(extension_id, hashed_id))
return CreateAvailability(FOUND_IN_BLACKLIST, type);
// TODO(benwells): don't grant all component extensions.
@@ -388,8 +390,8 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
if (component_extensions_auto_granted_ && location == Manifest::COMPONENT)
return CreateAvailability(IS_AVAILABLE, type);
- if (!whitelist_.empty() && !IsIdInWhitelist(extension_id) &&
- !IsWhitelistedForTest(extension_id)) {
+ if (!whitelist_.empty() && !IsIdInWhitelist(extension_id, hashed_id) &&
+ !IsWhitelistedForTest(extension_id) && !IsWhitelistedForTest(hashed_id)) {
return CreateAvailability(NOT_FOUND_IN_WHITELIST, type);
}
@@ -418,11 +420,8 @@ Feature::Availability SimpleFeature::IsAvailableToManifest(
}
return CheckDependencies(base::Bind(&IsAvailableToManifestForBind,
- extension_id,
- type,
- location,
- manifest_version,
- platform));
+ extension_id, hashed_id, type, location,
+ manifest_version, platform));
}
Feature::Availability SimpleFeature::IsAvailableToContext(
@@ -431,11 +430,9 @@ Feature::Availability SimpleFeature::IsAvailableToContext(
const GURL& url,
SimpleFeature::Platform platform) const {
if (extension) {
- Availability result = IsAvailableToManifest(extension->id(),
- extension->GetType(),
- extension->location(),
- extension->manifest_version(),
- platform);
+ Availability result = IsAvailableToManifest(
+ extension->id(), HashedIdInHex(extension->id()), extension->GetType(),
+ extension->location(), extension->manifest_version(), platform);
if (!result.is_available())
return result;
}
@@ -567,12 +564,16 @@ bool SimpleFeature::IsInternal() const {
return false;
}
-bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id) const {
- return IsIdInList(extension_id, blacklist_);
+bool SimpleFeature::IsIdInBlacklist(const std::string& extension_id,
+ const std::string& hashed_id) const {
+ return (IsIdInList(extension_id, blacklist_) ||
+ IsIdInList(hashed_id, blacklist_));
}
-bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id) const {
- return IsIdInList(extension_id, whitelist_);
+bool SimpleFeature::IsIdInWhitelist(const std::string& extension_id,
+ const std::string& hashed_id) const {
+ return (IsIdInList(extension_id, whitelist_) ||
+ IsIdInList(hashed_id, whitelist_));
}
// static
@@ -585,8 +586,7 @@ bool SimpleFeature::IsIdInArray(const std::string& extension_id,
const char* const* start = array;
const char* const* end = array + array_length;
- return ((std::find(start, end, extension_id) != end) ||
- (std::find(start, end, HashedIdInHex(extension_id)) != end));
+ return (std::find(start, end, extension_id) != end);
}
// static
@@ -595,8 +595,7 @@ bool SimpleFeature::IsIdInList(const std::string& extension_id,
if (!IsValidExtensionId(extension_id))
return false;
- return (ContainsValue(list, extension_id) ||
- ContainsValue(list, HashedIdInHex(extension_id)));
+ return ContainsValue(list, extension_id);
}
bool SimpleFeature::MatchesManifestLocation(
« no previous file with comments | « extensions/common/features/simple_feature.h ('k') | extensions/common/features/simple_feature_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698