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 // Download utility implementation | 5 // Download utility implementation |
6 | 6 |
7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
8 | 8 |
9 #include <cmath> | 9 #include <cmath> |
10 #include <string> | 10 #include <string> |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 void RecordDownloadCount(ChromeDownloadCountTypes type) { | 262 void RecordDownloadCount(ChromeDownloadCountTypes type) { |
263 UMA_HISTOGRAM_ENUMERATION( | 263 UMA_HISTOGRAM_ENUMERATION( |
264 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); | 264 "Download.CountsChrome", type, CHROME_DOWNLOAD_COUNT_TYPES_LAST_ENTRY); |
265 } | 265 } |
266 | 266 |
267 void RecordDownloadSource(ChromeDownloadSource source) { | 267 void RecordDownloadSource(ChromeDownloadSource source) { |
268 UMA_HISTOGRAM_ENUMERATION( | 268 UMA_HISTOGRAM_ENUMERATION( |
269 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); | 269 "Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); |
270 } | 270 } |
271 | 271 |
| 272 // Finch trial ----------------------------------------------------------------- |
| 273 |
| 274 const char kFinchTrialName[] = "MalwareDownloadWarning"; |
| 275 const char kCondition1Control[] = "Condition1Control"; |
| 276 const char kCondition2Control[] = "Condition2Control"; |
| 277 const char kCondition3Malicious[] = "Condition3Malicious"; |
| 278 const char kCondition4Unsafe[] = "Condition4Unsafe"; |
| 279 const char kCondition5Dangerous[] = "Condition5Dangerous"; |
| 280 const char kCondition6Harmful[] = "Condition6Harmful"; |
| 281 const char kCondition7DiscardSecond[] = "Condition7DiscardSecond"; |
| 282 const char kCondition8DiscardFirst[] = "Condition8DiscardFirst"; |
| 283 const char kCondition9SafeDiscard[] = "Condition9SafeDiscard"; |
| 284 const char kCondition10SafeDontRun[] = "Condition10SafeDontRun"; |
| 285 |
| 286 base::string16 AssembleMalwareFinchString( |
| 287 const std::string& trial_condition, const base::string16& elided_filename) { |
| 288 // Sanity check to make sure we have a filename. |
| 289 base::string16 filename; |
| 290 if (elided_filename.empty()) { |
| 291 filename = ASCIIToUTF16("This file"); |
| 292 } else { |
| 293 filename = ReplaceStringPlaceholders(ASCIIToUTF16("File '$1'"), |
| 294 elided_filename, |
| 295 NULL); |
| 296 } |
| 297 |
| 298 // Set the message text according to the condition. |
| 299 if (trial_condition == kCondition1Control) { |
| 300 return ASCIIToUTF16("This file appears malicious."); |
| 301 } |
| 302 base::string16 message_text; |
| 303 if (trial_condition == kCondition2Control) { |
| 304 message_text = ASCIIToUTF16("$1 appears malicious."); |
| 305 } else if (trial_condition == kCondition3Malicious) { |
| 306 message_text = ASCIIToUTF16("$1 is malicious."); |
| 307 } else if (trial_condition == kCondition4Unsafe) { |
| 308 message_text = ASCIIToUTF16("$1 is unsafe."); |
| 309 } else if (trial_condition == kCondition5Dangerous) { |
| 310 message_text = ASCIIToUTF16("$1 is dangerous."); |
| 311 } else if (trial_condition == kCondition6Harmful) { |
| 312 message_text = ASCIIToUTF16("$1 is harmful."); |
| 313 } else if (trial_condition == kCondition7DiscardSecond) { |
| 314 message_text = ASCIIToUTF16( |
| 315 "$1 is malicious. Discard this file to stay safe."); |
| 316 } else if (trial_condition == kCondition8DiscardFirst) { |
| 317 message_text = ASCIIToUTF16( |
| 318 "Discard this file to stay safe. $1 is malicious."); |
| 319 } else if (trial_condition == kCondition9SafeDiscard) { |
| 320 message_text = ASCIIToUTF16("$1 is malicious. To stay safe, discard it."); |
| 321 } else if (trial_condition == kCondition10SafeDontRun) { |
| 322 message_text = ASCIIToUTF16("$1 is malicious. To stay safe, don't run it."); |
| 323 } else { |
| 324 // We use the second control as a default for other conditions that don't |
| 325 // change the warning string. |
| 326 message_text = ASCIIToUTF16("$1 appears malicious."); |
| 327 } |
| 328 |
| 329 return ReplaceStringPlaceholders(message_text, filename, NULL); |
| 330 } |
| 331 |
272 } // namespace download_util | 332 } // namespace download_util |
OLD | NEW |