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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_host.cc

Issue 7119003: Create a browser feature extractor that runs after the renderer has (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Address Matt's and Pawel's comments Created 9 years, 6 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 side-by-side diff with in-line comments
Download patch
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: "
gcasto (DO NOT USE) 2011/06/09 21:39:55 Do we want a histogram here so we can see how ofte
noelutz 2011/06/09 22:52:09 Maybe? As of right now we can tell how often it h
+ << 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.
+ cb_factory_.NewCallback(
+ &ClientSideDetectionHost::MaybeShowPhishingWarning));
+}
+
void ClientSideDetectionHost::set_client_side_detection_service(
ClientSideDetectionService* service) {
csd_service_ = service;

Powered by Google App Engine
This is Rietveld 408576698