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