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 // Patterns used in content setting rules. | 5 // Patterns used in content setting rules. |
6 | 6 |
7 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 7 #ifndef COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
8 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 8 #define COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // Pattern A and B have an intersection. But pattern A has a higher | 46 // Pattern A and B have an intersection. But pattern A has a higher |
47 // precedence than pattern B for URLs that are matched by both pattern. | 47 // precedence than pattern B for URLs that are matched by both pattern. |
48 enum Relation { | 48 enum Relation { |
49 DISJOINT_ORDER_POST = -2, | 49 DISJOINT_ORDER_POST = -2, |
50 SUCCESSOR = -1, | 50 SUCCESSOR = -1, |
51 IDENTITY = 0, | 51 IDENTITY = 0, |
52 PREDECESSOR = 1, | 52 PREDECESSOR = 1, |
53 DISJOINT_ORDER_PRE = 2, | 53 DISJOINT_ORDER_PRE = 2, |
54 }; | 54 }; |
55 | 55 |
56 enum SchemeType { | |
Ilya Sherman
2016/08/10 05:34:26
Please document that this enum is used to back an
lshang
2016/08/11 00:26:50
Done.
| |
57 SCHEME_WILDCARD, | |
58 SCHEME_HTTP, | |
59 SCHEME_HTTPS, | |
60 SCHEME_FILE, | |
61 SCHEME_CHROMEEXTENSION, | |
62 SCHEME_OTHER, | |
63 SCHEME_MAX, | |
64 }; | |
65 | |
56 struct PatternParts { | 66 struct PatternParts { |
57 PatternParts(); | 67 PatternParts(); |
58 PatternParts(const PatternParts& other); | 68 PatternParts(const PatternParts& other); |
59 ~PatternParts(); | 69 ~PatternParts(); |
60 | 70 |
61 // Lowercase string of the URL scheme to match. This string is empty if the | 71 // Lowercase string of the URL scheme to match. This string is empty if the |
62 // |is_scheme_wildcard| flag is set. | 72 // |is_scheme_wildcard| flag is set. |
63 std::string scheme; | 73 std::string scheme; |
64 | 74 |
65 // True if the scheme wildcard is set. | 75 // True if the scheme wildcard is set. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 | 181 |
172 // True if |url| matches this pattern. | 182 // True if |url| matches this pattern. |
173 bool Matches(const GURL& url) const; | 183 bool Matches(const GURL& url) const; |
174 | 184 |
175 // True if this pattern matches all hosts (i.e. it has a host wildcard). | 185 // True if this pattern matches all hosts (i.e. it has a host wildcard). |
176 bool MatchesAllHosts() const; | 186 bool MatchesAllHosts() const; |
177 | 187 |
178 // Returns a std::string representation of this pattern. | 188 // Returns a std::string representation of this pattern. |
179 std::string ToString() const; | 189 std::string ToString() const; |
180 | 190 |
191 // Returns scheme type of pattern. | |
192 ContentSettingsPattern::SchemeType GetScheme() const; | |
193 | |
181 // Compares the pattern with a given |other| pattern and returns the | 194 // Compares the pattern with a given |other| pattern and returns the |
182 // |Relation| of the two patterns. | 195 // |Relation| of the two patterns. |
183 Relation Compare(const ContentSettingsPattern& other) const; | 196 Relation Compare(const ContentSettingsPattern& other) const; |
184 | 197 |
185 // Returns true if the pattern and the |other| pattern are identical. | 198 // Returns true if the pattern and the |other| pattern are identical. |
186 bool operator==(const ContentSettingsPattern& other) const; | 199 bool operator==(const ContentSettingsPattern& other) const; |
187 | 200 |
188 // Returns true if the pattern and the |other| pattern are not identical. | 201 // Returns true if the pattern and the |other| pattern are not identical. |
189 bool operator!=(const ContentSettingsPattern& other) const; | 202 bool operator!=(const ContentSettingsPattern& other) const; |
190 | 203 |
(...skipping 27 matching lines...) Expand all Loading... | |
218 const ContentSettingsPattern::PatternParts& other_parts); | 231 const ContentSettingsPattern::PatternParts& other_parts); |
219 | 232 |
220 ContentSettingsPattern(const PatternParts& parts, bool valid); | 233 ContentSettingsPattern(const PatternParts& parts, bool valid); |
221 | 234 |
222 PatternParts parts_; | 235 PatternParts parts_; |
223 | 236 |
224 bool is_valid_; | 237 bool is_valid_; |
225 }; | 238 }; |
226 | 239 |
227 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 240 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
OLD | NEW |