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 // 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 string16 AssembleMalwareFinchString(const std::string& trialCondition, | |
| 273 const string16& elided_filename) { | |
| 274 // Sanity check to make sure we have a filename. | |
| 275 string16 filename; | |
| 276 if (elided_filename == string16()) { | |
|
asanka
2013/08/09 18:50:17
Nit: elided_filename.empty()
felt
2013/08/09 19:13:15
Done.
| |
| 277 filename = ASCIIToUTF16("This file"); | |
| 278 } else { | |
| 279 filename = elided_filename; | |
| 280 } | |
| 281 // Set the message text according to the condition. | |
| 282 string16 message_text; | |
| 283 if (trialCondition == kCondition1Control) { | |
| 284 message_text = ASCIIToUTF16("This file appears malicious."); | |
| 285 } else if (trialCondition == kCondition2Control) { | |
| 286 message_text = ReplaceStringPlaceholders( | |
| 287 ASCIIToUTF16("$1 appears malicious."), | |
| 288 filename, | |
| 289 NULL); | |
| 290 } else if (trialCondition == kCondition3Malicious) { | |
| 291 message_text = ReplaceStringPlaceholders( | |
| 292 ASCIIToUTF16("$1 is malicious."), | |
| 293 filename, | |
| 294 NULL); | |
| 295 } else if (trialCondition == kCondition4Unsafe) { | |
| 296 message_text = ReplaceStringPlaceholders( | |
| 297 ASCIIToUTF16("$1 is unsafe."), | |
| 298 filename, | |
| 299 NULL); | |
| 300 } else if (trialCondition == kCondition5Dangerous) { | |
| 301 message_text = ReplaceStringPlaceholders( | |
| 302 ASCIIToUTF16("$1 is dangerous."), | |
| 303 filename, | |
| 304 NULL); | |
| 305 } else if (trialCondition == kCondition6Harmful) { | |
| 306 message_text = ReplaceStringPlaceholders( | |
| 307 ASCIIToUTF16("$1 is harmful."), | |
| 308 filename, | |
| 309 NULL); | |
| 310 } else if (trialCondition == kCondition7DiscardSecond) { | |
| 311 message_text = ReplaceStringPlaceholders( | |
| 312 ASCIIToUTF16("$1 is malicious. Discard this file to stay safe."), | |
| 313 filename, | |
| 314 NULL); | |
| 315 } else if (trialCondition == kCondition8DiscardFirst) { | |
| 316 message_text = ReplaceStringPlaceholders( | |
| 317 ASCIIToUTF16("Discard this file to stay safe. $1 is malicious."), | |
| 318 filename, | |
| 319 NULL); | |
| 320 } else if (trialCondition == kCondition9SafeDiscard) { | |
| 321 message_text = ReplaceStringPlaceholders( | |
| 322 ASCIIToUTF16("$1 is malicious. To stay safe, discard it."), | |
| 323 filename, | |
| 324 NULL); | |
| 325 } else if (trialCondition == kCondition10SafeDontRun) { | |
| 326 message_text = ReplaceStringPlaceholders( | |
| 327 ASCIIToUTF16("$1 is malicious. To stay safe, don't run it."), | |
| 328 filename, | |
| 329 NULL); | |
| 330 } else { | |
| 331 // We use the second control as a default for other conditions that don't | |
| 332 // change the warning string. | |
| 333 message_text = ReplaceStringPlaceholders( | |
| 334 ASCIIToUTF16("$1 appears malicious."), | |
| 335 filename, | |
| 336 NULL); | |
| 337 } | |
| 338 return message_text; | |
| 339 } | |
| 340 | |
| 272 } // namespace download_util | 341 } // namespace download_util |
| OLD | NEW |