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

Unified Diff: chrome/common/extensions/extension.cc

Issue 8849010: Add 'web_accessible_resource" keyword for version 2 extension manifests. This makes extension res... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years 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/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;

Powered by Google App Engine
This is Rietveld 408576698