OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/content_subresource_filt
er_driver_factory.h" | 5 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
6 | 6 |
7 #include "base/feature_list.h" | 7 #include "base/feature_list.h" |
8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 activation_decision_(ActivationDecision::UNKNOWN), | 94 activation_decision_(ActivationDecision::UNKNOWN), |
95 measure_performance_(false) {} | 95 measure_performance_(false) {} |
96 | 96 |
97 ContentSubresourceFilterDriverFactory:: | 97 ContentSubresourceFilterDriverFactory:: |
98 ~ContentSubresourceFilterDriverFactory() {} | 98 ~ContentSubresourceFilterDriverFactory() {} |
99 | 99 |
100 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { | 100 void ContentSubresourceFilterDriverFactory::OnFirstSubresourceLoadDisallowed() { |
101 if (ShouldSuppressNotifications()) | 101 if (ShouldSuppressNotifications()) |
102 return; | 102 return; |
103 | 103 |
104 client_->ToggleNotificationVisibility(activation_level_ == | 104 client_->ToggleNotificationVisibility( |
105 ActivationLevel::ENABLED); | 105 navigation_chain_.back(), activation_level_ == ActivationLevel::ENABLED); |
106 } | 106 } |
107 | 107 |
108 void ContentSubresourceFilterDriverFactory::OnDocumentLoadStatistics( | 108 void ContentSubresourceFilterDriverFactory::OnDocumentLoadStatistics( |
109 const DocumentLoadStatistics& statistics) { | 109 const DocumentLoadStatistics& statistics) { |
110 // Note: Chances of overflow are negligible. | 110 // Note: Chances of overflow are negligible. |
111 aggregated_document_statistics_.num_loads_total += statistics.num_loads_total; | 111 aggregated_document_statistics_.num_loads_total += statistics.num_loads_total; |
112 aggregated_document_statistics_.num_loads_evaluated += | 112 aggregated_document_statistics_.num_loads_evaluated += |
113 statistics.num_loads_evaluated; | 113 statistics.num_loads_evaluated; |
114 aggregated_document_statistics_.num_loads_matching_rules += | 114 aggregated_document_statistics_.num_loads_matching_rules += |
115 statistics.num_loads_matching_rules; | 115 statistics.num_loads_matching_rules; |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 aggregated_document_statistics_ = DocumentLoadStatistics(); | 219 aggregated_document_statistics_ = DocumentLoadStatistics(); |
220 } | 220 } |
221 | 221 |
222 void ContentSubresourceFilterDriverFactory::DidStartNavigation( | 222 void ContentSubresourceFilterDriverFactory::DidStartNavigation( |
223 content::NavigationHandle* navigation_handle) { | 223 content::NavigationHandle* navigation_handle) { |
224 if (navigation_handle->IsInMainFrame() && | 224 if (navigation_handle->IsInMainFrame() && |
225 !navigation_handle->IsSameDocument()) { | 225 !navigation_handle->IsSameDocument()) { |
226 activation_decision_ = ActivationDecision::UNKNOWN; | 226 activation_decision_ = ActivationDecision::UNKNOWN; |
227 ResetActivationState(); | 227 ResetActivationState(); |
228 navigation_chain_.push_back(navigation_handle->GetURL()); | 228 navigation_chain_.push_back(navigation_handle->GetURL()); |
229 client_->ToggleNotificationVisibility(false); | 229 client_->ToggleNotificationVisibility(navigation_handle->GetURL(), false); |
230 } | 230 } |
231 } | 231 } |
232 | 232 |
233 void ContentSubresourceFilterDriverFactory::DidRedirectNavigation( | 233 void ContentSubresourceFilterDriverFactory::DidRedirectNavigation( |
234 content::NavigationHandle* navigation_handle) { | 234 content::NavigationHandle* navigation_handle) { |
235 DCHECK(!navigation_handle->IsSameDocument()); | 235 DCHECK(!navigation_handle->IsSameDocument()); |
236 if (navigation_handle->IsInMainFrame()) | 236 if (navigation_handle->IsInMainFrame()) |
237 navigation_chain_.push_back(navigation_handle->GetURL()); | 237 navigation_chain_.push_back(navigation_handle->GetURL()); |
238 } | 238 } |
239 | 239 |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, | 417 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern, |
418 chain_size); | 418 chain_size); |
419 break; | 419 break; |
420 default: | 420 default: |
421 NOTREACHED(); | 421 NOTREACHED(); |
422 break; | 422 break; |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 } // namespace subresource_filter | 426 } // namespace subresource_filter |
OLD | NEW |