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

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

Issue 2889913002: [subresource_filter] Remove Forwarding NavigationThrottles (Closed)
Patch Set: shivanisha review 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/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
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
88 // No need to defer the navigation if the check already happened. 85 // No need to defer the navigation if the check already happened.
89 if (check_results_.back().finished) { 86 if (!database_client_ || check_results_.back().finished) {
90 NotifyResult(); 87 NotifyResult();
91 return content::NavigationThrottle::ThrottleCheckResult::PROCEED; 88 return content::NavigationThrottle::ThrottleCheckResult::PROCEED;
92 } 89 }
93 defer_time_ = base::TimeTicks::Now(); 90 defer_time_ = base::TimeTicks::Now();
94 return content::NavigationThrottle::ThrottleCheckResult::DEFER; 91 return content::NavigationThrottle::ThrottleCheckResult::DEFER;
95 } 92 }
96 93
97 const char* 94 const char*
98 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() { 95 SubresourceFilterSafeBrowsingActivationThrottle::GetNameForLogging() {
99 return "SubresourceFilterSafeBrowsingActivationThrottle"; 96 return "SubresourceFilterSafeBrowsingActivationThrottle";
(...skipping 25 matching lines...) Expand all
125 navigation_handle()->GetURL(), id)); 122 navigation_handle()->GetURL(), id));
126 } 123 }
127 124
128 void SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult() { 125 void SubresourceFilterSafeBrowsingActivationThrottle::NotifyResult() {
129 content::WebContents* web_contents = navigation_handle()->GetWebContents(); 126 content::WebContents* web_contents = navigation_handle()->GetWebContents();
130 if (!web_contents) 127 if (!web_contents)
131 return; 128 return;
132 129
133 using subresource_filter::ContentSubresourceFilterDriverFactory; 130 using subresource_filter::ContentSubresourceFilterDriverFactory;
134 131
135 const SubresourceFilterSafeBrowsingClient::CheckResult& result =
136 check_results_.back();
137 ContentSubresourceFilterDriverFactory* driver_factory = 132 ContentSubresourceFilterDriverFactory* driver_factory =
138 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); 133 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
139 DCHECK(driver_factory); 134 DCHECK(driver_factory);
140 135
141 driver_factory->OnMainResourceMatchedSafeBrowsingBlacklist( 136 const SubresourceFilterSafeBrowsingClient::CheckResult& result =
142 navigation_handle()->GetURL(), result.threat_type, result.pattern_type); 137 check_results_.back();
Charlie Harrison 2017/05/19 11:15:41 Here's the issue, we call back() on an empty vecto
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);
143 148
144 base::TimeDelta delay = defer_time_.is_null() 149 base::TimeDelta delay = defer_time_.is_null()
145 ? base::TimeDelta::FromMilliseconds(0) 150 ? base::TimeDelta::FromMilliseconds(0)
146 : base::TimeTicks::Now() - defer_time_; 151 : base::TimeTicks::Now() - defer_time_;
147 UMA_HISTOGRAM_TIMES("SubresourceFilter.PageLoad.SafeBrowsingDelay", delay); 152 UMA_HISTOGRAM_TIMES("SubresourceFilter.PageLoad.SafeBrowsingDelay", delay);
148 153
149 // Log a histogram for the delay we would have introduced if the throttle only 154 // Log a histogram for the delay we would have introduced if the throttle only
150 // speculatively checks URLs on WillStartRequest. This is only different from 155 // speculatively checks URLs on WillStartRequest. This is only different from
151 // the actual delay if there was at least one redirect. 156 // the actual delay if there was at least one redirect.
152 base::TimeDelta no_redirect_speculation_delay = 157 base::TimeDelta no_redirect_speculation_delay =
(...skipping 23 matching lines...) Expand all
176 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", is_matched, 181 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", is_matched,
177 chain_size); 182 chain_size);
178 break; 183 break;
179 default: 184 default:
180 NOTREACHED(); 185 NOTREACHED();
181 break; 186 break;
182 } 187 }
183 } 188 }
184 189
185 } // namespace subresource_filter 190 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698