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 "content/browser/download/download_stats.h" | 5 #include "content/browser/download/download_stats.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/metrics/sparse_histogram.h" | 8 #include "base/metrics/sparse_histogram.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "content/browser/download/download_resource_handler.h" | 10 #include "content/browser/download/download_resource_handler.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 | 63 |
64 void RecordContentDispositionCountFlag( | 64 void RecordContentDispositionCountFlag( |
65 ContentDispositionCountTypes type, | 65 ContentDispositionCountTypes type, |
66 int flags_to_test, | 66 int flags_to_test, |
67 net::HttpContentDisposition::ParseResultFlags flag) { | 67 net::HttpContentDisposition::ParseResultFlags flag) { |
68 RecordContentDispositionCount(type, (flags_to_test & flag) == flag); | 68 RecordContentDispositionCount(type, (flags_to_test & flag) == flag); |
69 } | 69 } |
70 | 70 |
71 // Do not insert, delete, or reorder; this is being histogrammed. Append only. | 71 // Do not insert, delete, or reorder; this is being histogrammed. Append only. |
72 // All of the download_extensions.cc file types should be in this list. | 72 // All of the download_extensions.cc file types should be in this list. |
| 73 // TODO(asanka): This enum and the UMA metrics for dangerous/malicious downloads |
| 74 // should be moved to //chrome/browser/download. |
73 const base::FilePath::CharType* kDangerousFileTypes[] = { | 75 const base::FilePath::CharType* kDangerousFileTypes[] = { |
74 FILE_PATH_LITERAL(".ad"), | 76 FILE_PATH_LITERAL(".ad"), |
75 FILE_PATH_LITERAL(".ade"), | 77 FILE_PATH_LITERAL(".ade"), |
76 FILE_PATH_LITERAL(".adp"), | 78 FILE_PATH_LITERAL(".adp"), |
77 FILE_PATH_LITERAL(".ah"), | 79 FILE_PATH_LITERAL(".ah"), |
78 FILE_PATH_LITERAL(".apk"), | 80 FILE_PATH_LITERAL(".apk"), |
79 FILE_PATH_LITERAL(".app"), | 81 FILE_PATH_LITERAL(".app"), |
80 FILE_PATH_LITERAL(".application"), | 82 FILE_PATH_LITERAL(".application"), |
81 FILE_PATH_LITERAL(".asp"), | 83 FILE_PATH_LITERAL(".asp"), |
82 FILE_PATH_LITERAL(".asx"), | 84 FILE_PATH_LITERAL(".asx"), |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 FILE_PATH_LITERAL(".ws"), | 189 FILE_PATH_LITERAL(".ws"), |
188 FILE_PATH_LITERAL(".wsc"), | 190 FILE_PATH_LITERAL(".wsc"), |
189 FILE_PATH_LITERAL(".wsf"), | 191 FILE_PATH_LITERAL(".wsf"), |
190 FILE_PATH_LITERAL(".wsh"), | 192 FILE_PATH_LITERAL(".wsh"), |
191 FILE_PATH_LITERAL(".xbap"), | 193 FILE_PATH_LITERAL(".xbap"), |
192 FILE_PATH_LITERAL(".xht"), | 194 FILE_PATH_LITERAL(".xht"), |
193 FILE_PATH_LITERAL(".xhtm"), | 195 FILE_PATH_LITERAL(".xhtm"), |
194 FILE_PATH_LITERAL(".xhtml"), | 196 FILE_PATH_LITERAL(".xhtml"), |
195 FILE_PATH_LITERAL(".xml"), | 197 FILE_PATH_LITERAL(".xml"), |
196 FILE_PATH_LITERAL(".xsl"), | 198 FILE_PATH_LITERAL(".xsl"), |
197 FILE_PATH_LITERAL(".xslt") | 199 FILE_PATH_LITERAL(".xslt"), |
198 FILE_PATH_LITERAL(".website") | 200 FILE_PATH_LITERAL(".website"), |
| 201 FILE_PATH_LITERAL(".msh1"), |
| 202 FILE_PATH_LITERAL(".msh2"), |
| 203 FILE_PATH_LITERAL(".msh1xml"), |
| 204 FILE_PATH_LITERAL(".msh2xml"), |
| 205 FILE_PATH_LITERAL(".ps1"), |
| 206 FILE_PATH_LITERAL(".ps1xml"), |
| 207 FILE_PATH_LITERAL(".ps2"), |
| 208 FILE_PATH_LITERAL(".ps2xml"), |
| 209 FILE_PATH_LITERAL(".psc1"), |
| 210 FILE_PATH_LITERAL(".psc2"), |
| 211 FILE_PATH_LITERAL(".xnk"), |
199 }; | 212 }; |
200 | 213 |
201 // Maps extensions to their matching UMA histogram int value. | 214 // Maps extensions to their matching UMA histogram int value. |
202 int GetDangerousFileType(const base::FilePath& file_path) { | 215 int GetDangerousFileType(const base::FilePath& file_path) { |
203 for (size_t i = 0; i < arraysize(kDangerousFileTypes); ++i) { | 216 for (size_t i = 0; i < arraysize(kDangerousFileTypes); ++i) { |
204 if (file_path.MatchesExtension(kDangerousFileTypes[i])) | 217 if (file_path.MatchesExtension(kDangerousFileTypes[i])) |
205 return i + 1; | 218 return i + 1; |
206 } | 219 } |
207 return 0; // Unknown extension. | 220 return 0; // Unknown extension. |
208 } | 221 } |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 int state) { | 638 int state) { |
626 if (is_partial) | 639 if (is_partial) |
627 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, | 640 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnPartialResumption", state, |
628 ORIGIN_STATE_ON_RESUMPTION_MAX); | 641 ORIGIN_STATE_ON_RESUMPTION_MAX); |
629 else | 642 else |
630 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, | 643 UMA_HISTOGRAM_ENUMERATION("Download.OriginStateOnFullResumption", state, |
631 ORIGIN_STATE_ON_RESUMPTION_MAX); | 644 ORIGIN_STATE_ON_RESUMPTION_MAX); |
632 } | 645 } |
633 | 646 |
634 } // namespace content | 647 } // namespace content |
OLD | NEW |