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_FRAME_ACTIVATION_NAVIGATIO N_THROTTLE_H_ | 5 #ifndef COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGATIO N_THROTTLE_H_ |
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGATIO N_THROTTLE_H_ | 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGATIO N_THROTTLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 22 matching lines...) Expand all Loading... | |
33 // has been established that activation computation is needed. | 33 // has been established that activation computation is needed. |
34 static std::unique_ptr<ActivationStateComputingNavigationThrottle> | 34 static std::unique_ptr<ActivationStateComputingNavigationThrottle> |
35 CreateForMainFrame(content::NavigationHandle* navigation_handle); | 35 CreateForMainFrame(content::NavigationHandle* navigation_handle); |
36 | 36 |
37 // It is illegal to create an activation computing throttle for subframes | 37 // It is illegal to create an activation computing throttle for subframes |
38 // whose parents are not activated. Similarly, |ruleset_handle| should be | 38 // whose parents are not activated. Similarly, |ruleset_handle| should be |
39 // non-null. | 39 // non-null. |
40 static std::unique_ptr<ActivationStateComputingNavigationThrottle> | 40 static std::unique_ptr<ActivationStateComputingNavigationThrottle> |
41 CreateForSubframe(content::NavigationHandle* navigation_handle, | 41 CreateForSubframe(content::NavigationHandle* navigation_handle, |
42 VerifiedRuleset::Handle* ruleset_handle, | 42 VerifiedRuleset::Handle* ruleset_handle, |
43 const ActivationState& parent_activation_state); | 43 const ActivationState& parent_activation_state, |
44 base::OnceClosure first_disallowed_load_callback); | |
engedy
2017/03/10 17:36:20
optional nit: On second read, it seems a bit weird
Charlie Harrison
2017/03/14 23:18:31
Sure. I added a setter on the ADSF.
| |
44 | 45 |
45 ~ActivationStateComputingNavigationThrottle() override; | 46 ~ActivationStateComputingNavigationThrottle() override; |
46 | 47 |
47 // Notification for main frames when the page level activation is computed. | 48 // Notification for main frames when the page level activation is computed. |
48 // Must be called at most once before WillProcessResponse is called on this | 49 // Must be called at most once before WillProcessResponse is called on this |
49 // throttle. If it is never called, or it is called with a DISABLED state, | 50 // throttle. If it is never called, or it is called with a DISABLED state, |
50 // this object will never delay the navigation. | 51 // this object will never delay the navigation. |
51 void NotifyPageActivationWithRuleset( | 52 void NotifyPageActivationWithRuleset( |
52 VerifiedRuleset::Handle* ruleset_handle, | 53 VerifiedRuleset::Handle* ruleset_handle, |
53 const ActivationState& page_activation_state); | 54 const ActivationState& page_activation_state, |
55 base::OnceClosure first_disallowed_load_callback); | |
54 | 56 |
55 // content::NavigationThrottle: | 57 // content::NavigationThrottle: |
56 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() | 58 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() |
57 override; | 59 override; |
58 | 60 |
59 // After the navigation is finished, the client may optionally choose to | 61 // After the navigation is finished, the client may optionally choose to |
60 // continue using the DocumentSubresourceFilter that was used to compute the | 62 // continue using the DocumentSubresourceFilter that was used to compute the |
61 // activation state for this frame. The transfered filter can be cached and | 63 // activation state for this frame. The transfered filter can be cached and |
62 // used to calculate load policy for subframe navigations occuring in this | 64 // used to calculate load policy for subframe navigations occuring in this |
63 // frame. | 65 // frame. |
64 std::unique_ptr<AsyncDocumentSubresourceFilter> ReleaseFilter(); | 66 std::unique_ptr<AsyncDocumentSubresourceFilter> ReleaseFilter(); |
65 | 67 |
66 // Gets the activation state calculated for this navigation. Must be called | 68 // Gets the activation state calculated for this navigation. Must be called |
67 // after the navigation is resumed from getting paused in WillProcessResponse, | 69 // after the navigation is resumed from getting paused in WillProcessResponse, |
68 // which, for example, will have happened at ReadyToCommitNavigation. | 70 // which, for example, will have happened at ReadyToCommitNavigation. |
69 const ActivationState& GetActivationState() const; | 71 const ActivationState& GetActivationState() const; |
engedy
2017/03/10 17:36:20
Now that the ADSF has the state, do we need this a
Charlie Harrison
2017/03/14 23:18:31
Nope, removed.
| |
70 | 72 |
71 private: | 73 private: |
72 void SetActivationStateAndResume(ActivationState state); | 74 void SetActivationStateAndResume(ActivationState state); |
73 | 75 |
74 ActivationStateComputingNavigationThrottle( | 76 ActivationStateComputingNavigationThrottle( |
75 content::NavigationHandle* navigation_handle, | 77 content::NavigationHandle* navigation_handle, |
76 const base::Optional<ActivationState> parent_activation_state, | 78 const base::Optional<ActivationState> parent_activation_state, |
77 VerifiedRuleset::Handle* ruleset_handle); | 79 VerifiedRuleset::Handle* ruleset_handle, |
80 base::OnceClosure first_disallowed_load_callback); | |
78 | 81 |
79 // These members are optional to allow DCHECKing their existence at certain | 82 // These members are optional to allow DCHECKing their existence at certain |
80 // points in the navigation flow. | 83 // points in the navigation flow. |
81 base::Optional<ActivationState> activation_state_; | 84 base::Optional<ActivationState> activation_state_; |
82 base::Optional<ActivationState> parent_activation_state_; | 85 base::Optional<ActivationState> parent_activation_state_; |
83 | 86 |
84 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter_; | 87 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter_; |
85 | 88 |
86 // Must outlive this class. For main frame navigations, this member will be | 89 // Must outlive this class. For main frame navigations, this member will be |
87 // nullptr until NotifyPageActivationWithRuleset is called. | 90 // nullptr until NotifyPageActivationWithRuleset is called. |
88 VerifiedRuleset::Handle* ruleset_handle_; | 91 VerifiedRuleset::Handle* ruleset_handle_; |
89 | 92 |
93 base::OnceClosure first_disallowed_load_callback_; | |
94 | |
90 base::WeakPtrFactory<ActivationStateComputingNavigationThrottle> | 95 base::WeakPtrFactory<ActivationStateComputingNavigationThrottle> |
91 weak_ptr_factory_; | 96 weak_ptr_factory_; |
92 | 97 |
93 DISALLOW_COPY_AND_ASSIGN(ActivationStateComputingNavigationThrottle); | 98 DISALLOW_COPY_AND_ASSIGN(ActivationStateComputingNavigationThrottle); |
94 }; | 99 }; |
95 | 100 |
96 } // namespace subresource_filter | 101 } // namespace subresource_filter |
97 | 102 |
98 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGA TION_THROTTLE_H_ | 103 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGA TION_THROTTLE_H_ |
OLD | NEW |