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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 | 65 |
66 // Adds all patterns from |set| into this. | 66 // Adds all patterns from |set| into this. |
67 void AddPatterns(const URLPatternSet& set); | 67 void AddPatterns(const URLPatternSet& set); |
68 | 68 |
69 void ClearPatterns(); | 69 void ClearPatterns(); |
70 | 70 |
71 // Returns true if every URL that matches |set| is matched by this. In other | 71 // 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. | 72 // words, if every pattern in |set| is encompassed by a pattern in this. |
73 bool Contains(const URLPatternSet& set) const; | 73 bool Contains(const URLPatternSet& set) const; |
74 | 74 |
| 75 // Returns true if any pattern in this set encompasses |pattern|. |
| 76 bool ContainsPattern(const URLPattern& pattern) const; |
| 77 |
75 // Test if the extent contains a URL. | 78 // Test if the extent contains a URL. |
76 bool MatchesURL(const GURL& url) const; | 79 bool MatchesURL(const GURL& url) const; |
77 | 80 |
78 bool MatchesSecurityOrigin(const GURL& origin) const; | 81 bool MatchesSecurityOrigin(const GURL& origin) const; |
79 | 82 |
80 // Returns true if there is a single URL that would be in two extents. | 83 // Returns true if there is a single URL that would be in two extents. |
81 bool OverlapsWith(const URLPatternSet& other) const; | 84 bool OverlapsWith(const URLPatternSet& other) const; |
82 | 85 |
83 // Converts to and from Value for serialization to preferences. | 86 // Converts to and from Value for serialization to preferences. |
84 scoped_ptr<base::ListValue> ToValue() const; | 87 scoped_ptr<base::ListValue> ToValue() const; |
85 bool Populate(const base::ListValue& value, | 88 bool Populate(const base::ListValue& value, |
86 int valid_schemes, | 89 int valid_schemes, |
87 bool allow_file_access, | 90 bool allow_file_access, |
88 std::string* error); | 91 std::string* error); |
89 | 92 |
90 bool Populate(const std::vector<std::string>& patterns, | 93 bool Populate(const std::vector<std::string>& patterns, |
91 int valid_schemes, | 94 int valid_schemes, |
92 bool allow_file_access, | 95 bool allow_file_access, |
93 std::string* error); | 96 std::string* error); |
94 | 97 |
95 private: | 98 private: |
96 // Returns true if any pattern in this set encompasses |pattern|. | |
97 bool ContainsPattern(const URLPattern& pattern) const; | |
98 | |
99 // The list of URL patterns that comprise the extent. | 99 // The list of URL patterns that comprise the extent. |
100 std::set<URLPattern> patterns_; | 100 std::set<URLPattern> patterns_; |
101 }; | 101 }; |
102 | 102 |
103 } // namespace extensions | 103 } // namespace extensions |
104 | 104 |
105 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ | 105 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ |
OLD | NEW |