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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/rand_util.h" | 8 #include "base/rand_util.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" | 10 #include "components/subresource_filter/content/browser/subresource_filter_clien
t.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 ActivationDecision activation_decision, | 66 ActivationDecision activation_decision, |
67 Configuration::ActivationOptions matched_options) { | 67 Configuration::ActivationOptions matched_options) { |
68 DCHECK(navigation_handle->IsInMainFrame()); | 68 DCHECK(navigation_handle->IsInMainFrame()); |
69 DCHECK(!navigation_handle->IsSameDocument()); | 69 DCHECK(!navigation_handle->IsSameDocument()); |
70 if (navigation_handle->GetNetErrorCode() != net::OK) | 70 if (navigation_handle->GetNetErrorCode() != net::OK) |
71 return; | 71 return; |
72 | 72 |
73 activation_decision_ = activation_decision; | 73 activation_decision_ = activation_decision; |
74 activation_options_ = matched_options; | 74 activation_options_ = matched_options; |
75 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); | 75 DCHECK_NE(activation_decision_, ActivationDecision::UNKNOWN); |
76 if (activation_decision_ != ActivationDecision::ACTIVATED) { | |
77 DCHECK_EQ(activation_options_.activation_level, ActivationLevel::DISABLED); | |
78 return; | |
79 } | |
80 | 76 |
81 DCHECK_NE(activation_options_.activation_level, ActivationLevel::DISABLED); | 77 // ACTIVATION_DISABLED implies DISABLED activation level. |
| 78 DCHECK(activation_decision_ != ActivationDecision::ACTIVATION_DISABLED || |
| 79 activation_options_.activation_level == ActivationLevel::DISABLED); |
82 ActivationState state = ActivationState(activation_options_.activation_level); | 80 ActivationState state = ActivationState(activation_options_.activation_level); |
83 state.measure_performance = ShouldMeasurePerformanceForPageLoad( | 81 state.measure_performance = ShouldMeasurePerformanceForPageLoad( |
84 activation_options_.performance_measurement_rate); | 82 activation_options_.performance_measurement_rate); |
85 | 83 |
86 // TODO(csharrison): Also use metadata returned from the safe browsing filter, | 84 // TODO(csharrison): Also use metadata returned from the safe browsing filter, |
87 // when it is available to set enable_logging. Add tests for this behavior. | 85 // when it is available to set enable_logging. Add tests for this behavior. |
88 state.enable_logging = | 86 state.enable_logging = |
89 activation_options_.activation_level == ActivationLevel::ENABLED && | 87 activation_options_.activation_level == ActivationLevel::ENABLED && |
90 !activation_options_.should_suppress_notifications && | 88 !activation_options_.should_suppress_notifications && |
91 base::FeatureList::IsEnabled( | 89 base::FeatureList::IsEnabled( |
(...skipping 25 matching lines...) Expand all Loading... |
117 if (navigation_handle->IsInMainFrame() && | 115 if (navigation_handle->IsInMainFrame() && |
118 !navigation_handle->IsSameDocument() && | 116 !navigation_handle->IsSameDocument() && |
119 activation_decision_ == ActivationDecision::UNKNOWN && | 117 activation_decision_ == ActivationDecision::UNKNOWN && |
120 navigation_handle->HasCommitted()) { | 118 navigation_handle->HasCommitted()) { |
121 activation_decision_ = ActivationDecision::ACTIVATION_DISABLED; | 119 activation_decision_ = ActivationDecision::ACTIVATION_DISABLED; |
122 activation_options_ = Configuration::ActivationOptions(); | 120 activation_options_ = Configuration::ActivationOptions(); |
123 } | 121 } |
124 } | 122 } |
125 | 123 |
126 } // namespace subresource_filter | 124 } // namespace subresource_filter |
OLD | NEW |