Index: chrome/common/extensions/url_pattern_set.cc |
diff --git a/chrome/common/extensions/url_pattern_set.cc b/chrome/common/extensions/url_pattern_set.cc |
index 11390ac446311420e19000ecd7963feb7e43f1a8..128b902e75b2a6873e80848f1db0d1681d242bed 100644 |
--- a/chrome/common/extensions/url_pattern_set.cc |
+++ b/chrome/common/extensions/url_pattern_set.cc |
@@ -175,6 +175,31 @@ scoped_ptr<base::ListValue> URLPatternSet::ToValue() const { |
return value.Pass(); |
} |
+bool URLPatternSet::Populate(const std::vector<std::string>& patterns, |
+ int valid_schemes, |
+ bool allow_file_access, |
+ std::string* error) { |
+ ClearPatterns(); |
+ for (size_t i = 0; i < patterns.size(); ++i) { |
+ URLPattern pattern(valid_schemes); |
+ if (pattern.Parse(patterns[i]) != URLPattern::PARSE_SUCCESS) { |
+ if (error) { |
+ *error = ExtensionErrorUtils::FormatErrorMessage( |
+ kInvalidURLPatternError, patterns[i]); |
+ } else { |
+ LOG(ERROR) << "Invalid url pattern: " << patterns[i]; |
+ } |
+ return false; |
+ } |
+ if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { |
+ pattern.SetValidSchemes( |
+ pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
+ } |
+ AddPattern(pattern); |
+ } |
+ return true; |
+} |
+ |
bool URLPatternSet::Populate(const base::ListValue& value, |
int valid_schemes, |
bool allow_file_access, |