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

Unified Diff: extensions/common/manifest_handlers/shared_module_info.cc

Issue 263703002: Allow shared modules to whitelist extensions that import them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: feedback 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/manifest_handlers/shared_module_info.cc
diff --git a/extensions/common/manifest_handlers/shared_module_info.cc b/extensions/common/manifest_handlers/shared_module_info.cc
index 5f4416099271c38d4565c835eb2f68b9cbe65af0..ac95ee5b07440270e2afb9bb64272c2981473597 100644
--- a/extensions/common/manifest_handlers/shared_module_info.cc
+++ b/extensions/common/manifest_handlers/shared_module_info.cc
@@ -84,6 +84,17 @@ bool SharedModuleInfo::IsExportAllowed(const Extension* extension,
}
// static
+bool SharedModuleInfo::IsExportAllowedByWhitelist(const Extension* extension,
+ const std::string& other_id) {
+ const SharedModuleInfo& info = GetSharedModuleInfo(extension);
+ if (info.export_whitelist_.empty())
+ return true;
+ if (info.export_whitelist_.find(other_id) != info.export_whitelist_.end())
+ return true;
+ return false;
+}
+
+// static
bool SharedModuleInfo::ImportsExtensionById(const Extension* extension,
const std::string& other_id) {
const SharedModuleInfo& info = GetSharedModuleInfo(extension);
@@ -128,6 +139,23 @@ bool SharedModuleInfo::Parse(const Extension* extension,
*error = base::ASCIIToUTF16(errors::kInvalidExportResources);
return false;
}
+ if (export_value->HasKey(keys::kWhitelist)) {
+ const base::ListValue* whitelist = NULL;
+ if (!export_value->GetList(keys::kWhitelist, &whitelist)) {
+ *error = base::ASCIIToUTF16(errors::kInvalidExportWhitelist);
+ return false;
+ }
+ for (size_t i = 0; i < whitelist->GetSize(); ++i) {
+ std::string extension_id;
+ if (!whitelist->GetString(i, &extension_id) ||
+ !Extension::IdIsValid(extension_id)) {
+ *error = ErrorUtils::FormatErrorMessageUTF16(
+ errors::kInvalidExportWhitelistString, base::IntToString(i));
+ return false;
+ }
+ export_whitelist_.insert(extension_id);
+ }
+ }
for (size_t i = 0; i < resources_list->GetSize(); ++i) {
std::string resource_path;
if (!resources_list->GetString(i, &resource_path)) {

Powered by Google App Engine
This is Rietveld 408576698