OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER
_THROTTLE_MANAGER_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER
_THROTTLE_MANAGER_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER
_THROTTLE_MANAGER_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FILTER
_THROTTLE_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <unordered_map> | 9 #include <unordered_map> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "components/subresource_filter/content/browser/verified_ruleset_dealer.
h" | 14 #include "components/subresource_filter/content/browser/verified_ruleset_dealer.
h" |
| 15 #include "components/subresource_filter/core/common/activation_decision.h" |
15 #include "components/subresource_filter/core/common/activation_state.h" | 16 #include "components/subresource_filter/core/common/activation_state.h" |
16 #include "content/public/browser/web_contents_observer.h" | 17 #include "content/public/browser/web_contents_observer.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 class NavigationHandle; | 20 class NavigationHandle; |
20 class NavigationThrottle; | 21 class NavigationThrottle; |
21 class RenderFrameHost; | 22 class RenderFrameHost; |
22 } // namespace content | 23 } // namespace content |
23 | 24 |
24 namespace IPC { | 25 namespace IPC { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 72 |
72 // Sets the desired page-level |activation_state| for the currently ongoing | 73 // Sets the desired page-level |activation_state| for the currently ongoing |
73 // page load, identified by its main-frame |navigation_handle|. To be called | 74 // page load, identified by its main-frame |navigation_handle|. To be called |
74 // by the embedder at the latest in the WillProcessResponse stage from a | 75 // by the embedder at the latest in the WillProcessResponse stage from a |
75 // NavigationThrottle that was registered before the throttles created by this | 76 // NavigationThrottle that was registered before the throttles created by this |
76 // manager in MaybeAppendNavigationThrottles(). If this method is not called | 77 // manager in MaybeAppendNavigationThrottles(). If this method is not called |
77 // for a main-frame navigation, the default behavior is no activation for that | 78 // for a main-frame navigation, the default behavior is no activation for that |
78 // page load. | 79 // page load. |
79 void NotifyPageActivationComputed( | 80 void NotifyPageActivationComputed( |
80 content::NavigationHandle* navigation_handle, | 81 content::NavigationHandle* navigation_handle, |
81 const ActivationState& activation_state); | 82 const ActivationState& activation_state, |
| 83 ActivationDecision activation_decision); |
82 | 84 |
83 // This method inspects |navigation_handle| and attaches navigation throttles | 85 // This method inspects |navigation_handle| and attaches navigation throttles |
84 // appropriately, based on the current state of frame activation. | 86 // appropriately, based on the current state of frame activation. |
85 // | 87 // |
86 // 1. Subframe navigation filtering throttles are appended if the parent | 88 // 1. Subframe navigation filtering throttles are appended if the parent |
87 // frame is activated. | 89 // frame is activated. |
88 // 2. Activation state computing throttles are appended if either the | 90 // 2. Activation state computing throttles are appended if either the |
89 // navigation is a main frame navigation, or if the parent frame is activated. | 91 // navigation is a main frame navigation, or if the parent frame is activated. |
90 // | 92 // |
91 // Note that there is currently no constraints on the ordering of throttles. | 93 // Note that there is currently no constraints on the ordering of throttles. |
92 void MaybeAppendNavigationThrottles( | 94 void MaybeAppendNavigationThrottles( |
93 content::NavigationHandle* navigation_handle, | 95 content::NavigationHandle* navigation_handle, |
94 std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles); | 96 std::vector<std::unique_ptr<content::NavigationThrottle>>* throttles); |
95 | 97 |
96 // Returns whether or not the current WebContents is allowed to create a new | 98 // Returns whether or not the current WebContents is allowed to create a new |
97 // window. | 99 // window. |
98 bool ShouldDisallowNewWindow(); | 100 bool ShouldDisallowNewWindow(); |
99 | 101 |
100 VerifiedRuleset::Handle* ruleset_handle_for_testing() { | 102 VerifiedRuleset::Handle* ruleset_handle_for_testing() { |
101 return ruleset_handle_.get(); | 103 return ruleset_handle_.get(); |
102 } | 104 } |
103 | 105 |
| 106 // Returns the |ActivationDecision| for the current main frame document. |
| 107 ActivationDecision GetActivationDecisionForLastCommittedPageLoad() const { |
| 108 return activation_decision_; |
| 109 } |
| 110 |
104 protected: | 111 protected: |
105 // content::WebContentsObserver: | 112 // content::WebContentsObserver: |
106 void RenderFrameDeleted(content::RenderFrameHost* frame_host) override; | 113 void RenderFrameDeleted(content::RenderFrameHost* frame_host) override; |
107 void ReadyToCommitNavigation( | 114 void ReadyToCommitNavigation( |
108 content::NavigationHandle* navigation_handle) override; | 115 content::NavigationHandle* navigation_handle) override; |
109 void DidFinishNavigation( | 116 void DidFinishNavigation( |
110 content::NavigationHandle* navigation_handle) override; | 117 content::NavigationHandle* navigation_handle) override; |
111 void DidFinishLoad(content::RenderFrameHost* render_frame_host, | 118 void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
112 const GURL& validated_url) override; | 119 const GURL& validated_url) override; |
113 bool OnMessageReceived(const IPC::Message& message, | 120 bool OnMessageReceived(const IPC::Message& message, |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // RenderFrameHosts (i.e. activated_frame_hosts_ is empty). | 160 // RenderFrameHosts (i.e. activated_frame_hosts_ is empty). |
154 std::unique_ptr<VerifiedRuleset::Handle> ruleset_handle_; | 161 std::unique_ptr<VerifiedRuleset::Handle> ruleset_handle_; |
155 | 162 |
156 std::unique_ptr<PageLoadStatistics> statistics_; | 163 std::unique_ptr<PageLoadStatistics> statistics_; |
157 | 164 |
158 // True if the current committed main frame load in this WebContents has | 165 // True if the current committed main frame load in this WebContents has |
159 // notified the delegate that a subresource was disallowed. The callback | 166 // notified the delegate that a subresource was disallowed. The callback |
160 // should only be called at most once per main frame load. | 167 // should only be called at most once per main frame load. |
161 bool current_committed_load_has_notified_disallowed_load_ = false; | 168 bool current_committed_load_has_notified_disallowed_load_ = false; |
162 | 169 |
| 170 // The activation decision for the last committed main frame navigation. |
| 171 ActivationDecision activation_decision_ = ActivationDecision::UNKNOWN; |
| 172 |
163 // These members outlive this class. | 173 // These members outlive this class. |
164 VerifiedRulesetDealer::Handle* dealer_handle_; | 174 VerifiedRulesetDealer::Handle* dealer_handle_; |
165 Delegate* delegate_; | 175 Delegate* delegate_; |
166 | 176 |
167 base::WeakPtrFactory<ContentSubresourceFilterThrottleManager> | 177 base::WeakPtrFactory<ContentSubresourceFilterThrottleManager> |
168 weak_ptr_factory_; | 178 weak_ptr_factory_; |
169 | 179 |
170 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterThrottleManager); | 180 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterThrottleManager); |
171 }; | 181 }; |
172 | 182 |
173 } // namespace subresource_filter | 183 } // namespace subresource_filter |
174 | 184 |
175 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL
TER_THROTTLE_MANAGER_H_ | 185 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL
TER_THROTTLE_MANAGER_H_ |
OLD | NEW |