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

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

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 #include "components/subresource_filter/content/browser/activation_state_computi ng_navigation_throttle.h" 5 #include "components/subresource_filter/content/browser/activation_state_computi ng_navigation_throttle.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "components/subresource_filter/content/browser/async_document_subresour ce_filter.h" 12 #include "components/subresource_filter/content/browser/async_document_subresour ce_filter.h"
13 #include "components/subresource_filter/core/browser/subresource_filter_features .h"
13 #include "content/public/browser/navigation_handle.h" 14 #include "content/public/browser/navigation_handle.h"
14 #include "content/public/browser/render_frame_host.h" 15 #include "content/public/browser/render_frame_host.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 17
17 namespace subresource_filter { 18 namespace subresource_filter {
18 19
19 // static 20 // static
20 std::unique_ptr<ActivationStateComputingNavigationThrottle> 21 std::unique_ptr<ActivationStateComputingNavigationThrottle>
21 ActivationStateComputingNavigationThrottle::CreateForMainFrame( 22 ActivationStateComputingNavigationThrottle::CreateForMainFrame(
22 content::NavigationHandle* navigation_handle) { 23 content::NavigationHandle* navigation_handle) {
(...skipping 25 matching lines...) Expand all
48 parent_activation_state_(parent_activation_state), 49 parent_activation_state_(parent_activation_state),
49 ruleset_handle_(ruleset_handle), 50 ruleset_handle_(ruleset_handle),
50 weak_ptr_factory_(this) {} 51 weak_ptr_factory_(this) {}
51 52
52 ActivationStateComputingNavigationThrottle:: 53 ActivationStateComputingNavigationThrottle::
53 ~ActivationStateComputingNavigationThrottle() {} 54 ~ActivationStateComputingNavigationThrottle() {}
54 55
55 void ActivationStateComputingNavigationThrottle:: 56 void ActivationStateComputingNavigationThrottle::
56 NotifyPageActivationWithRuleset( 57 NotifyPageActivationWithRuleset(
57 VerifiedRuleset::Handle* ruleset_handle, 58 VerifiedRuleset::Handle* ruleset_handle,
58 const ActivationState& page_activation_state) { 59 const ActivationState& page_activation_state,
60 ActivationDecision page_activation_decision) {
59 DCHECK(navigation_handle()->IsInMainFrame()); 61 DCHECK(navigation_handle()->IsInMainFrame());
60 DCHECK(!parent_activation_state_); 62 DCHECK(!parent_activation_state_);
61 DCHECK(!ruleset_handle_); 63 DCHECK(!ruleset_handle_);
62 // DISABLED implies null ruleset. 64 parent_activation_state_ = page_activation_state;
65 page_activation_decision_ = page_activation_decision;
66 ruleset_handle_ = ruleset_handle;
67
68 // Activated implies not disabled.
69 DCHECK(page_activation_decision != ActivationDecision::ACTIVATED ||
70 page_activation_state.activation_level != ActivationLevel::DISABLED);
71 // Disabled implies null ruleset.
63 DCHECK(page_activation_state.activation_level != ActivationLevel::DISABLED || 72 DCHECK(page_activation_state.activation_level != ActivationLevel::DISABLED ||
64 !ruleset_handle); 73 !ruleset_handle);
65 parent_activation_state_ = page_activation_state;
66 ruleset_handle_ = ruleset_handle;
67 } 74 }
68 75
69 content::NavigationThrottle::ThrottleCheckResult 76 content::NavigationThrottle::ThrottleCheckResult
70 ActivationStateComputingNavigationThrottle::WillProcessResponse() { 77 ActivationStateComputingNavigationThrottle::WillProcessResponse() {
71 // Main frame navigations with disabled page-level activation become 78 // Main frame navigations with disabled page-level activation become
72 // pass-through throttles. 79 // pass-through throttles.
73 if (!parent_activation_state_ || 80 if (!parent_activation_state_ ||
74 parent_activation_state_->activation_level == ActivationLevel::DISABLED) { 81 parent_activation_state_->activation_level == ActivationLevel::DISABLED) {
75 DCHECK(navigation_handle()->IsInMainFrame()); 82 DCHECK(navigation_handle()->IsInMainFrame());
76 DCHECK(!ruleset_handle_); 83 DCHECK(!ruleset_handle_);
(...skipping 29 matching lines...) Expand all
106 navigation_handle()->Resume(); 113 navigation_handle()->Resume();
107 } 114 }
108 115
109 // Ensure the caller cannot take ownership of a subresource filter for cases 116 // Ensure the caller cannot take ownership of a subresource filter for cases
110 // when activation IPCs are not sent to the render process. 117 // when activation IPCs are not sent to the render process.
111 std::unique_ptr<AsyncDocumentSubresourceFilter> 118 std::unique_ptr<AsyncDocumentSubresourceFilter>
112 ActivationStateComputingNavigationThrottle::ReleaseFilter() { 119 ActivationStateComputingNavigationThrottle::ReleaseFilter() {
113 return will_send_activation_to_renderer_ ? std::move(async_filter_) : nullptr; 120 return will_send_activation_to_renderer_ ? std::move(async_filter_) : nullptr;
114 } 121 }
115 122
123 ActivationDecision
124 ActivationStateComputingNavigationThrottle::GetPageActivationDecision() {
125 DCHECK(navigation_handle()->IsInMainFrame());
126 return page_activation_decision_;
127 }
128
116 void ActivationStateComputingNavigationThrottle:: 129 void ActivationStateComputingNavigationThrottle::
117 WillSendActivationToRenderer() { 130 WillSendActivationToRenderer() {
118 DCHECK(async_filter_); 131 DCHECK(async_filter_);
119 will_send_activation_to_renderer_ = true; 132 will_send_activation_to_renderer_ = true;
120 } 133 }
121 134
122 } // namespace subresource_filter 135 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698