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 #include "chrome/browser/download/download_item_model.h" | 5 #include "chrome/browser/download/download_item_model.h" |
6 | 6 |
7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 12 #include "base/time.h" |
| 13 #include "chrome/browser/download/download_crx_util.h" |
13 #include "chrome/common/time_format.h" | 14 #include "chrome/common/time_format.h" |
14 #include "content/public/browser/download_danger_type.h" | 15 #include "content/public/browser/download_danger_type.h" |
15 #include "content/public/browser/download_interrupt_reasons.h" | 16 #include "content/public/browser/download_interrupt_reasons.h" |
16 #include "content/public/browser/download_item.h" | 17 #include "content/public/browser/download_item.h" |
17 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
19 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/text/bytes_formatting.h" | 21 #include "ui/base/text/bytes_formatting.h" |
21 #include "ui/base/text/text_elider.h" | 22 #include "ui/base/text/text_elider.h" |
22 | 23 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 case DownloadItem::IN_PROGRESS: | 79 case DownloadItem::IN_PROGRESS: |
79 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
80 if (is_gdata && size == 0) { | 81 if (is_gdata && size == 0) { |
81 // We haven't started the upload yet. The download needs to progress | 82 // We haven't started the upload yet. The download needs to progress |
82 // further before we will see any upload progress. Show "Downloading..." | 83 // further before we will see any upload progress. Show "Downloading..." |
83 // until we start uploading. | 84 // until we start uploading. |
84 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_WAITING); | 85 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_WAITING); |
85 break; | 86 break; |
86 } | 87 } |
87 #endif | 88 #endif |
88 if (ChromeDownloadManagerDelegate::IsExtensionDownload(download_) && | 89 if (download_crx_util::IsExtensionDownload(*download_) && |
89 download_->AllDataSaved() && | 90 download_->AllDataSaved() && |
90 download_->GetState() == DownloadItem::IN_PROGRESS) { | 91 download_->GetState() == DownloadItem::IN_PROGRESS) { |
91 // The download is a CRX (app, extension, theme, ...) and it is | 92 // The download is a CRX (app, extension, theme, ...) and it is |
92 // being unpacked and validated. | 93 // being unpacked and validated. |
93 status_text = l10n_util::GetStringUTF16( | 94 status_text = l10n_util::GetStringUTF16( |
94 IDS_DOWNLOAD_STATUS_CRX_INSTALL_RUNNING); | 95 IDS_DOWNLOAD_STATUS_CRX_INSTALL_RUNNING); |
95 } else if (download_->GetOpenWhenComplete()) { | 96 } else if (download_->GetOpenWhenComplete()) { |
96 if (simple_time.empty()) { | 97 if (simple_time.empty()) { |
97 status_text = | 98 status_text = |
98 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); | 99 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 | 177 |
177 string16 DownloadItemModel::GetWarningText(const gfx::Font& font, | 178 string16 DownloadItemModel::GetWarningText(const gfx::Font& font, |
178 int base_width) { | 179 int base_width) { |
179 // Should only be called if IsDangerous(). | 180 // Should only be called if IsDangerous(). |
180 DCHECK(IsDangerous()); | 181 DCHECK(IsDangerous()); |
181 switch (download_->GetDangerType()) { | 182 switch (download_->GetDangerType()) { |
182 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 183 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
183 return l10n_util::GetStringUTF16(IDS_PROMPT_MALICIOUS_DOWNLOAD_URL); | 184 return l10n_util::GetStringUTF16(IDS_PROMPT_MALICIOUS_DOWNLOAD_URL); |
184 | 185 |
185 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: | 186 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE: |
186 if (ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) { | 187 if (download_crx_util::IsExtensionDownload(*download_)) { |
187 return l10n_util::GetStringUTF16( | 188 return l10n_util::GetStringUTF16( |
188 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); | 189 IDS_PROMPT_DANGEROUS_DOWNLOAD_EXTENSION); |
189 } else { | 190 } else { |
190 return l10n_util::GetStringFUTF16( | 191 return l10n_util::GetStringFUTF16( |
191 IDS_PROMPT_DANGEROUS_DOWNLOAD, | 192 IDS_PROMPT_DANGEROUS_DOWNLOAD, |
192 ui::ElideFilename(download_->GetFileNameToReportUser(), | 193 ui::ElideFilename(download_->GetFileNameToReportUser(), |
193 font, base_width)); | 194 font, base_width)); |
194 } | 195 } |
195 | 196 |
196 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: | 197 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT: |
(...skipping 14 matching lines...) Expand all Loading... |
211 NOTREACHED(); | 212 NOTREACHED(); |
212 } | 213 } |
213 return string16(); | 214 return string16(); |
214 } | 215 } |
215 | 216 |
216 string16 DownloadItemModel::GetWarningConfirmButtonText() { | 217 string16 DownloadItemModel::GetWarningConfirmButtonText() { |
217 // Should only be called if IsDangerous() | 218 // Should only be called if IsDangerous() |
218 DCHECK(IsDangerous()); | 219 DCHECK(IsDangerous()); |
219 if (download_->GetDangerType() == | 220 if (download_->GetDangerType() == |
220 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && | 221 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE && |
221 ChromeDownloadManagerDelegate::IsExtensionDownload(download_)) { | 222 download_crx_util::IsExtensionDownload(*download_)) { |
222 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); | 223 return l10n_util::GetStringUTF16(IDS_CONTINUE_EXTENSION_DOWNLOAD); |
223 } else { | 224 } else { |
224 return l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD); | 225 return l10n_util::GetStringUTF16(IDS_CONFIRM_DOWNLOAD); |
225 } | 226 } |
226 } | 227 } |
227 | 228 |
228 bool DownloadItemModel::IsMalicious() { | 229 bool DownloadItemModel::IsMalicious() { |
229 if (!IsDangerous()) | 230 if (!IsDangerous()) |
230 return false; | 231 return false; |
231 switch (download_->GetDangerType()) { | 232 switch (download_->GetDangerType()) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 break; | 361 break; |
361 default: | 362 default: |
362 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; | 363 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; |
363 break; | 364 break; |
364 } | 365 } |
365 | 366 |
366 status_text = l10n_util::GetStringUTF16(string_id); | 367 status_text = l10n_util::GetStringUTF16(string_id); |
367 | 368 |
368 return status_text; | 369 return status_text; |
369 } | 370 } |
OLD | NEW |