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

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

Issue 7432006: Add an experimental permissions API for extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 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: 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 3c8f52c552e4aaf1ffba410913fa8a3123f6f493..cf2b9a6f8642b79ff7de6bb2c2c19f56c1574153 100644
--- a/chrome/common/extensions/url_pattern_set.cc
+++ b/chrome/common/extensions/url_pattern_set.cc
@@ -10,6 +10,29 @@
#include "chrome/common/extensions/url_pattern.h"
#include "googleurl/src/gurl.h"
+
+// static
+void URLPatternSet::CreateDifference(const URLPatternSet& set1,
+ const URLPatternSet& set2,
+ URLPatternSet* out) {
+ out->ClearPatterns();
+ std::set_difference(set1.patterns_.begin(), set1.patterns_.end(),
+ set2.patterns_.begin(), set2.patterns_.end(),
+ std::inserter<std::set<URLPattern> >(
+ out->patterns_, out->patterns_.begin()));
+}
+
+// static
+void URLPatternSet::CreateIntersection(const URLPatternSet& set1,
+ const URLPatternSet& set2,
+ URLPatternSet* out) {
+ out->ClearPatterns();
+ std::set_intersection(set1.patterns_.begin(), set1.patterns_.end(),
+ set2.patterns_.begin(), set2.patterns_.end(),
+ std::inserter<std::set<URLPattern> >(
+ out->patterns_, out->patterns_.begin()));
+}
+
// static
void URLPatternSet::CreateUnion(const URLPatternSet& set1,
const URLPatternSet& set2,
@@ -52,6 +75,11 @@ void URLPatternSet::ClearPatterns() {
patterns_.clear();
}
+bool URLPatternSet::Contains(const URLPatternSet& set) const {
+ return std::includes(patterns_.begin(), patterns_.end(),
+ set.patterns_.begin(), set.patterns_.end());
+}
+
bool URLPatternSet::MatchesURL(const GURL& url) const {
for (URLPatternSet::const_iterator pattern = patterns_.begin();
pattern != patterns_.end(); ++pattern) {

Powered by Google App Engine
This is Rietveld 408576698