Index: chrome/browser/download/download_util.cc |
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc |
index 8010f97301aaa887eaec16263d701d85170f2102..b3774276f4742a6b7ac32250b35d2a95215ace15 100644 |
--- a/chrome/browser/download/download_util.cc |
+++ b/chrome/browser/download/download_util.cc |
@@ -269,4 +269,87 @@ void RecordDownloadSource(ChromeDownloadSource source) { |
"Download.SourcesChrome", source, CHROME_DOWNLOAD_SOURCE_LAST_ENTRY); |
} |
+// Finch trial ----------------------------------------------------------------- |
+ |
+const char kFinchTrialName[] = "MalwareDownloadWarning"; |
+const char kCondition1Control[] = "Condition1Control"; |
+const char kCondition2Control[] = "Condition2Control"; |
+const char kCondition3Malicious[] = "Condition3Malicious"; |
+const char kCondition4Unsafe[] = "Condition4Unsafe"; |
+const char kCondition5Dangerous[] = "Condition5Dangerous"; |
+const char kCondition6Harmful[] = "Condition6Harmful"; |
+const char kCondition7DiscardSecond[] = "Condition7DiscardSecond"; |
+const char kCondition8DiscardFirst[] = "Condition8DiscardFirst"; |
+const char kCondition9SafeDiscard[] = "Condition9SafeDiscard"; |
+const char kCondition10SafeDontRun[] = "Condition10SafeDontRun"; |
+ |
+string16 AssembleMalwareFinchString(const std::string& trial_condition, |
+ const string16& elided_filename) { |
+ // Sanity check to make sure we have a filename. |
+ string16 filename; |
+ if (elided_filename.empty()) { |
+ filename = ASCIIToUTF16("This file"); |
+ } else { |
+ filename = elided_filename; |
+ } |
+ // Set the message text according to the condition. |
+ string16 message_text; |
+ if (trial_condition == kCondition1Control) { |
+ message_text = ASCIIToUTF16("This file appears malicious."); |
+ } else if (trial_condition == kCondition2Control) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 appears malicious."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition3Malicious) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is malicious."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition4Unsafe) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is unsafe."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition5Dangerous) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is dangerous."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition6Harmful) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is harmful."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition7DiscardSecond) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is malicious. Discard this file to stay safe."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition8DiscardFirst) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("Discard this file to stay safe. $1 is malicious."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition9SafeDiscard) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is malicious. To stay safe, discard it."), |
+ filename, |
+ NULL); |
+ } else if (trial_condition == kCondition10SafeDontRun) { |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 is malicious. To stay safe, don't run it."), |
+ filename, |
+ NULL); |
+ } else { |
+ // We use the second control as a default for other conditions that don't |
+ // change the warning string. |
+ message_text = ReplaceStringPlaceholders( |
+ ASCIIToUTF16("$1 appears malicious."), |
+ filename, |
+ NULL); |
+ } |
+ return message_text; |
+} |
+ |
} // namespace download_util |