Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 2872133006: Add full filename to sampled-download pings. (Closed)
Patch Set: . Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_protection_service_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 930 matching lines...) Expand 10 before | Expand all | Expand 10 after
941 941
942 for (auto bin_itr : request.archived_binary()) { 942 for (auto bin_itr : request.archived_binary()) {
943 if (service_->IsHashManuallyBlacklisted(bin_itr.digests().sha256())) 943 if (service_->IsHashManuallyBlacklisted(bin_itr.digests().sha256()))
944 return true; 944 return true;
945 } 945 }
946 return false; 946 return false;
947 } 947 }
948 948
949 // Prepares URLs to be put into a ping message. Currently this just shortens 949 // Prepares URLs to be put into a ping message. Currently this just shortens
950 // data: URIs, other URLs are included verbatim. If this is a sampled binary, 950 // data: URIs, other URLs are included verbatim. If this is a sampled binary,
951 // we'll send a lite-ping which strips all PII. 951 // we'll send a light-ping which strips PII from the URL.
952 std::string SanitizeUrl(const GURL& url) const { 952 std::string SanitizeUrl(const GURL& url) const {
953 if (type_ == ClientDownloadRequest::SAMPLED_UNSUPPORTED_FILE) 953 if (type_ == ClientDownloadRequest::SAMPLED_UNSUPPORTED_FILE)
954 return url.GetOrigin().spec(); 954 return url.GetOrigin().spec();
955 955
956 std::string spec = url.spec(); 956 std::string spec = url.spec();
957 if (url.SchemeIs(url::kDataScheme)) { 957 if (url.SchemeIs(url::kDataScheme)) {
958 size_t comma_pos = spec.find(','); 958 size_t comma_pos = spec.find(',');
959 if (comma_pos != std::string::npos && comma_pos != spec.size() - 1) { 959 if (comma_pos != std::string::npos && comma_pos != spec.size() - 1) {
960 std::string hash_value = crypto::SHA256HashString(spec); 960 std::string hash_value = crypto::SHA256HashString(spec);
961 spec.erase(comma_pos + 1); 961 spec.erase(comma_pos + 1);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 resource->set_url(SanitizeUrl(tab_url_)); 1015 resource->set_url(SanitizeUrl(tab_url_));
1016 DVLOG(2) << "tab url " << resource->url(); 1016 DVLOG(2) << "tab url " << resource->url();
1017 resource->set_type(ClientDownloadRequest::TAB_URL); 1017 resource->set_type(ClientDownloadRequest::TAB_URL);
1018 if (tab_referrer_url_.is_valid()) { 1018 if (tab_referrer_url_.is_valid()) {
1019 resource->set_referrer(SanitizeUrl(tab_referrer_url_)); 1019 resource->set_referrer(SanitizeUrl(tab_referrer_url_));
1020 DVLOG(2) << "tab referrer " << resource->referrer(); 1020 DVLOG(2) << "tab referrer " << resource->referrer();
1021 } 1021 }
1022 } 1022 }
1023 1023
1024 request.set_user_initiated(item_->HasUserGesture()); 1024 request.set_user_initiated(item_->HasUserGesture());
1025 if (type_ == ClientDownloadRequest::SAMPLED_UNSUPPORTED_FILE) { 1025 request.set_file_basename(
1026 request.set_file_basename(
1027 base::FilePath(item_->GetTargetFilePath().Extension())
1028 .AsUTF8Unsafe());
1029 } else {
1030 request.set_file_basename(
1031 item_->GetTargetFilePath().BaseName().AsUTF8Unsafe()); 1026 item_->GetTargetFilePath().BaseName().AsUTF8Unsafe());
1032 }
1033 request.set_download_type(type_); 1027 request.set_download_type(type_);
1034 1028
1035 ReferrerChainData* referrer_chain_data = 1029 ReferrerChainData* referrer_chain_data =
1036 static_cast<ReferrerChainData*>( 1030 static_cast<ReferrerChainData*>(
1037 item_->GetUserData(kDownloadReferrerChainDataKey)); 1031 item_->GetUserData(kDownloadReferrerChainDataKey));
1038 if (referrer_chain_data && 1032 if (referrer_chain_data &&
1039 !referrer_chain_data->GetReferrerChain()->empty()) { 1033 !referrer_chain_data->GetReferrerChain()->empty()) {
1040 request.mutable_referrer_chain()->Swap( 1034 request.mutable_referrer_chain()->Swap(
1041 referrer_chain_data->GetReferrerChain()); 1035 referrer_chain_data->GetReferrerChain());
1042 } 1036 }
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 out_request->mutable_referrer_chain()); 1990 out_request->mutable_referrer_chain());
1997 UMA_HISTOGRAM_COUNTS_100( 1991 UMA_HISTOGRAM_COUNTS_100(
1998 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution", 1992 "SafeBrowsing.ReferrerURLChainSize.PPAPIDownloadAttribution",
1999 out_request->referrer_chain_size()); 1993 out_request->referrer_chain_size());
2000 UMA_HISTOGRAM_ENUMERATION( 1994 UMA_HISTOGRAM_ENUMERATION(
2001 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result, 1995 "SafeBrowsing.ReferrerAttributionResult.PPAPIDownloadAttribution", result,
2002 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX); 1996 SafeBrowsingNavigationObserverManager::ATTRIBUTION_FAILURE_TYPE_MAX);
2003 } 1997 }
2004 1998
2005 } // namespace safe_browsing 1999 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_protection_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698