| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 #include "chrome/browser/ui/browser.h" | 41 #include "chrome/browser/ui/browser.h" |
| 42 #include "chrome/browser/ui/browser_list.h" | 42 #include "chrome/browser/ui/browser_list.h" |
| 43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/pref_names.h" | 44 #include "chrome/common/pref_names.h" |
| 45 #include "chrome/common/safe_browsing/binary_feature_extractor.h" | 45 #include "chrome/common/safe_browsing/binary_feature_extractor.h" |
| 46 #include "chrome/common/safe_browsing/csd.pb.h" | 46 #include "chrome/common/safe_browsing/csd.pb.h" |
| 47 #include "chrome/common/safe_browsing/download_protection_util.h" | 47 #include "chrome/common/safe_browsing/download_protection_util.h" |
| 48 #include "chrome/common/safe_browsing/file_type_policies.h" | 48 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 49 #include "chrome/common/safe_browsing/zip_analyzer_results.h" | 49 #include "chrome/common/safe_browsing/zip_analyzer_results.h" |
| 50 #include "chrome/common/url_constants.h" | 50 #include "chrome/common/url_constants.h" |
| 51 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 51 #include "components/google/core/browser/google_util.h" | 52 #include "components/google/core/browser/google_util.h" |
| 52 #include "components/history/core/browser/history_service.h" | 53 #include "components/history/core/browser/history_service.h" |
| 53 #include "components/prefs/pref_service.h" | 54 #include "components/prefs/pref_service.h" |
| 54 #include "content/public/browser/browser_thread.h" | 55 #include "content/public/browser/browser_thread.h" |
| 55 #include "content/public/browser/download_item.h" | 56 #include "content/public/browser/download_item.h" |
| 56 #include "content/public/browser/page_navigator.h" | 57 #include "content/public/browser/page_navigator.h" |
| 57 #include "crypto/sha2.h" | 58 #include "crypto/sha2.h" |
| 58 #include "google_apis/google_api_keys.h" | 59 #include "google_apis/google_api_keys.h" |
| 59 #include "net/base/escape.h" | 60 #include "net/base/escape.h" |
| 60 #include "net/base/load_flags.h" | 61 #include "net/base/load_flags.h" |
| (...skipping 975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1036 } | 1037 } |
| 1037 | 1038 |
| 1038 service_->client_download_request_callbacks_.Notify(item_, &request); | 1039 service_->client_download_request_callbacks_.Notify(item_, &request); |
| 1039 DVLOG(2) << "Sending a request for URL: " | 1040 DVLOG(2) << "Sending a request for URL: " |
| 1040 << item_->GetUrlChain().back(); | 1041 << item_->GetUrlChain().back(); |
| 1041 DVLOG(2) << "Detected " << request.archived_binary().size() << " archived " | 1042 DVLOG(2) << "Detected " << request.archived_binary().size() << " archived " |
| 1042 << "binaries"; | 1043 << "binaries"; |
| 1043 fetcher_ = net::URLFetcher::Create(0 /* ID used for testing */, | 1044 fetcher_ = net::URLFetcher::Create(0 /* ID used for testing */, |
| 1044 GetDownloadRequestUrl(), | 1045 GetDownloadRequestUrl(), |
| 1045 net::URLFetcher::POST, this); | 1046 net::URLFetcher::POST, this); |
| 1047 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 1048 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING); |
| 1046 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 1049 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 1047 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. | 1050 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. |
| 1048 fetcher_->SetRequestContext(service_->request_context_getter_.get()); | 1051 fetcher_->SetRequestContext(service_->request_context_getter_.get()); |
| 1049 fetcher_->SetUploadData("application/octet-stream", | 1052 fetcher_->SetUploadData("application/octet-stream", |
| 1050 client_download_request_data_); | 1053 client_download_request_data_); |
| 1051 request_start_time_ = base::TimeTicks::Now(); | 1054 request_start_time_ = base::TimeTicks::Now(); |
| 1052 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", | 1055 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", |
| 1053 client_download_request_data_.size()); | 1056 client_download_request_data_.size()); |
| 1054 fetcher_->Start(); | 1057 fetcher_->Start(); |
| 1055 } | 1058 } |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 // verdict gets interpreted as "allowed". | 1368 // verdict gets interpreted as "allowed". |
| 1366 Finish(RequestOutcome::REQUEST_MALFORMED, UNKNOWN); | 1369 Finish(RequestOutcome::REQUEST_MALFORMED, UNKNOWN); |
| 1367 return; | 1370 return; |
| 1368 } | 1371 } |
| 1369 | 1372 |
| 1370 service_->ppapi_download_request_callbacks_.Notify(&request); | 1373 service_->ppapi_download_request_callbacks_.Notify(&request); |
| 1371 DVLOG(2) << "Sending a PPAPI download request for URL: " << request.url(); | 1374 DVLOG(2) << "Sending a PPAPI download request for URL: " << request.url(); |
| 1372 | 1375 |
| 1373 fetcher_ = net::URLFetcher::Create(0, GetDownloadRequestUrl(), | 1376 fetcher_ = net::URLFetcher::Create(0, GetDownloadRequestUrl(), |
| 1374 net::URLFetcher::POST, this); | 1377 net::URLFetcher::POST, this); |
| 1378 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 1379 fetcher_.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING); |
| 1375 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 1380 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 1376 fetcher_->SetAutomaticallyRetryOn5xx(false); | 1381 fetcher_->SetAutomaticallyRetryOn5xx(false); |
| 1377 fetcher_->SetRequestContext(service_->request_context_getter_.get()); | 1382 fetcher_->SetRequestContext(service_->request_context_getter_.get()); |
| 1378 fetcher_->SetUploadData("application/octet-stream", | 1383 fetcher_->SetUploadData("application/octet-stream", |
| 1379 client_download_request_data_); | 1384 client_download_request_data_); |
| 1380 fetcher_->Start(); | 1385 fetcher_->Start(); |
| 1381 } | 1386 } |
| 1382 | 1387 |
| 1383 // net::URLFetcherDelegate | 1388 // net::URLFetcherDelegate |
| 1384 void OnURLFetchComplete(const net::URLFetcher* source) override { | 1389 void OnURLFetchComplete(const net::URLFetcher* source) override { |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1780 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1785 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1781 GURL url(kDownloadRequestUrl); | 1786 GURL url(kDownloadRequestUrl); |
| 1782 std::string api_key = google_apis::GetAPIKey(); | 1787 std::string api_key = google_apis::GetAPIKey(); |
| 1783 if (!api_key.empty()) | 1788 if (!api_key.empty()) |
| 1784 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1789 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1785 | 1790 |
| 1786 return url; | 1791 return url; |
| 1787 } | 1792 } |
| 1788 | 1793 |
| 1789 } // namespace safe_browsing | 1794 } // namespace safe_browsing |
| OLD | NEW |