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 // 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 base::string16 message_text; | |
| 300 if (trial_condition == kCondition1Control) { | |
| 301 message_text = ASCIIToUTF16("This file appears malicious."); | |
| 302 } else if (trial_condition == kCondition2Control) { | |
| 303 message_text = ReplaceStringPlaceholders( | |
| 304 ASCIIToUTF16("$1 appears malicious."), | |
| 305 filename, | |
| 306 NULL); | |
|
Dan Beam
2013/08/09 23:24:51
nit: shaves code, reduces duplication
if (trial
felt
2013/08/09 23:48:34
Done.
| |
| 307 } else if (trial_condition == kCondition3Malicious) { | |
| 308 message_text = ReplaceStringPlaceholders( | |
| 309 ASCIIToUTF16("$1 is malicious."), | |
| 310 filename, | |
| 311 NULL); | |
| 312 } else if (trial_condition == kCondition4Unsafe) { | |
| 313 message_text = ReplaceStringPlaceholders( | |
| 314 ASCIIToUTF16("$1 is unsafe."), | |
| 315 filename, | |
| 316 NULL); | |
| 317 } else if (trial_condition == kCondition5Dangerous) { | |
| 318 message_text = ReplaceStringPlaceholders( | |
| 319 ASCIIToUTF16("$1 is dangerous."), | |
| 320 filename, | |
| 321 NULL); | |
| 322 } else if (trial_condition == kCondition6Harmful) { | |
| 323 message_text = ReplaceStringPlaceholders( | |
| 324 ASCIIToUTF16("$1 is harmful."), | |
| 325 filename, | |
| 326 NULL); | |
| 327 } else if (trial_condition == kCondition7DiscardSecond) { | |
| 328 message_text = ReplaceStringPlaceholders( | |
| 329 ASCIIToUTF16("$1 is malicious. Discard this file to stay safe."), | |
| 330 filename, | |
| 331 NULL); | |
| 332 } else if (trial_condition == kCondition8DiscardFirst) { | |
| 333 message_text = ReplaceStringPlaceholders( | |
| 334 ASCIIToUTF16("Discard this file to stay safe. $1 is malicious."), | |
| 335 filename, | |
| 336 NULL); | |
| 337 } else if (trial_condition == kCondition9SafeDiscard) { | |
| 338 message_text = ReplaceStringPlaceholders( | |
| 339 ASCIIToUTF16("$1 is malicious. To stay safe, discard it."), | |
| 340 filename, | |
| 341 NULL); | |
| 342 } else if (trial_condition == kCondition10SafeDontRun) { | |
| 343 message_text = ReplaceStringPlaceholders( | |
| 344 ASCIIToUTF16("$1 is malicious. To stay safe, don't run it."), | |
| 345 filename, | |
| 346 NULL); | |
| 347 } else { | |
| 348 // We use the second control as a default for other conditions that don't | |
| 349 // change the warning string. | |
| 350 message_text = ReplaceStringPlaceholders( | |
| 351 ASCIIToUTF16("$1 appears malicious."), | |
| 352 filename, | |
| 353 NULL); | |
| 354 } | |
| 355 | |
| 356 return message_text; | |
| 357 } | |
| 358 | |
| 272 } // namespace download_util | 359 } // namespace download_util |
| OLD | NEW |