Index: chrome/browser/safe_browsing/client_side_detection_host.cc |
diff --git a/chrome/browser/safe_browsing/client_side_detection_host.cc b/chrome/browser/safe_browsing/client_side_detection_host.cc |
index 4cb448c5a77dc99262b3a93e1b982adf17e73257..c33c6ba4bfb0edacb68185805c48c8e9aae7f597 100644 |
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc |
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc |
@@ -13,6 +13,7 @@ |
#include "base/task.h" |
#include "chrome/browser/browser_process.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
#include "chrome/browser/safe_browsing/client_side_detection_service.h" |
#include "chrome/browser/safe_browsing/safe_browsing_service.h" |
#include "chrome/common/chrome_switches.h" |
@@ -264,6 +265,7 @@ ClientSideDetectionHost* ClientSideDetectionHost::Create( |
ClientSideDetectionHost::ClientSideDetectionHost(TabContents* tab) |
: TabContentsObserver(tab), |
csd_service_(g_browser_process->safe_browsing_detection_service()), |
+ feature_extractor_(new BrowserFeatureExtractor(tab)), |
cb_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
DCHECK(tab); |
// Note: csd_service_ and sb_service_ might be NULL. |
@@ -340,12 +342,12 @@ void ClientSideDetectionHost::OnDetectedPhishingSite( |
// There shouldn't be any pending requests because we revoke them everytime |
// we navigate away. |
DCHECK(!cb_factory_.HasPendingCallbacks()); |
- VLOG(2) << "Start sending client phishing request for URL: " |
- << verdict->url(); |
- csd_service_->SendClientReportPhishingRequest( |
- verdict.release(), // The service takes ownership of the verdict. |
- cb_factory_.NewCallback( |
- &ClientSideDetectionHost::MaybeShowPhishingWarning)); |
+ |
+ // Start browser-side feature extraction. Once we're done it will send |
+ // the client verdict request. |
+ feature_extractor_->ExtractFeatures( |
+ verdict.release(), |
+ NewCallback(this, &ClientSideDetectionHost::FeatureExtractionDone)); |
} |
} |
@@ -377,6 +379,22 @@ void ClientSideDetectionHost::MaybeShowPhishingWarning(GURL phishing_url, |
} |
} |
+void ClientSideDetectionHost::FeatureExtractionDone( |
+ bool success, |
+ ClientPhishingRequest* request) { |
+ if (!request) { |
+ DLOG(FATAL) << "Invalid request object in FeatureExtractionDone"; |
+ return; |
+ } |
+ VLOG(2) << "Feature extraction done (success:" << success << ") for URL: " |
+ << request->url() << ". Start sending client phishing request."; |
+ // Send ping no matter what - even if the browser feature extraction failed. |
+ csd_service_->SendClientReportPhishingRequest( |
+ request, // The service takes ownership of the verdict object. |
Brian Ryner
2011/06/10 04:45:10
nit: maybe say "the request object" just so we're
noelutz
2011/06/14 01:10:10
Done.
|
+ cb_factory_.NewCallback( |
+ &ClientSideDetectionHost::MaybeShowPhishingWarning)); |
+} |
+ |
void ClientSideDetectionHost::set_client_side_detection_service( |
ClientSideDetectionService* service) { |
csd_service_ = service; |