| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/renderer/safe_browsing/phishing_classifier.h" | 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 verdict.set_is_phishing(score >= kPhishyThreshold); | 202 verdict.set_is_phishing(score >= kPhishyThreshold); |
| 203 RunCallback(verdict); | 203 RunCallback(verdict); |
| 204 } else { | 204 } else { |
| 205 RunFailureCallback(); | 205 RunFailureCallback(); |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 void PhishingClassifier::CheckNoPendingClassification() { | 209 void PhishingClassifier::CheckNoPendingClassification() { |
| 210 DCHECK(done_callback_.is_null()); | 210 DCHECK(done_callback_.is_null()); |
| 211 DCHECK(!page_text_); | 211 DCHECK(!page_text_); |
| 212 if (done_callback_.is_null() || page_text_) { | 212 if (!done_callback_.is_null() || page_text_) { |
| 213 LOG(ERROR) << "Classification in progress, missing call to " | 213 LOG(ERROR) << "Classification in progress, missing call to " |
| 214 << "CancelPendingClassification"; | 214 << "CancelPendingClassification"; |
| 215 UMA_HISTOGRAM_COUNTS("SBClientPhishing.CheckNoPendingClassificationFailed", | 215 UMA_HISTOGRAM_COUNTS("SBClientPhishing.CheckNoPendingClassificationFailed", |
| 216 1); | 216 1); |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 void PhishingClassifier::RunCallback(const ClientPhishingRequest& verdict) { | 220 void PhishingClassifier::RunCallback(const ClientPhishingRequest& verdict) { |
| 221 done_callback_.Run(verdict); | 221 done_callback_.Run(verdict); |
| 222 Clear(); | 222 Clear(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void PhishingClassifier::RunFailureCallback() { | 225 void PhishingClassifier::RunFailureCallback() { |
| 226 ClientPhishingRequest verdict; | 226 ClientPhishingRequest verdict; |
| 227 // In this case we're not guaranteed to have a valid URL. Just set it | 227 // In this case we're not guaranteed to have a valid URL. Just set it |
| 228 // to the empty string to make sure we have a valid protocol buffer. | 228 // to the empty string to make sure we have a valid protocol buffer. |
| 229 verdict.set_url(""); | 229 verdict.set_url(""); |
| 230 verdict.set_client_score(kInvalidScore); | 230 verdict.set_client_score(kInvalidScore); |
| 231 verdict.set_is_phishing(false); | 231 verdict.set_is_phishing(false); |
| 232 RunCallback(verdict); | 232 RunCallback(verdict); |
| 233 } | 233 } |
| 234 | 234 |
| 235 void PhishingClassifier::Clear() { | 235 void PhishingClassifier::Clear() { |
| 236 page_text_ = NULL; | 236 page_text_ = NULL; |
| 237 done_callback_.Reset(); | 237 done_callback_.Reset(); |
| 238 features_.reset(NULL); | 238 features_.reset(NULL); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace safe_browsing | 241 } // namespace safe_browsing |
| OLD | NEW |