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_DOCUMENT_SUBRESOURCE_FILTER_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_DOCUMENT_SUBRESOURCE_FILTER_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_DOCUMENT_SUBRESOURCE_FILTER_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_DOCUMENT_SUBRESOURCE_FILTER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 public: | 50 public: |
51 // Constructs a new filter that will: | 51 // Constructs a new filter that will: |
52 // -- Operate in a manner prescribed in |activation_state|. | 52 // -- Operate in a manner prescribed in |activation_state|. |
53 // -- Filter subresource loads in the scope of a document loaded from | 53 // -- Filter subresource loads in the scope of a document loaded from |
54 // |document_origin|. | 54 // |document_origin|. |
55 // -- Hold a reference to and use |ruleset| for its entire lifetime. | 55 // -- Hold a reference to and use |ruleset| for its entire lifetime. |
56 DocumentSubresourceFilter(url::Origin document_origin, | 56 DocumentSubresourceFilter(url::Origin document_origin, |
57 ActivationState activation_state, | 57 ActivationState activation_state, |
58 scoped_refptr<const MemoryMappedRuleset> ruleset); | 58 scoped_refptr<const MemoryMappedRuleset> ruleset); |
59 | 59 |
| 60 // Constructs a new filter that will: |
| 61 // -- Operate in a manner prescribed in |activation_state|. |
| 62 // -- Filter subresource loads in the scope of a document loaded from |
| 63 // |document_origin|. |
| 64 // -- Hold a reference to and use |ruleset| for its entire lifetime. |
| 65 DocumentSubresourceFilter(url::Origin document_origin, |
| 66 ActivationState activation_state, |
| 67 scoped_refptr<const MemoryMappedRuleset> ruleset, |
| 68 std::unique_ptr<RuleRecorder> recorder); |
| 69 |
60 ~DocumentSubresourceFilter(); | 70 ~DocumentSubresourceFilter(); |
61 | 71 |
62 ActivationState activation_state() const { return activation_state_; } | 72 ActivationState activation_state() const { return activation_state_; } |
63 const DocumentLoadStatistics& statistics() const { return statistics_; } | 73 const DocumentLoadStatistics& statistics() const { return statistics_; } |
64 | 74 |
65 // WARNING: This is only to allow DocumentSubresourceFilter's wrappers to | 75 // WARNING: This is only to allow DocumentSubresourceFilter's wrappers to |
66 // modify the |statistics|. | 76 // modify the |statistics|. |
67 // TODO(pkalinnikov): Find a better way to achieve this. | 77 // TODO(pkalinnikov): Find a better way to achieve this. |
68 DocumentLoadStatistics& statistics() { return statistics_; } | 78 DocumentLoadStatistics& statistics() { return statistics_; } |
69 | 79 |
70 LoadPolicy GetLoadPolicy(const GURL& subresource_url, | 80 LoadPolicy GetLoadPolicy(const GURL& subresource_url, |
71 proto::ElementType subresource_type); | 81 proto::ElementType subresource_type); |
72 | 82 |
73 private: | 83 private: |
74 const ActivationState activation_state_; | 84 const ActivationState activation_state_; |
75 const scoped_refptr<const MemoryMappedRuleset> ruleset_; | 85 const scoped_refptr<const MemoryMappedRuleset> ruleset_; |
76 const IndexedRulesetMatcher ruleset_matcher_; | 86 const IndexedRulesetMatcher ruleset_matcher_; |
77 | 87 |
78 // Equals nullptr iff |activation_state_.filtering_disabled_for_document|. | 88 // Equals nullptr iff |activation_state_.filtering_disabled_for_document|. |
79 std::unique_ptr<FirstPartyOrigin> document_origin_; | 89 std::unique_ptr<FirstPartyOrigin> document_origin_; |
80 | 90 |
81 DocumentLoadStatistics statistics_; | 91 DocumentLoadStatistics statistics_; |
82 | 92 |
83 DISALLOW_COPY_AND_ASSIGN(DocumentSubresourceFilter); | 93 DISALLOW_COPY_AND_ASSIGN(DocumentSubresourceFilter); |
84 }; | 94 }; |
85 | 95 |
86 } // namespace subresource_filter | 96 } // namespace subresource_filter |
87 | 97 |
88 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_DOCUMENT_SUBRESOURCE_FILTER
_H_ | 98 #endif // COMPONENTS_SUBRESOURCE_FILTER_CORE_COMMON_DOCUMENT_SUBRESOURCE_FILTER
_H_ |
OLD | NEW |