OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/common/extensions/url_pattern_set.h" | 5 #include "chrome/common/extensions/url_pattern_set.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "chrome/common/extensions/url_pattern.h" | 10 #include "chrome/common/extensions/url_pattern.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 bool URLPatternSet::MatchesURL(const GURL& url) const { | 83 bool URLPatternSet::MatchesURL(const GURL& url) const { |
84 for (URLPatternSet::const_iterator pattern = patterns_.begin(); | 84 for (URLPatternSet::const_iterator pattern = patterns_.begin(); |
85 pattern != patterns_.end(); ++pattern) { | 85 pattern != patterns_.end(); ++pattern) { |
86 if (pattern->MatchesURL(url)) | 86 if (pattern->MatchesURL(url)) |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
90 return false; | 90 return false; |
91 } | 91 } |
92 | 92 |
| 93 bool URLPatternSet::MatchesSecurityOrigin(const std::string& origin) const { |
| 94 GURL origin_as_url(origin); |
| 95 for (URLPatternSet::const_iterator pattern = patterns_.begin(); |
| 96 pattern != patterns_.end(); ++pattern) { |
| 97 if (pattern->MatchesSecurityOrigin(origin_as_url)) |
| 98 return true; |
| 99 } |
| 100 |
| 101 return false; |
| 102 } |
| 103 |
93 bool URLPatternSet::OverlapsWith(const URLPatternSet& other) const { | 104 bool URLPatternSet::OverlapsWith(const URLPatternSet& other) const { |
94 // Two extension extents overlap if there is any one URL that would match at | 105 // Two extension extents overlap if there is any one URL that would match at |
95 // least one pattern in each of the extents. | 106 // least one pattern in each of the extents. |
96 for (URLPatternSet::const_iterator i = patterns_.begin(); | 107 for (URLPatternSet::const_iterator i = patterns_.begin(); |
97 i != patterns_.end(); ++i) { | 108 i != patterns_.end(); ++i) { |
98 for (URLPatternSet::const_iterator j = other.patterns().begin(); | 109 for (URLPatternSet::const_iterator j = other.patterns().begin(); |
99 j != other.patterns().end(); ++j) { | 110 j != other.patterns().end(); ++j) { |
100 if (i->OverlapsWith(*j)) | 111 if (i->OverlapsWith(*j)) |
101 return true; | 112 return true; |
102 } | 113 } |
103 } | 114 } |
104 | 115 |
105 return false; | 116 return false; |
106 } | 117 } |
OLD | NEW |