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 string16 AssembleMalwareFinchString(const std::string& trial_condition, | |
Dan Beam
2013/08/09 21:25:02
base::string16 everywhere
felt
2013/08/09 22:38:03
Done.
| |
287 const string16& elided_filename) { | |
288 // Sanity check to make sure we have a filename. | |
289 string16 filename; | |
290 if (elided_filename.empty()) { | |
Dan Beam
2013/08/09 21:25:02
nit: no curlies when if () and {} are 1-liners
felt
2013/08/09 22:38:03
Is that in the style guide? I can't find it and it
Dan Beam
2013/08/09 23:24:51
"In general, curly braces are not required for sin
| |
291 filename = ASCIIToUTF16("This file"); | |
292 } else { | |
293 filename = elided_filename; | |
294 } | |
Dan Beam
2013/08/09 21:25:02
nit: \n
felt
2013/08/09 22:38:03
Done.
| |
295 // Set the message text according to the condition. | |
296 string16 message_text; | |
297 if (trial_condition == kCondition1Control) { | |
298 message_text = ASCIIToUTF16("This file appears malicious."); | |
299 } else if (trial_condition == kCondition2Control) { | |
300 message_text = ReplaceStringPlaceholders( | |
301 ASCIIToUTF16("File '$1' appears malicious."), | |
302 filename, | |
303 NULL); | |
304 } else if (trial_condition == kCondition3Malicious) { | |
305 message_text = ReplaceStringPlaceholders( | |
306 ASCIIToUTF16("File '$1' is malicious."), | |
307 filename, | |
308 NULL); | |
309 } else if (trial_condition == kCondition4Unsafe) { | |
310 message_text = ReplaceStringPlaceholders( | |
311 ASCIIToUTF16("File '$1' is unsafe."), | |
312 filename, | |
313 NULL); | |
314 } else if (trial_condition == kCondition5Dangerous) { | |
315 message_text = ReplaceStringPlaceholders( | |
316 ASCIIToUTF16("File '$1' is dangerous."), | |
317 filename, | |
318 NULL); | |
319 } else if (trial_condition == kCondition6Harmful) { | |
320 message_text = ReplaceStringPlaceholders( | |
321 ASCIIToUTF16("File '$1' is harmful."), | |
322 filename, | |
323 NULL); | |
324 } else if (trial_condition == kCondition7DiscardSecond) { | |
325 message_text = ReplaceStringPlaceholders( | |
326 ASCIIToUTF16("File '$1' is malicious. Discard this file to stay safe."), | |
327 filename, | |
328 NULL); | |
329 } else if (trial_condition == kCondition8DiscardFirst) { | |
330 message_text = ReplaceStringPlaceholders( | |
331 ASCIIToUTF16("Discard this file to stay safe. File '$1' is malicious."), | |
332 filename, | |
333 NULL); | |
334 } else if (trial_condition == kCondition9SafeDiscard) { | |
335 message_text = ReplaceStringPlaceholders( | |
336 ASCIIToUTF16("File '$1' is malicious. To stay safe, discard it."), | |
337 filename, | |
338 NULL); | |
339 } else if (trial_condition == kCondition10SafeDontRun) { | |
340 message_text = ReplaceStringPlaceholders( | |
341 ASCIIToUTF16("File '$1' is malicious. To stay safe, don't run it."), | |
342 filename, | |
343 NULL); | |
344 } else { | |
345 // We use the second control as a default for other conditions that don't | |
346 // change the warning string. | |
347 message_text = ReplaceStringPlaceholders( | |
348 ASCIIToUTF16("File '$1' appears malicious."), | |
349 filename, | |
350 NULL); | |
351 } | |
Dan Beam
2013/08/09 21:25:02
nit: \n
felt
2013/08/09 22:38:03
Done.
| |
352 return message_text; | |
353 } | |
354 | |
272 } // namespace download_util | 355 } // namespace download_util |
OLD | NEW |