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 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
6 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ | 6 #define CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 // and |set2|. | 33 // and |set2|. |
34 static void CreateIntersection(const URLPatternSet& set1, | 34 static void CreateIntersection(const URLPatternSet& set1, |
35 const URLPatternSet& set2, | 35 const URLPatternSet& set2, |
36 URLPatternSet* out); | 36 URLPatternSet* out); |
37 | 37 |
38 // Clears |out| and populates the set with the union of |set1| and |set2|. | 38 // Clears |out| and populates the set with the union of |set1| and |set2|. |
39 static void CreateUnion(const URLPatternSet& set1, | 39 static void CreateUnion(const URLPatternSet& set1, |
40 const URLPatternSet& set2, | 40 const URLPatternSet& set2, |
41 URLPatternSet* out); | 41 URLPatternSet* out); |
42 | 42 |
| 43 // Clears |out| and populates it with the union of all sets in |sets|. |
| 44 static void CreateUnion(const std::vector<URLPatternSet>& sets, |
| 45 URLPatternSet* out); |
| 46 |
43 URLPatternSet(); | 47 URLPatternSet(); |
44 URLPatternSet(const URLPatternSet& rhs); | 48 URLPatternSet(const URLPatternSet& rhs); |
45 explicit URLPatternSet(const std::set<URLPattern>& patterns); | 49 explicit URLPatternSet(const std::set<URLPattern>& patterns); |
46 ~URLPatternSet(); | 50 ~URLPatternSet(); |
47 | 51 |
48 URLPatternSet& operator=(const URLPatternSet& rhs); | 52 URLPatternSet& operator=(const URLPatternSet& rhs); |
49 bool operator==(const URLPatternSet& rhs) const; | 53 bool operator==(const URLPatternSet& rhs) const; |
50 | 54 |
51 bool is_empty() const; | 55 bool is_empty() const; |
| 56 size_t size() const; |
52 const std::set<URLPattern>& patterns() const { return patterns_; } | 57 const std::set<URLPattern>& patterns() const { return patterns_; } |
53 const_iterator begin() const { return patterns_.begin(); } | 58 const_iterator begin() const { return patterns_.begin(); } |
54 const_iterator end() const { return patterns_.end(); } | 59 const_iterator end() const { return patterns_.end(); } |
55 | 60 |
56 void AddPattern(const URLPattern& pattern); | 61 void AddPattern(const URLPattern& pattern); |
57 void ClearPatterns(); | 62 void ClearPatterns(); |
58 | 63 |
59 // Returns true if the permission |set| is a subset of this. | 64 // Returns true if the permission |set| is a subset of this. |
60 bool Contains(const URLPatternSet& set) const; | 65 bool Contains(const URLPatternSet& set) const; |
61 | 66 |
(...skipping 11 matching lines...) Expand all Loading... |
73 int valid_schemes, | 78 int valid_schemes, |
74 bool allow_file_access, | 79 bool allow_file_access, |
75 std::string* error); | 80 std::string* error); |
76 | 81 |
77 private: | 82 private: |
78 // The list of URL patterns that comprise the extent. | 83 // The list of URL patterns that comprise the extent. |
79 std::set<URLPattern> patterns_; | 84 std::set<URLPattern> patterns_; |
80 }; | 85 }; |
81 | 86 |
82 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ | 87 #endif // CHROME_COMMON_EXTENSIONS_URL_PATTERN_SET_H_ |
OLD | NEW |