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 #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" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 content::NavigationThrottle::ThrottleCheckResult | 71 content::NavigationThrottle::ThrottleCheckResult |
72 ActivationStateComputingNavigationThrottle::WillProcessResponse() { | 72 ActivationStateComputingNavigationThrottle::WillProcessResponse() { |
73 // Main frame navigations with disabled page-level activation become | 73 // Main frame navigations with disabled page-level activation become |
74 // pass-through throttles. | 74 // pass-through throttles. |
75 if (!parent_activation_state_ || | 75 if (!parent_activation_state_ || |
76 parent_activation_state_->activation_level == ActivationLevel::DISABLED) { | 76 parent_activation_state_->activation_level == ActivationLevel::DISABLED) { |
77 DCHECK(navigation_handle()->IsInMainFrame()); | 77 DCHECK(navigation_handle()->IsInMainFrame()); |
78 DCHECK(!ruleset_handle_); | 78 DCHECK(!ruleset_handle_); |
79 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 79 return content::NavigationThrottle::PROCEED; |
80 } | 80 } |
81 | 81 |
82 DCHECK(ruleset_handle_); | 82 DCHECK(ruleset_handle_); |
83 AsyncDocumentSubresourceFilter::InitializationParams params; | 83 AsyncDocumentSubresourceFilter::InitializationParams params; |
84 params.document_url = navigation_handle()->GetURL(); | 84 params.document_url = navigation_handle()->GetURL(); |
85 params.parent_activation_state = parent_activation_state_.value(); | 85 params.parent_activation_state = parent_activation_state_.value(); |
86 if (!navigation_handle()->IsInMainFrame()) { | 86 if (!navigation_handle()->IsInMainFrame()) { |
87 content::RenderFrameHost* parent = navigation_handle()->GetParentFrame(); | 87 content::RenderFrameHost* parent = navigation_handle()->GetParentFrame(); |
88 DCHECK(parent); | 88 DCHECK(parent); |
89 params.parent_document_origin = parent->GetLastCommittedOrigin(); | 89 params.parent_document_origin = parent->GetLastCommittedOrigin(); |
90 } | 90 } |
91 | 91 |
92 async_filter_ = base::MakeUnique<AsyncDocumentSubresourceFilter>( | 92 async_filter_ = base::MakeUnique<AsyncDocumentSubresourceFilter>( |
93 ruleset_handle_, std::move(params), | 93 ruleset_handle_, std::move(params), |
94 base::Bind(&ActivationStateComputingNavigationThrottle:: | 94 base::Bind(&ActivationStateComputingNavigationThrottle:: |
95 OnActivationStateComputed, | 95 OnActivationStateComputed, |
96 weak_ptr_factory_.GetWeakPtr())); | 96 weak_ptr_factory_.GetWeakPtr())); |
97 | 97 |
98 defer_timestamp_ = base::TimeTicks::Now(); | 98 defer_timestamp_ = base::TimeTicks::Now(); |
99 return content::NavigationThrottle::ThrottleCheckResult::DEFER; | 99 return content::NavigationThrottle::DEFER; |
100 } | 100 } |
101 | 101 |
102 const char* ActivationStateComputingNavigationThrottle::GetNameForLogging() { | 102 const char* ActivationStateComputingNavigationThrottle::GetNameForLogging() { |
103 return "ActivationStateComputingNavigationThrottle"; | 103 return "ActivationStateComputingNavigationThrottle"; |
104 } | 104 } |
105 | 105 |
106 void ActivationStateComputingNavigationThrottle::OnActivationStateComputed( | 106 void ActivationStateComputingNavigationThrottle::OnActivationStateComputed( |
107 ActivationState state) { | 107 ActivationState state) { |
108 DCHECK(!defer_timestamp_.is_null()); | 108 DCHECK(!defer_timestamp_.is_null()); |
109 base::TimeDelta delay = base::TimeTicks::Now() - defer_timestamp_; | 109 base::TimeDelta delay = base::TimeTicks::Now() - defer_timestamp_; |
(...skipping 17 matching lines...) Expand all Loading... |
127 return will_send_activation_to_renderer_ ? std::move(async_filter_) : nullptr; | 127 return will_send_activation_to_renderer_ ? std::move(async_filter_) : nullptr; |
128 } | 128 } |
129 | 129 |
130 void ActivationStateComputingNavigationThrottle:: | 130 void ActivationStateComputingNavigationThrottle:: |
131 WillSendActivationToRenderer() { | 131 WillSendActivationToRenderer() { |
132 DCHECK(async_filter_); | 132 DCHECK(async_filter_); |
133 will_send_activation_to_renderer_ = true; | 133 will_send_activation_to_renderer_ = true; |
134 } | 134 } |
135 | 135 |
136 } // namespace subresource_filter | 136 } // namespace subresource_filter |
OLD | NEW |