OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/safe_browsing/browser_feature_extractor.h" | 5 #include "chrome/browser/safe_browsing/browser_feature_extractor.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 (first_visit < (base::Time::Now() - base::TimeDelta::FromDays(1))) ? | 451 (first_visit < (base::Time::Now() - base::TimeDelta::FromDays(1))) ? |
452 1.0 : 0.0, | 452 1.0 : 0.0, |
453 request); | 453 request); |
454 } | 454 } |
455 } | 455 } |
456 | 456 |
457 bool BrowserFeatureExtractor::GetHistoryService(HistoryService** history) { | 457 bool BrowserFeatureExtractor::GetHistoryService(HistoryService** history) { |
458 *history = NULL; | 458 *history = NULL; |
459 if (tab_ && tab_->GetBrowserContext()) { | 459 if (tab_ && tab_->GetBrowserContext()) { |
460 Profile* profile = Profile::FromBrowserContext(tab_->GetBrowserContext()); | 460 Profile* profile = Profile::FromBrowserContext(tab_->GetBrowserContext()); |
461 *history = HistoryServiceFactory::GetForProfile(profile, | 461 *history = HistoryServiceFactory::GetForProfile( |
462 Profile::EXPLICIT_ACCESS); | 462 profile, ServiceAccessType::EXPLICIT_ACCESS); |
463 if (*history) { | 463 if (*history) { |
464 return true; | 464 return true; |
465 } | 465 } |
466 } | 466 } |
467 DVLOG(2) << "Unable to query history. No history service available."; | 467 DVLOG(2) << "Unable to query history. No history service available."; |
468 return false; | 468 return false; |
469 } | 469 } |
470 | 470 |
471 void BrowserFeatureExtractor::FinishExtractMalwareFeatures( | 471 void BrowserFeatureExtractor::FinishExtractMalwareFeatures( |
472 scoped_ptr<IPUrlMap> bad_ips, | 472 scoped_ptr<IPUrlMap> bad_ips, |
473 MalwareDoneCallback callback, | 473 MalwareDoneCallback callback, |
474 scoped_ptr<ClientMalwareRequest> request) { | 474 scoped_ptr<ClientMalwareRequest> request) { |
475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
476 int matched_bad_ips = 0; | 476 int matched_bad_ips = 0; |
477 for (IPUrlMap::const_iterator it = bad_ips->begin(); | 477 for (IPUrlMap::const_iterator it = bad_ips->begin(); |
478 it != bad_ips->end(); ++it) { | 478 it != bad_ips->end(); ++it) { |
479 AddMalwareIpUrlInfo(it->first, it->second, request.get()); | 479 AddMalwareIpUrlInfo(it->first, it->second, request.get()); |
480 ++matched_bad_ips; | 480 ++matched_bad_ips; |
481 // Limit the number of matched bad IPs in one request to control | 481 // Limit the number of matched bad IPs in one request to control |
482 // the request's size | 482 // the request's size |
483 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { | 483 if (matched_bad_ips >= kMaxMalwareIPPerRequest) { |
484 break; | 484 break; |
485 } | 485 } |
486 } | 486 } |
487 callback.Run(true, request.Pass()); | 487 callback.Run(true, request.Pass()); |
488 } | 488 } |
489 | 489 |
490 } // namespace safe_browsing | 490 } // namespace safe_browsing |
OLD | NEW |