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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // Adds a pattern to the set. Returns true if a new pattern was inserted, | 62 // Adds a pattern to the set. Returns true if a new pattern was inserted, |
63 // false if the pattern was already in the set. | 63 // false if the pattern was already in the set. |
64 bool AddPattern(const URLPattern& pattern); | 64 bool AddPattern(const URLPattern& pattern); |
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 the permission |set| is a subset of this. | 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 bool Contains(const URLPatternSet& set) const; | 73 bool Contains(const URLPatternSet& set) const; |
73 | 74 |
74 // Test if the extent contains a URL. | 75 // Test if the extent contains a URL. |
75 bool MatchesURL(const GURL& url) const; | 76 bool MatchesURL(const GURL& url) const; |
76 | 77 |
77 bool MatchesSecurityOrigin(const GURL& origin) const; | 78 bool MatchesSecurityOrigin(const GURL& origin) const; |
78 | 79 |
79 // Returns true if there is a single URL that would be in two extents. | 80 // Returns true if there is a single URL that would be in two extents. |
80 bool OverlapsWith(const URLPatternSet& other) const; | 81 bool OverlapsWith(const URLPatternSet& other) const; |
81 | 82 |
82 // Converts to and from Value for serialization to preferences. | 83 // Converts to and from Value for serialization to preferences. |
83 scoped_ptr<base::ListValue> ToValue() const; | 84 scoped_ptr<base::ListValue> ToValue() const; |
84 bool Populate(const base::ListValue& value, | 85 bool Populate(const base::ListValue& value, |
85 int valid_schemes, | 86 int valid_schemes, |
86 bool allow_file_access, | 87 bool allow_file_access, |
87 std::string* error); | 88 std::string* error); |
88 | 89 |
89 bool Populate(const std::vector<std::string>& patterns, | 90 bool Populate(const std::vector<std::string>& patterns, |
90 int valid_schemes, | 91 int valid_schemes, |
91 bool allow_file_access, | 92 bool allow_file_access, |
92 std::string* error); | 93 std::string* error); |
93 | 94 |
94 private: | 95 private: |
| 96 // Returns true if any pattern in this set encompasses |pattern|. |
| 97 bool ContainsPattern(const URLPattern& pattern) const; |
| 98 |
95 // The list of URL patterns that comprise the extent. | 99 // The list of URL patterns that comprise the extent. |
96 std::set<URLPattern> patterns_; | 100 std::set<URLPattern> patterns_; |
97 }; | 101 }; |
98 | 102 |
99 } // namespace extensions | 103 } // namespace extensions |
100 | 104 |
101 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ | 105 #endif // EXTENSIONS_COMMMON_URL_PATTERN_SET_H_ |
OLD | NEW |