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/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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 if (!request.SerializeToString(&request_data)) { | 673 if (!request.SerializeToString(&request_data)) { |
674 RecordImprovedProtectionStats(REASON_INVALID_REQUEST_PROTO); | 674 RecordImprovedProtectionStats(REASON_INVALID_REQUEST_PROTO); |
675 FinishRequest(SAFE); | 675 FinishRequest(SAFE); |
676 return; | 676 return; |
677 } | 677 } |
678 | 678 |
679 VLOG(2) << "Sending a request for URL: " | 679 VLOG(2) << "Sending a request for URL: " |
680 << info_.download_url_chain.back(); | 680 << info_.download_url_chain.back(); |
681 fetcher_.reset(content::URLFetcher::Create(0 /* ID used for testing */, | 681 fetcher_.reset(content::URLFetcher::Create(0 /* ID used for testing */, |
682 GURL(kDownloadRequestUrl), | 682 GURL(kDownloadRequestUrl), |
683 content::URLFetcher::POST, | 683 net::URLFetcher::POST, |
684 this)); | 684 this)); |
685 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 685 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
686 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. | 686 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. |
687 fetcher_->SetRequestContext(service_->request_context_getter_.get()); | 687 fetcher_->SetRequestContext(service_->request_context_getter_.get()); |
688 fetcher_->SetUploadData("application/octet-stream", request_data); | 688 fetcher_->SetUploadData("application/octet-stream", request_data); |
689 fetcher_->Start(); | 689 fetcher_->Start(); |
690 } | 690 } |
691 | 691 |
692 void PostFinishTask(DownloadCheckResult result) { | 692 void PostFinishTask(DownloadCheckResult result) { |
693 BrowserThread::PostTask( | 693 BrowserThread::PostTask( |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 } | 759 } |
760 | 760 |
761 DownloadInfo info_; | 761 DownloadInfo info_; |
762 ClientDownloadRequest_SignatureInfo signature_info_; | 762 ClientDownloadRequest_SignatureInfo signature_info_; |
763 CheckDownloadCallback callback_; | 763 CheckDownloadCallback callback_; |
764 // Will be NULL if the request has been canceled. | 764 // Will be NULL if the request has been canceled. |
765 DownloadProtectionService* service_; | 765 DownloadProtectionService* service_; |
766 scoped_refptr<SignatureUtil> signature_util_; | 766 scoped_refptr<SignatureUtil> signature_util_; |
767 scoped_refptr<SafeBrowsingService> sb_service_; | 767 scoped_refptr<SafeBrowsingService> sb_service_; |
768 const bool pingback_enabled_; | 768 const bool pingback_enabled_; |
769 scoped_ptr<content::URLFetcher> fetcher_; | 769 scoped_ptr<net::URLFetcher> fetcher_; |
770 bool finished_; | 770 bool finished_; |
771 ClientDownloadRequest::DownloadType type_; | 771 ClientDownloadRequest::DownloadType type_; |
772 base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_; | 772 base::WeakPtrFactory<CheckClientDownloadRequest> timeout_weakptr_factory_; |
773 base::TimeTicks start_time_; // Used for stats. | 773 base::TimeTicks start_time_; // Used for stats. |
774 | 774 |
775 DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest); | 775 DISALLOW_COPY_AND_ASSIGN(CheckClientDownloadRequest); |
776 }; | 776 }; |
777 | 777 |
778 DownloadProtectionService::DownloadProtectionService( | 778 DownloadProtectionService::DownloadProtectionService( |
779 SafeBrowsingService* sb_service, | 779 SafeBrowsingService* sb_service, |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 | 943 |
944 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, | 944 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, |
945 sizeof(issuer.fingerprint().data)); | 945 sizeof(issuer.fingerprint().data)); |
946 for (std::set<std::string>::iterator it = paths_to_check.begin(); | 946 for (std::set<std::string>::iterator it = paths_to_check.begin(); |
947 it != paths_to_check.end(); ++it) { | 947 it != paths_to_check.end(); ++it) { |
948 whitelist_strings->push_back("cert/" + issuer_fp + *it); | 948 whitelist_strings->push_back("cert/" + issuer_fp + *it); |
949 } | 949 } |
950 } | 950 } |
951 | 951 |
952 } // namespace safe_browsing | 952 } // namespace safe_browsing |
OLD | NEW |