OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ | 5 #ifndef EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ |
6 #define EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ | 6 #define EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 | 52 |
53 URLPatternSet& operator=(const URLPatternSet& rhs); | 53 URLPatternSet& operator=(const URLPatternSet& rhs); |
54 bool operator==(const URLPatternSet& rhs) const; | 54 bool operator==(const URLPatternSet& rhs) const; |
55 | 55 |
56 bool is_empty() const; | 56 bool is_empty() const; |
57 size_t size() const; | 57 size_t size() const; |
58 const std::set<URLPattern>& patterns() const { return patterns_; } | 58 const std::set<URLPattern>& patterns() const { return patterns_; } |
59 const_iterator begin() const { return patterns_.begin(); } | 59 const_iterator begin() const { return patterns_.begin(); } |
60 const_iterator end() const { return patterns_.end(); } | 60 const_iterator end() const { return patterns_.end(); } |
61 | 61 |
62 // Adds a pattern to the set. Returns true if a new pattern was inserted, | 62 // Adds a pattern to the set. If a more general pattern is added, the more |
63 // false if the pattern was already in the set. | 63 // specific ones are removed from the set. Returns true if a new pattern was |
| 64 // inserted, false if the pattern was already in the set. |
64 bool AddPattern(const URLPattern& pattern); | 65 bool AddPattern(const URLPattern& pattern); |
65 | 66 |
66 // Adds all patterns from |set| into this. | 67 // Adds all patterns from |set| into this. |
67 void AddPatterns(const URLPatternSet& set); | 68 void AddPatterns(const URLPatternSet& set); |
68 | 69 |
69 void ClearPatterns(); | 70 void ClearPatterns(); |
70 | 71 |
71 // Returns true if every URL that matches |set| is matched by this. In other | 72 // Returns true if every URL that matches |set| is matched by this. In other |
72 // words, if every pattern in |set| is encompassed by a pattern in this. | 73 // words, if every pattern in |set| is encompassed by a pattern in this. |
73 bool Contains(const URLPatternSet& set) const; | 74 bool Contains(const URLPatternSet& set) const; |
(...skipping 15 matching lines...) Expand all Loading... |
89 int valid_schemes, | 90 int valid_schemes, |
90 bool allow_file_access, | 91 bool allow_file_access, |
91 std::string* error); | 92 std::string* error); |
92 | 93 |
93 bool Populate(const std::vector<std::string>& patterns, | 94 bool Populate(const std::vector<std::string>& patterns, |
94 int valid_schemes, | 95 int valid_schemes, |
95 bool allow_file_access, | 96 bool allow_file_access, |
96 std::string* error); | 97 std::string* error); |
97 | 98 |
98 private: | 99 private: |
| 100 // Directly inserts a pattern in the set without checking for more |
| 101 // generic/more specific containment conditions. |
| 102 bool InsertPattern(const URLPattern& pattern); |
| 103 |
99 // The list of URL patterns that comprise the extent. | 104 // The list of URL patterns that comprise the extent. |
100 std::set<URLPattern> patterns_; | 105 std::set<URLPattern> patterns_; |
101 }; | 106 }; |
102 | 107 |
103 } // namespace extensions | 108 } // namespace extensions |
104 | 109 |
105 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ | 110 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ |
OLD | NEW |