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

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

Issue 42553002: Mostly integrate new malware IP blacklist with the csd client. When (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix leaks in the unit-tests Created 7 years, 1 month 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 eace117d9e6bf90f4f36fa6e3d77b663588d6d61..4447c9b9442a95cca6261b214ed105c38eec46c2 100644
--- a/chrome/browser/safe_browsing/client_side_detection_host.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_host.cc
@@ -260,7 +260,7 @@ ClientSideDetectionHost::ClientSideDetectionHost(WebContents* tab)
DCHECK(tab);
// Note: csd_service_ and sb_service will be NULL here in testing.
csd_service_ = g_browser_process->safe_browsing_detection_service();
- feature_extractor_.reset(new BrowserFeatureExtractor(tab, csd_service_));
+ feature_extractor_.reset(new BrowserFeatureExtractor(tab, this));
registrar_.Add(this, content::NOTIFICATION_RESOURCE_RESPONSE_STARTED,
content::Source<WebContents>(tab));
@@ -361,6 +361,11 @@ void ClientSideDetectionHost::OnSafeBrowsingHit(
}
}
+scoped_refptr<SafeBrowsingDatabaseManager>
+ClientSideDetectionHost::database_manager() {
+ return database_manager_;
+}
+
void ClientSideDetectionHost::WebContentsDestroyed(WebContents* tab) {
DCHECK(tab);
// Tell any pending classification request that it is being canceled.
@@ -399,9 +404,13 @@ void ClientSideDetectionHost::OnPhishingDetectionDone(
// Start browser-side malware feature extraction. Once we're done it will
// send the malware client verdict request.
malware_verdict->set_url(verdict->url());
+ // This function doesn't expect browse_info_ to stay around after this
+ // function returns.
feature_extractor_->ExtractMalwareFeatures(
- browse_info_.get(), malware_verdict.get());
- MalwareFeatureExtractionDone(malware_verdict.Pass());
+ browse_info_.get(),
+ malware_verdict.release(),
+ base::Bind(&ClientSideDetectionHost::MalwareFeatureExtractionDone,
+ weak_factory_.GetWeakPtr()));
}
// We only send phishing verdict to the server if the verdict is phishing or
@@ -490,10 +499,7 @@ void ClientSideDetectionHost::MaybeShowMalwareWarning(GURL original_url,
void ClientSideDetectionHost::FeatureExtractionDone(
bool success,
ClientPhishingRequest* request) {
- if (!request) {
- DLOG(FATAL) << "Invalid request object in FeatureExtractionDone";
- return;
- }
+ DCHECK(request);
VLOG(2) << "Feature extraction done (success:" << success << ") for URL: "
<< request->url() << ". Start sending client phishing request.";
ClientSideDetectionService::ClientReportPhishingRequestCallback callback;
@@ -510,23 +516,19 @@ void ClientSideDetectionHost::FeatureExtractionDone(
}
void ClientSideDetectionHost::MalwareFeatureExtractionDone(
+ bool feature_extraction_success,
scoped_ptr<ClientMalwareRequest> request) {
- if (!request) {
- DLOG(FATAL) << "Invalid request object in MalwareFeatureExtractionDone";
- return;
- }
+ DCHECK(request.get());
VLOG(2) << "Malware Feature extraction done for URL: " << request->url()
<< ", with features count:" << request->feature_map_size();
// Send ping if there is matching features.
- if (request->feature_map_size() > 0) {
+ if (feature_extraction_success && request->feature_map_size() > 0) {
VLOG(1) << "Start sending client malware request.";
ClientSideDetectionService::ClientReportMalwareRequestCallback callback;
callback = base::Bind(&ClientSideDetectionHost::MaybeShowMalwareWarning,
weak_factory_.GetWeakPtr());
- csd_service_->SendClientReportMalwareRequest(
- request.release(), // The service takes ownership of the request object
- callback);
+ csd_service_->SendClientReportMalwareRequest(request.release(), callback);
}
}

Powered by Google App Engine
This is Rietveld 408576698