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/subresource_filter_safe_
browsing_activation_throttle.h" | 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 | 76 |
77 content::NavigationThrottle::ThrottleCheckResult | 77 content::NavigationThrottle::ThrottleCheckResult |
78 SubresourceFilterSafeBrowsingActivationThrottle::WillRedirectRequest() { | 78 SubresourceFilterSafeBrowsingActivationThrottle::WillRedirectRequest() { |
79 CheckCurrentUrl(); | 79 CheckCurrentUrl(); |
80 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 80 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; |
81 } | 81 } |
82 | 82 |
83 content::NavigationThrottle::ThrottleCheckResult | 83 content::NavigationThrottle::ThrottleCheckResult |
84 SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() { | 84 SubresourceFilterSafeBrowsingActivationThrottle::WillProcessResponse() { |
| 85 if (!database_client_) |
| 86 return content::NavigationThrottle::PROCEED; |
| 87 |
85 // No need to defer the navigation if the check already happened. | 88 // No need to defer the navigation if the check already happened. |
86 if (!database_client_ || check_results_.back().finished) { | 89 if (check_results_.back().finished) { |
87 NotifyResult(); | 90 NotifyResult(); |
88 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; | 91 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; |
89 } | 92 } |
90 defer_time_ = base::TimeTicks::Now(); | 93 defer_time_ = base::TimeTicks::Now(); |
91 return content::NavigationThrottle::ThrottleCheckResult::DEFER; | 94 return content::NavigationThrottle::ThrottleCheckResult::DEFER; |
92 } | 95 } |
93 | 96 |
94 const char* | 97 const char* |
95 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() { | 98 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() { |
96 return "SubresourceFilterSafeBrowsingActivationThrottle"; | 99 return "SubresourceFilterSafeBrowsingActivationThrottle"; |
(...skipping 25 matching lines...) Expand all Loading... |
122 navigation_handle()->GetURL(), id)); | 125 navigation_handle()->GetURL(), id)); |
123 } | 126 } |
124 | 127 |
125 void SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult() { | 128 void SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult() { |
126 content::WebContents* web_contents = navigation_handle()->GetWebContents(); | 129 content::WebContents* web_contents = navigation_handle()->GetWebContents(); |
127 if (!web_contents) | 130 if (!web_contents) |
128 return; | 131 return; |
129 | 132 |
130 using subresource_filter::ContentSubresourceFilterDriverFactory; | 133 using subresource_filter::ContentSubresourceFilterDriverFactory; |
131 | 134 |
| 135 const SubresourceFilterSafeBrowsingClient::CheckResult& result = |
| 136 check_results_.back(); |
132 ContentSubresourceFilterDriverFactory* driver_factory = | 137 ContentSubresourceFilterDriverFactory* driver_factory = |
133 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); | 138 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); |
134 DCHECK(driver_factory); | 139 DCHECK(driver_factory); |
135 | 140 |
136 const SubresourceFilterSafeBrowsingClient::CheckResult& result = | 141 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( |
137 check_results_.back(); | 142 navigation_handle()->GetURL(), result.threat_type, result.pattern_type); |
138 auto threat_type = safe_browsing::SBThreatType::SB_THREAT_TYPE_SAFE; | |
139 auto pattern_type = safe_browsing::ThreatPatternType::NONE; | |
140 if (database_client_) { | |
141 DCHECK(!check_results_.empty()); | |
142 DCHECK(check_results_.back().finished); | |
143 threat_type = result.threat_type; | |
144 pattern_type = result.pattern_type; | |
145 } | |
146 driver_factory->OnSafeBrowsingMatchComputed(navigation_handle(), threat_type, | |
147 pattern_type); | |
148 | 143 |
149 base::TimeDelta delay = defer_time_.is_null() | 144 base::TimeDelta delay = defer_time_.is_null() |
150 ? base::TimeDelta::FromMilliseconds(0) | 145 ? base::TimeDelta::FromMilliseconds(0) |
151 : base::TimeTicks::Now() - defer_time_; | 146 : base::TimeTicks::Now() - defer_time_; |
152 UMA_HISTOGRAM_TIMES("SubresourceFilter.PageLoad.SafeBrowsingDelay", delay); | 147 UMA_HISTOGRAM_TIMES("SubresourceFilter.PageLoad.SafeBrowsingDelay", delay); |
153 | 148 |
154 // Log a histogram for the delay we would have introduced if the throttle only | 149 // Log a histogram for the delay we would have introduced if the throttle only |
155 // speculatively checks URLs on WillStartRequest. This is only different from | 150 // speculatively checks URLs on WillStartRequest. This is only different from |
156 // the actual delay if there was at least one redirect. | 151 // the actual delay if there was at least one redirect. |
157 base::TimeDelta no_redirect_speculation_delay = | 152 base::TimeDelta no_redirect_speculation_delay = |
(...skipping 23 matching lines...) Expand all Loading... |
181 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", is_matched, | 176 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", is_matched, |
182 chain_size); | 177 chain_size); |
183 break; | 178 break; |
184 default: | 179 default: |
185 NOTREACHED(); | 180 NOTREACHED(); |
186 break; | 181 break; |
187 } | 182 } |
188 } | 183 } |
189 | 184 |
190 } // namespace subresource_filter | 185 } // namespace subresource_filter |
OLD | NEW |