OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ | 7 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ |
8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ | 8 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <ostream> | 11 #include <ostream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 | 15 |
16 class GURL; | 16 class GURL; |
17 | 17 |
18 namespace content_settings { | 18 namespace content_settings { |
19 class PatternParser; | 19 class PatternParser; |
20 } | 20 } |
21 | 21 |
22 // A pattern used in content setting rules. See |IsValid| for a description of | 22 // A pattern used in content setting rules. See |IsValid| for a description of |
23 // possible patterns. | 23 // possible patterns. |
24 class ContentSettingsPattern { | 24 class ContentSettingsPattern { |
25 public: | 25 public: |
26 // Each content settings pattern describes a set of origins. Patterns, and the | 26 // Each content settings pattern describes a set of origins. Patterns, and the |
27 // sets they describe, have specific relations. |Relation| describes the | 27 // sets they describe, have specific relations. |Relation| describes the |
28 // relation of two patterns A and B. When pattern A is compared with pattern B | 28 // relation of two patterns A and B. When pattern A is compared with pattern B |
29 // (A compare B) interessting relations are: | 29 // (|A.Compare(B)|) interesting relations are: |
30 // - IDENTITY : Pattern A and B are identical. The patterns are equal. | 30 // - IDENTITY: Pattern A and B are identical. The patterns are equal. |
31 // - DISJOINT : Pattern A and B have no intersection. A and B never match | 31 // - DISJOINT: Pattern A and B have no intersection. A and B never both |
32 // a the origin of a URL at the same time. | 32 // match the origin of a URL. |
33 // - SUCCESSOR : Pattern A and B have an intersection. But pattern B has a | 33 // - SUCCESSOR: Pattern A and B have an intersection. But pattern B has a |
34 // higher precedence than pattern A for URLs that are matched | 34 // higher precedence than pattern A for URLs that are matched |
35 // by both pattern. | 35 // by both pattern. |
36 // - PREDECESSOR : Pattern A and B have an intersection. But pattern A has a | 36 // - PREDECESSOR: Pattern A and B have an intersection. But pattern A has a |
37 // higher precedence than pattern B for URLs that are matched | 37 // higher precedence than pattern B for URLs that are matched |
38 // by both pattern. | 38 // by both pattern. |
39 enum Relation { | 39 enum Relation { |
40 DISJOINT = -2, | 40 DISJOINT = -2, |
41 SUCCESSOR = -1, | 41 SUCCESSOR = -1, |
42 IDENTITY = 0, | 42 IDENTITY = 0, |
43 PREDECESSOR = 1, | 43 PREDECESSOR = 1, |
44 }; | 44 }; |
45 | 45 |
46 class BuilderInterface { | 46 class BuilderInterface { |
47 public: | 47 public: |
48 virtual ~BuilderInterface() {} | 48 virtual ~BuilderInterface() {} |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 }; | 218 }; |
219 | 219 |
220 // Stream operator so ContentSettingsPattern can be used in assertion | 220 // Stream operator so ContentSettingsPattern can be used in assertion |
221 // statements. | 221 // statements. |
222 inline std::ostream& operator<<( | 222 inline std::ostream& operator<<( |
223 std::ostream& out, const ContentSettingsPattern& pattern) { | 223 std::ostream& out, const ContentSettingsPattern& pattern) { |
224 return out << pattern.ToString(); | 224 return out << pattern.ToString(); |
225 } | 225 } |
226 | 226 |
227 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ | 227 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_PATTERN_H_ |
OLD | NEW |