Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1961)

Side by Side Diff: chrome/browser/download/download_danger_prompt.cc

Issue 22640018: Set up Finch trial for malware download warnings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Accidental indent Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/download/download_danger_prompt.h" 5 #include "chrome/browser/download/download_danger_prompt.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/field_trial.h"
8 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/download/chrome_download_manager_delegate.h" 10 #include "chrome/browser/download/chrome_download_manager_delegate.h"
11 #include "chrome/browser/download/download_util.h"
10 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" 12 #include "chrome/browser/ui/tab_modal_confirm_dialog.h"
11 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" 13 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h"
12 #include "content/public/browser/download_danger_type.h" 14 #include "content/public/browser/download_danger_type.h"
13 #include "content/public/browser/download_item.h" 15 #include "content/public/browser/download_item.h"
14 #include "grit/chromium_strings.h" 16 #include "grit/chromium_strings.h"
15 #include "grit/generated_resources.h" 17 #include "grit/generated_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
17 19
18 namespace { 20 namespace {
19 21
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 98
97 string16 DownloadDangerPromptImpl::GetTitle() { 99 string16 DownloadDangerPromptImpl::GetTitle() {
98 return l10n_util::GetStringUTF16(IDS_CONFIRM_KEEP_DANGEROUS_DOWNLOAD_TITLE); 100 return l10n_util::GetStringUTF16(IDS_CONFIRM_KEEP_DANGEROUS_DOWNLOAD_TITLE);
99 } 101 }
100 102
101 string16 DownloadDangerPromptImpl::GetMessage() { 103 string16 DownloadDangerPromptImpl::GetMessage() {
102 if (!show_context_) 104 if (!show_context_)
103 return l10n_util::GetStringUTF16( 105 return l10n_util::GetStringUTF16(
104 IDS_PROMPT_CONFIRM_KEEP_DANGEROUS_DOWNLOAD); 106 IDS_PROMPT_CONFIRM_KEEP_DANGEROUS_DOWNLOAD);
105 switch (download_->GetDangerType()) { 107 switch (download_->GetDangerType()) {
106 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: 108 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: {
107 return l10n_util::GetStringFUTF16( 109 return l10n_util::GetStringFUTF16(
108 IDS_PROMPT_DANGEROUS_DOWNLOAD, 110 IDS_PROMPT_DANGEROUS_DOWNLOAD,
109 download_->GetFileNameToReportUser().LossyDisplayName()); 111 download_->GetFileNameToReportUser().LossyDisplayName());
112 }
110 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: // Fall through 113 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: // Fall through
111 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: 114 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
112 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: 115 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST: {
113 return l10n_util::GetStringFUTF16( 116 std::string trial_condition =
114 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT, 117 base::FieldTrialList::FindFullName(download_util::kFinchTrialName);
118 if (trial_condition.empty()) {
119 return l10n_util::GetStringFUTF16(
120 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT,
121 download_->GetFileNameToReportUser().LossyDisplayName());
122 }
123 return download_util::AssembleMalwareFinchString(
124 trial_condition,
115 download_->GetFileNameToReportUser().LossyDisplayName()); 125 download_->GetFileNameToReportUser().LossyDisplayName());
116 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: 126 }
127 case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT: {
117 return l10n_util::GetStringFUTF16( 128 return l10n_util::GetStringFUTF16(
118 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT, 129 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT,
119 download_->GetFileNameToReportUser().LossyDisplayName()); 130 download_->GetFileNameToReportUser().LossyDisplayName());
120 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: 131 }
132 case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED: {
121 return l10n_util::GetStringFUTF16( 133 return l10n_util::GetStringFUTF16(
122 IDS_PROMPT_DOWNLOAD_CHANGES_SEARCH_SETTINGS, 134 IDS_PROMPT_DOWNLOAD_CHANGES_SEARCH_SETTINGS,
123 download_->GetFileNameToReportUser().LossyDisplayName()); 135 download_->GetFileNameToReportUser().LossyDisplayName());
136 }
124 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS: 137 case content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS:
125 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT: 138 case content::DOWNLOAD_DANGER_TYPE_MAYBE_DANGEROUS_CONTENT:
126 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED: 139 case content::DOWNLOAD_DANGER_TYPE_USER_VALIDATED:
127 case content::DOWNLOAD_DANGER_TYPE_MAX: 140 case content::DOWNLOAD_DANGER_TYPE_MAX: {
128 break; 141 break;
142 }
129 } 143 }
130 NOTREACHED(); 144 NOTREACHED();
131 return string16(); 145 return string16();
132 } 146 }
133 147
134 string16 DownloadDangerPromptImpl::GetAcceptButtonTitle() { 148 string16 DownloadDangerPromptImpl::GetAcceptButtonTitle() {
135 return l10n_util::GetStringUTF16( 149 return l10n_util::GetStringUTF16(
136 show_context_ ? IDS_CONFIRM_DOWNLOAD : IDS_CONFIRM_DOWNLOAD_AGAIN); 150 show_context_ ? IDS_CONFIRM_DOWNLOAD : IDS_CONFIRM_DOWNLOAD_AGAIN);
137 } 151 }
138 152
(...skipping 30 matching lines...) Expand all
169 content::DownloadItem* item, 183 content::DownloadItem* item,
170 content::WebContents* web_contents, 184 content::WebContents* web_contents,
171 bool show_context, 185 bool show_context,
172 const OnDone& done) { 186 const OnDone& done) {
173 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl( 187 DownloadDangerPromptImpl* prompt = new DownloadDangerPromptImpl(
174 item, web_contents, show_context, done); 188 item, web_contents, show_context, done);
175 // |prompt| will be deleted when the dialog is done. 189 // |prompt| will be deleted when the dialog is done.
176 TabModalConfirmDialog::Create(prompt, web_contents); 190 TabModalConfirmDialog::Create(prompt, web_contents);
177 return prompt; 191 return prompt;
178 } 192 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_item_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698