| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 request.set_download_type(type_); | 653 request.set_download_type(type_); |
| 654 request.mutable_signature()->CopyFrom(signature_info_); | 654 request.mutable_signature()->CopyFrom(signature_info_); |
| 655 if (!request.SerializeToString(&client_download_request_data_)) { | 655 if (!request.SerializeToString(&client_download_request_data_)) { |
| 656 FinishRequest(SAFE, REASON_INVALID_REQUEST_PROTO); | 656 FinishRequest(SAFE, REASON_INVALID_REQUEST_PROTO); |
| 657 return; | 657 return; |
| 658 } | 658 } |
| 659 | 659 |
| 660 VLOG(2) << "Sending a request for URL: " | 660 VLOG(2) << "Sending a request for URL: " |
| 661 << item_->GetUrlChain().back(); | 661 << item_->GetUrlChain().back(); |
| 662 fetcher_.reset(net::URLFetcher::Create(0 /* ID used for testing */, | 662 fetcher_.reset(net::URLFetcher::Create(0 /* ID used for testing */, |
| 663 GURL(GetDownloadRequestUrl()), | 663 GetDownloadRequestUrl(), |
| 664 net::URLFetcher::POST, | 664 net::URLFetcher::POST, |
| 665 this)); | 665 this)); |
| 666 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 666 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 667 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. | 667 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. |
| 668 fetcher_->SetRequestContext(service_->request_context_getter_.get()); | 668 fetcher_->SetRequestContext(service_->request_context_getter_.get()); |
| 669 fetcher_->SetUploadData("application/octet-stream", | 669 fetcher_->SetUploadData("application/octet-stream", |
| 670 client_download_request_data_); | 670 client_download_request_data_); |
| 671 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", | 671 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", |
| 672 client_download_request_data_.size()); | 672 client_download_request_data_.size()); |
| 673 fetcher_->Start(); | 673 fetcher_->Start(); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 960 | 960 |
| 961 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, | 961 std::string issuer_fp = base::HexEncode(issuer.fingerprint().data, |
| 962 sizeof(issuer.fingerprint().data)); | 962 sizeof(issuer.fingerprint().data)); |
| 963 for (std::set<std::string>::iterator it = paths_to_check.begin(); | 963 for (std::set<std::string>::iterator it = paths_to_check.begin(); |
| 964 it != paths_to_check.end(); ++it) { | 964 it != paths_to_check.end(); ++it) { |
| 965 whitelist_strings->push_back("cert/" + issuer_fp + *it); | 965 whitelist_strings->push_back("cert/" + issuer_fp + *it); |
| 966 } | 966 } |
| 967 } | 967 } |
| 968 | 968 |
| 969 // static | 969 // static |
| 970 std::string DownloadProtectionService::GetDownloadRequestUrl() { | 970 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 971 std::string url = kDownloadRequestUrl; | 971 GURL url(kDownloadRequestUrl); |
| 972 std::string api_key = google_apis::GetAPIKey(); | 972 std::string api_key = google_apis::GetAPIKey(); |
| 973 if (!api_key.empty()) { | 973 if (!api_key.empty()) |
| 974 base::StringAppendF(&url, "?key=%s", | 974 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 975 net::EscapeQueryParamValue(api_key, true).c_str()); | 975 |
| 976 } | |
| 977 return url; | 976 return url; |
| 978 } | 977 } |
| 979 | 978 |
| 980 } // namespace safe_browsing | 979 } // namespace safe_browsing |
| OLD | NEW |