Chromium Code Reviews| 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 "chrome/grit/chromium_strings.h" | |
| 15 #include "chrome/grit/generated_resources.h" | |
|
asanka
2016/05/18 18:47:54
Thanks for these.
| |
| 16 #include "content/public/browser/browser_context.h" | |
| 14 #include "content/public/browser/download_danger_type.h" | 17 #include "content/public/browser/download_danger_type.h" |
| 15 #include "content/public/browser/download_item.h" | 18 #include "content/public/browser/download_item.h" |
| 16 | 19 |
| 17 using safe_browsing::ClientDownloadResponse; | 20 using safe_browsing::ClientDownloadResponse; |
| 18 using safe_browsing::ClientSafeBrowsingReportRequest; | 21 using safe_browsing::ClientSafeBrowsingReportRequest; |
| 19 using safe_browsing::download_protection_util:: | |
| 20 GetSBClientDownloadExtensionValueForUMA; | |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 | 24 |
| 24 const char kDownloadDangerPromptPrefix[] = "Download.DownloadDangerPrompt"; | 25 const char kDownloadDangerPromptPrefix[] = "Download.DownloadDangerPrompt"; |
| 25 | 26 |
| 26 // Converts DownloadDangerType into their corresponding string. | 27 // Converts DownloadDangerType into their corresponding string. |
| 27 const char* GetDangerTypeString( | 28 const char* GetDangerTypeString( |
| 28 const content::DownloadDangerType& danger_type) { | 29 const content::DownloadDangerType& danger_type) { |
| 29 switch (danger_type) { | 30 switch (danger_type) { |
| 30 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 31 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; | 82 std::string serialized_report; |
| 82 if (report.SerializeToString(&serialized_report)) | 83 if (report.SerializeToString(&serialized_report)) |
| 83 sb_service->SendSerializedDownloadReport(serialized_report); | 84 sb_service->SendSerializedDownloadReport(serialized_report); |
| 84 else | 85 else |
| 85 DLOG(ERROR) << "Unable to serialize the threat report."; | 86 DLOG(ERROR) << "Unable to serialize the threat report."; |
| 86 } | 87 } |
| 87 | 88 |
| 88 void DownloadDangerPrompt::RecordDownloadDangerPrompt( | 89 void DownloadDangerPrompt::RecordDownloadDangerPrompt( |
| 89 bool did_proceed, | 90 bool did_proceed, |
| 90 const content::DownloadItem& download) { | 91 const content::DownloadItem& download) { |
| 91 int dangerous_file_type = | 92 int64_t file_type_uma_value = |
| 92 GetSBClientDownloadExtensionValueForUMA(download.GetTargetFilePath()); | 93 safe_browsing::FileTypePolicies::GlobalInstance()->UmaValueForFile( |
| 94 download.GetTargetFilePath()); | |
| 93 content::DownloadDangerType danger_type = download.GetDangerType(); | 95 content::DownloadDangerType danger_type = download.GetDangerType(); |
| 94 | 96 |
| 95 UMA_HISTOGRAM_SPARSE_SLOWLY( | 97 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 96 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix, | 98 base::StringPrintf("%s.%s.Shown", kDownloadDangerPromptPrefix, |
| 97 GetDangerTypeString(danger_type)), | 99 GetDangerTypeString(danger_type)), |
| 98 dangerous_file_type); | 100 file_type_uma_value); |
| 99 if (did_proceed) { | 101 if (did_proceed) { |
| 100 UMA_HISTOGRAM_SPARSE_SLOWLY( | 102 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 101 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix, | 103 base::StringPrintf("%s.%s.Proceed", kDownloadDangerPromptPrefix, |
| 102 GetDangerTypeString(danger_type)), | 104 GetDangerTypeString(danger_type)), |
| 103 dangerous_file_type); | 105 file_type_uma_value); |
| 104 } | 106 } |
| 105 } | 107 } |
| OLD | NEW |