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 { |
| 57 SCHEME_UNKNOWN, |
| 58 SCHEME_HTTP, |
| 59 SCHEME_HTTPS, |
| 60 SCHEME_FILE, |
| 61 SCHEME_CHROMEEXTENSION, |
| 62 SCHEME_MAX, |
| 63 }; |
| 64 |
56 struct PatternParts { | 65 struct PatternParts { |
57 PatternParts(); | 66 PatternParts(); |
58 PatternParts(const PatternParts& other); | 67 PatternParts(const PatternParts& other); |
59 ~PatternParts(); | 68 ~PatternParts(); |
60 | 69 |
61 // Lowercase string of the URL scheme to match. This string is empty if the | 70 // Lowercase string of the URL scheme to match. This string is empty if the |
62 // |is_scheme_wildcard| flag is set. | 71 // |is_scheme_wildcard| flag is set. |
63 std::string scheme; | 72 std::string scheme; |
64 | 73 |
65 // True if the scheme wildcard is set. | 74 // True if the scheme wildcard is set. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 180 |
172 // True if |url| matches this pattern. | 181 // True if |url| matches this pattern. |
173 bool Matches(const GURL& url) const; | 182 bool Matches(const GURL& url) const; |
174 | 183 |
175 // True if this pattern matches all hosts (i.e. it has a host wildcard). | 184 // True if this pattern matches all hosts (i.e. it has a host wildcard). |
176 bool MatchesAllHosts() const; | 185 bool MatchesAllHosts() const; |
177 | 186 |
178 // Returns a std::string representation of this pattern. | 187 // Returns a std::string representation of this pattern. |
179 std::string ToString() const; | 188 std::string ToString() const; |
180 | 189 |
| 190 // Returns scheme type of pattern. |
| 191 ContentSettingsPattern::SchemeType GetScheme() const; |
| 192 |
181 // Compares the pattern with a given |other| pattern and returns the | 193 // Compares the pattern with a given |other| pattern and returns the |
182 // |Relation| of the two patterns. | 194 // |Relation| of the two patterns. |
183 Relation Compare(const ContentSettingsPattern& other) const; | 195 Relation Compare(const ContentSettingsPattern& other) const; |
184 | 196 |
185 // Returns true if the pattern and the |other| pattern are identical. | 197 // Returns true if the pattern and the |other| pattern are identical. |
186 bool operator==(const ContentSettingsPattern& other) const; | 198 bool operator==(const ContentSettingsPattern& other) const; |
187 | 199 |
188 // Returns true if the pattern and the |other| pattern are not identical. | 200 // Returns true if the pattern and the |other| pattern are not identical. |
189 bool operator!=(const ContentSettingsPattern& other) const; | 201 bool operator!=(const ContentSettingsPattern& other) const; |
190 | 202 |
(...skipping 27 matching lines...) Expand all Loading... |
218 const ContentSettingsPattern::PatternParts& other_parts); | 230 const ContentSettingsPattern::PatternParts& other_parts); |
219 | 231 |
220 ContentSettingsPattern(const PatternParts& parts, bool valid); | 232 ContentSettingsPattern(const PatternParts& parts, bool valid); |
221 | 233 |
222 PatternParts parts_; | 234 PatternParts parts_; |
223 | 235 |
224 bool is_valid_; | 236 bool is_valid_; |
225 }; | 237 }; |
226 | 238 |
227 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ | 239 #endif // COMPONENTS_CONTENT_SETTINGS_CORE_COMMON_CONTENT_SETTINGS_PATTERN_H_ |
OLD | NEW |