| 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/download/download_danger_prompt.h" | 5 #include "chrome/browser/download/download_danger_prompt.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 11 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 12 #include "chrome/common/safe_browsing/csd.pb.h" | 12 #include "chrome/common/safe_browsing/csd.pb.h" |
| 13 #include "chrome/common/safe_browsing/download_protection_util.h" | 13 #include "chrome/common/safe_browsing/file_type_policies.h" |
| 14 #include "content/public/browser/download_danger_type.h" | 14 #include "content/public/browser/download_danger_type.h" |
| 15 #include "content/public/browser/download_item.h" | 15 #include "content/public/browser/download_item.h" |
| 16 | 16 |
| 17 using safe_browsing::ClientDownloadResponse; | 17 using safe_browsing::ClientDownloadResponse; |
| 18 using safe_browsing::ClientSafeBrowsingReportRequest; | 18 using safe_browsing::ClientSafeBrowsingReportRequest; |
| 19 using safe_browsing::download_protection_util:: | |
| 20 GetSBClientDownloadExtensionValueForUMA; | |
| 21 | 19 |
| 22 namespace { | 20 namespace { |
| 23 | 21 |
| 24 const char kDownloadDangerPromptPrefix[] = "Download.DownloadDangerPrompt"; | 22 const char kDownloadDangerPromptPrefix[] = "Download.DownloadDangerPrompt"; |
| 25 | 23 |
| 26 // Converts DownloadDangerType into their corresponding string. | 24 // Converts DownloadDangerType into their corresponding string. |
| 27 const char* GetDangerTypeString( | 25 const char* GetDangerTypeString( |
| 28 const content::DownloadDangerType& danger_type) { | 26 const content::DownloadDangerType& danger_type) { |
| 29 switch (danger_type) { | 27 switch (danger_type) { |
| 30 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 28 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 std::string serialized_report; | 79 std::string serialized_report; |
| 82 if (report.SerializeToString(&serialized_report)) | 80 if (report.SerializeToString(&serialized_report)) |
| 83 sb_service->SendSerializedDownloadReport(serialized_report); | 81 sb_service->SendSerializedDownloadReport(serialized_report); |
| 84 else | 82 else |
| 85 DLOG(ERROR) << "Unable to serialize the threat report."; | 83 DLOG(ERROR) << "Unable to serialize the threat report."; |
| 86 } | 84 } |
| 87 | 85 |
| 88 void DownloadDangerPrompt::RecordDownloadDangerPrompt( | 86 void DownloadDangerPrompt::RecordDownloadDangerPrompt( |
| 89 bool did_proceed, | 87 bool did_proceed, |
| 90 const content::DownloadItem& download) { | 88 const content::DownloadItem& download) { |
| 91 int dangerous_file_type = | 89 int64_t file_type_uma_value = |
| 92 GetSBClientDownloadExtensionValueForUMA(download.GetTargetFilePath()); | 90 safe_browsing::FileTypePolicies::GetInstance()->UmaValueForFile( |
| 91 download.GetTargetFilePath()); |
| 93 content::DownloadDangerType danger_type = download.GetDangerType(); | 92 content::DownloadDangerType danger_type = download.GetDangerType(); |
| 94 | 93 |
| 95 UMA_HISTOGRAM_SPARSE_SLOWLY( | 94 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 96 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix, | 95 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix, |
| 97 GetDangerTypeString(danger_type)), | 96 GetDangerTypeString(danger_type)), |
| 98 dangerous_file_type); | 97 file_type_uma_value); |
| 99 if (did_proceed) { | 98 if (did_proceed) { |
| 100 UMA_HISTOGRAM_SPARSE_SLOWLY( | 99 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 101 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix, | 100 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix, |
| 102 GetDangerTypeString(danger_type)), | 101 GetDangerTypeString(danger_type)), |
| 103 dangerous_file_type); | 102 file_type_uma_value); |
| 104 } | 103 } |
| 105 } | 104 } |
| OLD | NEW |