OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 public: | 75 public: |
76 // Returns whether the |buffer| of the given |size| contains a valid | 76 // Returns whether the |buffer| of the given |size| contains a valid |
77 // flat::IndexedRuleset FlatBuffer. | 77 // flat::IndexedRuleset FlatBuffer. |
78 static bool Verify(const uint8_t* buffer, size_t size); | 78 static bool Verify(const uint8_t* buffer, size_t size); |
79 | 79 |
80 // Creates an instance that matches URLs against the flat::IndexedRuleset | 80 // Creates an instance that matches URLs against the flat::IndexedRuleset |
81 // provided as the root object of serialized data in the |buffer| of the given | 81 // provided as the root object of serialized data in the |buffer| of the given |
82 // |size|. | 82 // |size|. |
83 IndexedRulesetMatcher(const uint8_t* buffer, size_t size); | 83 IndexedRulesetMatcher(const uint8_t* buffer, size_t size); |
84 | 84 |
| 85 // Creates an instance that matches URLs against the flat::IndexedRuleset |
| 86 // provided as the root object of serialized data in the |buffer| of the given |
| 87 // |size|. Usage of rules will be recorded to |recorder|. |
| 88 IndexedRulesetMatcher(const uint8_t* buffer, |
| 89 size_t size, |
| 90 std::unique_ptr<RuleRecorder> recorder); |
| 91 |
85 // Returns whether the subset of subresource filtering rules specified by the | 92 // Returns whether the subset of subresource filtering rules specified by the |
86 // |activation_type| should be disabled for the |document| loaded from | 93 // |activation_type| should be disabled for the |document| loaded from |
87 // |parent_document_origin|. Always returns false if |activation_type| == | 94 // |parent_document_origin|. Always returns false if |activation_type| == |
88 // ACTIVATION_TYPE_UNSPECIFIED or the |document_url| is not valid. Unlike | 95 // ACTIVATION_TYPE_UNSPECIFIED or the |document_url| is not valid. Unlike |
89 // page-level activation, such rules can be used to have fine-grained control | 96 // page-level activation, such rules can be used to have fine-grained control |
90 // over the activation of filtering within (sub-)documents. | 97 // over the activation of filtering within (sub-)documents. |
91 bool ShouldDisableFilteringForDocument( | 98 bool ShouldDisableFilteringForDocument( |
92 const GURL& document_url, | 99 const GURL& document_url, |
93 const url::Origin& parent_document_origin, | 100 const url::Origin& parent_document_origin, |
94 proto::ActivationType activation_type) const; | 101 proto::ActivationType activation_type) const; |
95 | 102 |
96 // Returns whether the network request to |url| of |element_type| initiated by | 103 // Returns whether the network request to |url| of |element_type| initiated by |
97 // |document_origin| is not allowed to proceed. Always returns false if the | 104 // |document_origin| is not allowed to proceed. Always returns false if the |
98 // |url| is not valid or |element_type| == ELEMENT_TYPE_UNSPECIFIED. | 105 // |url| is not valid or |element_type| == ELEMENT_TYPE_UNSPECIFIED. |
99 bool ShouldDisallowResourceLoad(const GURL& url, | 106 bool ShouldDisallowResourceLoad(const GURL& url, |
100 const FirstPartyOrigin& first_party, | 107 const FirstPartyOrigin& first_party, |
101 proto::ElementType element_type, | 108 proto::ElementType element_type, |
102 bool disable_generic_rules) const; | 109 bool disable_generic_rules) const; |
103 | 110 |
104 private: | 111 private: |
105 const flat::IndexedRuleset* root_; | 112 const flat::IndexedRuleset* root_; |
106 | 113 |
107 UrlPatternIndexMatcher blacklist_; | 114 UrlPatternIndexMatcher blacklist_; |
108 UrlPatternIndexMatcher whitelist_; | 115 UrlPatternIndexMatcher whitelist_; |
109 UrlPatternIndexMatcher deactivation_; | 116 UrlPatternIndexMatcher deactivation_; |
110 | 117 |
| 118 std::unique_ptr<RuleRecorder> recorder_; |
| 119 |
111 DISALLOW_COPY_AND_ASSIGN(IndexedRulesetMatcher); | 120 DISALLOW_COPY_AND_ASSIGN(IndexedRulesetMatcher); |
112 }; | 121 }; |
113 | 122 |
114 } // namespace subresource_filter | 123 } // namespace subresource_filter |
115 | 124 |
116 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ | 125 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_INDEXED_RULESET_H_ |
OLD | NEW |