Index: chrome/common/extensions/extension.cc |
=================================================================== |
--- chrome/common/extensions/extension.cc (revision 113054) |
+++ chrome/common/extensions/extension.cc (working copy) |
@@ -369,6 +369,22 @@ |
return ret_val; |
} |
+bool Extension::IsResourceWebAccessible(const std::string& relative_path) |
+ const { |
+ if (web_accessible_resources_.find(relative_path) != |
+ web_accessible_resources_.end()) |
+ return true; |
+ |
+ return false; |
+} |
+ |
+bool Extension::HasWebAccessibleResources() const { |
+ if (web_accessible_resources_.size()) |
+ return true; |
+ |
+ return false; |
+} |
+ |
bool Extension::GenerateId(const std::string& input, std::string* output) { |
DCHECK(output); |
uint8 hash[Extension::kIdSize]; |
@@ -1827,6 +1843,26 @@ |
} |
} |
+ // Initialize web accessible resources (optional). |
+ if (manifest->HasKey(keys::kWebAccessibleResources)) { |
+ ListValue* list_value; |
+ if (!manifest->GetList(keys::kWebAccessibleResources, &list_value)) { |
+ *error = errors::kInvalidWebAccessibleResourcesList; |
+ return false; |
+ } |
+ for (size_t i = 0; i < list_value->GetSize(); ++i) { |
+ std::string relative_path; |
+ if (!list_value->GetString(i, &relative_path)) { |
+ *error = ExtensionErrorUtils::FormatErrorMessage( |
+ errors::kInvalidWebAccessibleResource, base::IntToString(i)); |
+ return false; |
+ } |
+ if (relative_path[0] != '/') |
+ relative_path = '/' + relative_path; |
+ web_accessible_resources_.insert(relative_path); |
+ } |
+ } |
+ |
// Initialize page action (optional). |
DictionaryValue* page_action_value = NULL; |