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> |
(...skipping 29 matching lines...) Expand all Loading... |
40 // | 40 // |
41 // The class is designed to be used by a Delegate, which shares lifetime with | 41 // The class is designed to be used by a Delegate, which shares lifetime with |
42 // this class (aka the typical lifetime of a WebContentsObserver). The delegate | 42 // this class (aka the typical lifetime of a WebContentsObserver). The delegate |
43 // will be notified of the first disallowed subresource load for a top level | 43 // will be notified of the first disallowed subresource load for a top level |
44 // navgation, and has veto power for frame activation. | 44 // navgation, and has veto power for frame activation. |
45 class ContentSubresourceFilterThrottleManager | 45 class ContentSubresourceFilterThrottleManager |
46 : public content::WebContentsObserver { | 46 : public content::WebContentsObserver { |
47 public: | 47 public: |
48 // It is expected that the Delegate outlives |this|, and manages the lifetime | 48 // It is expected that the Delegate outlives |this|, and manages the lifetime |
49 // of this class. | 49 // of this class. |
| 50 // TODO(csharrison): Remove this in favor of the SubresourceFilterClient. |
50 class Delegate { | 51 class Delegate { |
51 public: | 52 public: |
52 // The embedder may be interested in displaying UI to the user when the | 53 // The embedder may be interested in displaying UI to the user when the |
53 // first load is disallowed for a given page load. | 54 // first load is disallowed for a given page load. |
54 virtual void OnFirstSubresourceLoadDisallowed() {} | 55 virtual void OnFirstSubresourceLoadDisallowed() {} |
55 | 56 |
56 // Let the delegate have the last word when it comes to activation. It might | 57 // Let the delegate have the last word when it comes to activation. It might |
57 // have a specific whitelist. | 58 // have a specific whitelist. |
58 virtual bool ShouldSuppressActivation( | 59 virtual bool ShouldSuppressActivation( |
59 content::NavigationHandle* navigation_handle); | 60 content::NavigationHandle* navigation_handle); |
60 | 61 |
61 // Temporary method to help the delegate compute the activation decision. | 62 // Temporary method to help the delegate compute the activation decision. |
62 virtual void WillProcessResponse( | 63 virtual void WillProcessResponse( |
63 content::NavigationHandle* navigation_handle) {} | 64 content::NavigationHandle* navigation_handle) {} |
| 65 |
| 66 virtual void OnPageActivated(const ActivationState& activation_state) {} |
64 }; | 67 }; |
65 | 68 |
66 ContentSubresourceFilterThrottleManager( | 69 ContentSubresourceFilterThrottleManager( |
67 Delegate* delegate, | 70 Delegate* delegate, |
68 VerifiedRulesetDealer::Handle* dealer_handle, | 71 VerifiedRulesetDealer::Handle* dealer_handle, |
69 content::WebContents* web_contents); | 72 content::WebContents* web_contents); |
70 ~ContentSubresourceFilterThrottleManager() override; | 73 ~ContentSubresourceFilterThrottleManager() override; |
71 | 74 |
72 // Sets the desired page-level |activation_state| for the currently ongoing | 75 // Sets the desired page-level |activation_state| for the currently ongoing |
73 // page load, identified by its main-frame |navigation_handle|. To be called | 76 // page load, identified by its main-frame |navigation_handle|. To be called |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 169 |
167 base::WeakPtrFactory<ContentSubresourceFilterThrottleManager> | 170 base::WeakPtrFactory<ContentSubresourceFilterThrottleManager> |
168 weak_ptr_factory_; | 171 weak_ptr_factory_; |
169 | 172 |
170 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterThrottleManager); | 173 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterThrottleManager); |
171 }; | 174 }; |
172 | 175 |
173 } // namespace subresource_filter | 176 } // namespace subresource_filter |
174 | 177 |
175 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL
TER_THROTTLE_MANAGER_H_ | 178 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_CONTENT_SUBRESOURCE_FIL
TER_THROTTLE_MANAGER_H_ |
OLD | NEW |