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 #include "components/subresource_filter/core/common/indexed_ruleset.h" | 5 #include "components/subresource_filter/core/common/indexed_ruleset.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "components/subresource_filter/core/common/first_party_origin.h" | 8 #include "components/subresource_filter/core/common/first_party_origin.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 #include "url/origin.h" | 10 #include "url/origin.h" |
11 | 11 |
12 namespace subresource_filter { | 12 namespace subresource_filter { |
13 | 13 |
14 namespace proto = url_pattern_index::proto; | 14 namespace proto = url_pattern_index::proto; |
15 | 15 |
16 // RulesetIndexer -------------------------------------------------------------- | 16 // RulesetIndexer -------------------------------------------------------------- |
17 | 17 |
18 // static | 18 // static |
19 const int RulesetIndexer::kIndexedFormatVersion = 17; | 19 const int RulesetIndexer::kIndexedFormatVersion = 18; |
20 | 20 |
21 RulesetIndexer::RulesetIndexer() | 21 RulesetIndexer::RulesetIndexer() |
22 : blacklist_(&builder_), whitelist_(&builder_), deactivation_(&builder_) {} | 22 : blacklist_(&builder_), whitelist_(&builder_), deactivation_(&builder_) {} |
23 | 23 |
24 RulesetIndexer::~RulesetIndexer() = default; | 24 RulesetIndexer::~RulesetIndexer() = default; |
25 | 25 |
26 bool RulesetIndexer::AddUrlRule(const proto::UrlRule& rule) { | 26 bool RulesetIndexer::AddUrlRule(const proto::UrlRule& rule) { |
27 const auto offset = url_pattern_index::SerializeUrlRule(rule, &builder_); | 27 const auto offset = url_pattern_index::SerializeUrlRule(rule, &builder_); |
28 // Note: A zero offset.o means a "nullptr" offset. It is returned when the | 28 // Note: A zero offset.o means a "nullptr" offset. It is returned when the |
29 // rule has not been serialized. | 29 // rule has not been serialized. |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const bool is_third_party = first_party.IsThirdParty(url); | 87 const bool is_third_party = first_party.IsThirdParty(url); |
88 return !!blacklist_.FindMatch(url, first_party.origin(), element_type, | 88 return !!blacklist_.FindMatch(url, first_party.origin(), element_type, |
89 proto::ACTIVATION_TYPE_UNSPECIFIED, | 89 proto::ACTIVATION_TYPE_UNSPECIFIED, |
90 is_third_party, disable_generic_rules) && | 90 is_third_party, disable_generic_rules) && |
91 !whitelist_.FindMatch(url, first_party.origin(), element_type, | 91 !whitelist_.FindMatch(url, first_party.origin(), element_type, |
92 proto::ACTIVATION_TYPE_UNSPECIFIED, | 92 proto::ACTIVATION_TYPE_UNSPECIFIED, |
93 is_third_party, disable_generic_rules); | 93 is_third_party, disable_generic_rules); |
94 } | 94 } |
95 | 95 |
96 } // namespace subresource_filter | 96 } // namespace subresource_filter |
OLD | NEW |