OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extension_extent.h" | 5 #include "chrome/common/extensions/extension_extent.h" |
6 | 6 |
7 bool ExtensionExtent::ContainsURL(const GURL& url) const { | 7 bool ExtensionExtent::ContainsURL(const GURL& url) const { |
8 for (PatternList::const_iterator pattern = patterns_.begin(); | 8 for (PatternList::const_iterator pattern = patterns_.begin(); |
9 pattern != patterns_.end(); ++pattern) { | 9 pattern != patterns_.end(); ++pattern) { |
10 if (pattern->MatchesUrl(url)) | 10 if (pattern->MatchesUrl(url)) |
11 return true; | 11 return true; |
12 } | 12 } |
13 | 13 |
14 return false; | 14 return false; |
15 } | 15 } |
| 16 |
| 17 bool ExtensionExtent::OverlapsWith(const ExtensionExtent& other) const { |
| 18 // Two extension extents overlap if there is any one URL that would match at |
| 19 // least one pattern in each of the extents. |
| 20 for (PatternList::const_iterator i = patterns_.begin(); |
| 21 i != patterns_.end(); ++i) { |
| 22 for (PatternList::const_iterator j = other.patterns().begin(); |
| 23 j != other.patterns().end(); ++j) { |
| 24 if (i->OverlapsWith(*j)) |
| 25 return true; |
| 26 } |
| 27 } |
| 28 |
| 29 return false; |
| 30 } |
OLD | NEW |