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/browser/safe_browsing/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 568 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
569 if (service_) { | 569 if (service_) { |
570 callback_.Run(result); | 570 callback_.Run(result); |
571 service_->RequestFinished(this); | 571 service_->RequestFinished(this); |
572 } else { | 572 } else { |
573 callback_.Run(SAFE); | 573 callback_.Run(SAFE); |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 void RecordImprovedProtectionStats(DownloadCheckResultReason reason) { | 577 void RecordImprovedProtectionStats(DownloadCheckResultReason reason) { |
| 578 VLOG(2) << "SafeBrowsing download verdict for: " |
| 579 << info_.DebugString() << " verdict:" << reason; |
578 UMA_HISTOGRAM_ENUMERATION("SBClientDownload.CheckDownloadStats", | 580 UMA_HISTOGRAM_ENUMERATION("SBClientDownload.CheckDownloadStats", |
579 reason, | 581 reason, |
580 REASON_MAX); | 582 REASON_MAX); |
581 } | 583 } |
582 | 584 |
583 DownloadInfo info_; | 585 DownloadInfo info_; |
584 ClientDownloadRequest_SignatureInfo signature_info_; | 586 ClientDownloadRequest_SignatureInfo signature_info_; |
585 CheckDownloadCallback callback_; | 587 CheckDownloadCallback callback_; |
586 // Will be NULL if the request has been canceled. | 588 // Will be NULL if the request has been canceled. |
587 DownloadProtectionService* service_; | 589 DownloadProtectionService* service_; |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 DCHECK(!info.download_url_chain.empty()); | 635 DCHECK(!info.download_url_chain.empty()); |
634 scoped_refptr<DownloadUrlSBClient> client( | 636 scoped_refptr<DownloadUrlSBClient> client( |
635 new DownloadUrlSBClient(info, callback, sb_service_)); | 637 new DownloadUrlSBClient(info, callback, sb_service_)); |
636 // The client will release itself once it is done. | 638 // The client will release itself once it is done. |
637 BrowserThread::PostTask( | 639 BrowserThread::PostTask( |
638 BrowserThread::IO, | 640 BrowserThread::IO, |
639 FROM_HERE, | 641 FROM_HERE, |
640 base::Bind(&DownloadUrlSBClient::StartCheck, client)); | 642 base::Bind(&DownloadUrlSBClient::StartCheck, client)); |
641 } | 643 } |
642 | 644 |
| 645 bool DownloadProtectionService::IsSupportedFileType( |
| 646 const FilePath& filename) const { |
| 647 return IsBinaryFile(filename); |
| 648 } |
| 649 |
643 void DownloadProtectionService::CancelPendingRequests() { | 650 void DownloadProtectionService::CancelPendingRequests() { |
644 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 651 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
645 for (std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 652 for (std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
646 download_requests_.begin(); | 653 download_requests_.begin(); |
647 it != download_requests_.end(); ++it) { | 654 it != download_requests_.end(); ++it) { |
648 (*it)->Cancel(); | 655 (*it)->Cancel(); |
649 } | 656 } |
650 download_requests_.clear(); | 657 download_requests_.clear(); |
651 } | 658 } |
652 | 659 |
653 void DownloadProtectionService::RequestFinished( | 660 void DownloadProtectionService::RequestFinished( |
654 CheckClientDownloadRequest* request) { | 661 CheckClientDownloadRequest* request) { |
655 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 662 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
656 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = | 663 std::set<scoped_refptr<CheckClientDownloadRequest> >::iterator it = |
657 download_requests_.find(request); | 664 download_requests_.find(request); |
658 DCHECK(it != download_requests_.end()); | 665 DCHECK(it != download_requests_.end()); |
659 download_requests_.erase(*it); | 666 download_requests_.erase(*it); |
660 } | 667 } |
661 } // namespace safe_browsing | 668 } // namespace safe_browsing |
OLD | NEW |