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