Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(204)

Side by Side Diff: components/subresource_filter/content/browser/activation_state_computing_navigation_throttle.h

Issue 2841933003: [subresource_filter] Remove some state from the driver factory (Closed)
Patch Set: no more dep branch Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_ACTIVATION_STATE_COMPUTING _NAVIGATION_THROTTLE_H_
6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGATIO N_THROTTLE_H_ 6 #define COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ACTIVATION_STATE_COMPUTING _NAVIGATION_THROTTLE_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <utility>
9 10
10 #include "base/macros.h" 11 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/optional.h" 13 #include "base/optional.h"
13 #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"
14 #include "components/subresource_filter/core/common/activation_state.h" 16 #include "components/subresource_filter/core/common/activation_state.h"
15 #include "content/public/browser/navigation_throttle.h" 17 #include "content/public/browser/navigation_throttle.h"
16 18
17 namespace subresource_filter { 19 namespace subresource_filter {
18 20
19 class AsyncDocumentSubresourceFilter; 21 class AsyncDocumentSubresourceFilter;
20 22
21 // NavigationThrottle responsible for determining the activation state of 23 // NavigationThrottle responsible for determining the activation state of
22 // subresource filtering for a given navigation (either in the main frame or in 24 // subresource filtering for a given navigation (either in the main frame or in
23 // a subframe); and for deferring that navigation at WillProcessResponse until 25 // a subframe); and for deferring that navigation at WillProcessResponse until
(...skipping 17 matching lines...) Expand all
41 CreateForSubframe(content::NavigationHandle* navigation_handle, 43 CreateForSubframe(content::NavigationHandle* navigation_handle,
42 VerifiedRuleset::Handle* ruleset_handle, 44 VerifiedRuleset::Handle* ruleset_handle,
43 const ActivationState& parent_activation_state); 45 const ActivationState& parent_activation_state);
44 46
45 ~ActivationStateComputingNavigationThrottle() override; 47 ~ActivationStateComputingNavigationThrottle() override;
46 48
47 // Notification for main frames when the page level activation is computed. 49 // Notification for main frames when the page level activation is computed.
48 // Must be called at most once before WillProcessResponse is called on this 50 // 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, 51 // throttle. If it is never called, or it is called with a DISABLED state,
50 // this object will never delay the navigation. 52 // this object will never delay the navigation.
51 void NotifyPageActivationWithRuleset( 53 void NotifyPageActivationWithRuleset(VerifiedRuleset::Handle* ruleset_handle,
52 VerifiedRuleset::Handle* ruleset_handle, 54 const ActivationState& activation_state,
53 const ActivationState& page_activation_state); 55 ActivationDecision activation_decision);
54 56
55 // content::NavigationThrottle: 57 // content::NavigationThrottle:
56 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse() 58 content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
57 override; 59 override;
58 const char* GetNameForLogging() override; 60 const char* GetNameForLogging() override;
59 61
60 // After the navigation is finished, the client may optionally choose to 62 // After the navigation is finished, the client may optionally choose to
61 // continue using the DocumentSubresourceFilter that was used to compute the 63 // continue using the DocumentSubresourceFilter that was used to compute the
62 // activation state for this frame. The transfered filter can be cached and 64 // activation state for this frame. The transfered filter can be cached and
63 // used to calculate load policy for subframe navigations occuring in this 65 // used to calculate load policy for subframe navigations occuring in this
64 // frame. 66 // frame.
65 std::unique_ptr<AsyncDocumentSubresourceFilter> ReleaseFilter(); 67 std::unique_ptr<AsyncDocumentSubresourceFilter> ReleaseFilter();
66 68
67 AsyncDocumentSubresourceFilter* filter() { return async_filter_.get(); } 69 AsyncDocumentSubresourceFilter* filter() { return async_filter_.get(); }
68 70
71 // Must only be called if this is a main frame throttle.
72 ActivationDecision GetPageActivationDecision();
73
69 void WillSendActivationToRenderer(); 74 void WillSendActivationToRenderer();
70 75
71 private: 76 private:
72 void OnActivationStateComputed(ActivationState state); 77 void OnActivationStateComputed(ActivationState state);
73 void set_filter( 78 void set_filter(
74 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter) { 79 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter) {
75 async_filter_ = std::move(async_filter); 80 async_filter_ = std::move(async_filter);
76 } 81 }
77 82
78 ActivationStateComputingNavigationThrottle( 83 ActivationStateComputingNavigationThrottle(
79 content::NavigationHandle* navigation_handle, 84 content::NavigationHandle* navigation_handle,
80 const base::Optional<ActivationState> parent_activation_state, 85 const base::Optional<ActivationState> parent_activation_state,
81 VerifiedRuleset::Handle* ruleset_handle); 86 VerifiedRuleset::Handle* ruleset_handle);
82 87
83 // Optional to allow for DCHECKing. 88 // Optional to allow for DCHECKing.
84 base::Optional<ActivationState> parent_activation_state_; 89 base::Optional<ActivationState> parent_activation_state_;
85 90
91 // Will only be set on main frame throttles.
92 ActivationDecision page_activation_decision_ = ActivationDecision::UNKNOWN;
93
86 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter_; 94 std::unique_ptr<AsyncDocumentSubresourceFilter> async_filter_;
87 95
88 // Must outlive this class. For main frame navigations, this member will be 96 // Must outlive this class. For main frame navigations, this member will be
89 // nullptr until NotifyPageActivationWithRuleset is called. 97 // nullptr until NotifyPageActivationWithRuleset is called.
90 VerifiedRuleset::Handle* ruleset_handle_; 98 VerifiedRuleset::Handle* ruleset_handle_;
91 99
92 // Becomes true when the throttle manager reaches ReadyToCommitNavigation and 100 // Becomes true when the throttle manager reaches ReadyToCommitNavigation and
93 // sends an activation IPC to the render process. Makes sure a caller cannot 101 // sends an activation IPC to the render process. Makes sure a caller cannot
94 // take ownership of the subresource filter unless an activation IPC is sent 102 // take ownership of the subresource filter unless an activation IPC is sent
95 // to the renderer. 103 // to the renderer.
96 bool will_send_activation_to_renderer_ = false; 104 bool will_send_activation_to_renderer_ = false;
97 105
98 base::WeakPtrFactory<ActivationStateComputingNavigationThrottle> 106 base::WeakPtrFactory<ActivationStateComputingNavigationThrottle>
99 weak_ptr_factory_; 107 weak_ptr_factory_;
100 108
101 DISALLOW_COPY_AND_ASSIGN(ActivationStateComputingNavigationThrottle); 109 DISALLOW_COPY_AND_ASSIGN(ActivationStateComputingNavigationThrottle);
102 }; 110 };
103 111
104 } // namespace subresource_filter 112 } // namespace subresource_filter
105 113
106 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_FRAME_ACTIVATION_NAVIGA TION_THROTTLE_H_ 114 #endif // COMPONENTS_SUBRESOURCE_FILTER_CONTENT_BROWSER_ACTIVATION_STATE_COMPUT ING_NAVIGATION_THROTTLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698