Chromium Code Reviews| Index: extensions/common/url_pattern_set.cc |
| diff --git a/extensions/common/url_pattern_set.cc b/extensions/common/url_pattern_set.cc |
| index 40663201c1c5a66169f5160a43eaa67f8f7d6f5f..36498935c7b216b10406f57b196bac8f4a808bd0 100644 |
| --- a/extensions/common/url_pattern_set.cc |
| +++ b/extensions/common/url_pattern_set.cc |
| @@ -134,6 +134,26 @@ bool URLPatternSet::Contains(const URLPatternSet& set) const { |
| set.patterns_.begin(), set.patterns_.end()); |
| } |
| +bool URLPatternSet::EncompassesPattern(const URLPattern& pattern) const { |
| + for (URLPatternSet::const_iterator it = begin(); |
| + it != end(); ++it) { |
| + if (it->Encompasses(pattern)) |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| +bool URLPatternSet::Encompasses(const URLPatternSet& other) const { |
| + for (URLPatternSet::const_iterator it = other.begin(); |
| + it != other.end(); ++it) { |
| + if (!EncompassesPattern(*it)) |
| + return false; |
| + } |
| + |
| + return true; |
| +} |
| + |
| bool URLPatternSet::MatchesURL(const GURL& url) const { |
| for (URLPatternSet::const_iterator pattern = patterns_.begin(); |
| pattern != patterns_.end(); ++pattern) { |
| @@ -216,4 +236,16 @@ bool URLPatternSet::Populate(const base::ListValue& value, |
| return Populate(patterns, valid_schemes, allow_file_access, error); |
| } |
| +std::ostream& operator<<(std::ostream& out, const URLPatternSet& set) { |
| + bool needs_comma = false; |
| + out << "{"; |
| + for (URLPatternSet::const_iterator it = set.begin(); it != set.end(); ++it) { |
| + if (needs_comma) |
|
Matt Perry
2013/02/12 01:14:47
could this just be "it != set.begin()" ?
not at google - send to devlin
2013/02/12 01:49:36
Done.
|
| + out << ","; |
| + needs_comma = true; |
| + out << it->GetAsString(); |
| + } |
| + return out << "}"; |
| +} |
| + |
| } // namespace extensions |