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/supports_user_data.h" | 10 #include "base/supports_user_data.h" |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // ----------------------------------------------------------------------------- | 211 // ----------------------------------------------------------------------------- |
212 // DownloadItemModel | 212 // DownloadItemModel |
213 | 213 |
214 DownloadItemModel::DownloadItemModel(DownloadItem* download) | 214 DownloadItemModel::DownloadItemModel(DownloadItem* download) |
215 : download_(download) { | 215 : download_(download) { |
216 } | 216 } |
217 | 217 |
218 DownloadItemModel::~DownloadItemModel() { | 218 DownloadItemModel::~DownloadItemModel() { |
219 } | 219 } |
220 | 220 |
221 void DownloadItemModel::CancelTask() { | |
222 download_->Cancel(true /* update history service */); | |
223 } | |
224 | |
225 string16 DownloadItemModel::GetInterruptReasonText() const { | 221 string16 DownloadItemModel::GetInterruptReasonText() const { |
226 if (download_->GetState() != DownloadItem::INTERRUPTED || | 222 if (download_->GetState() != DownloadItem::INTERRUPTED || |
227 download_->GetLastReason() == | 223 download_->GetLastReason() == |
228 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { | 224 content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { |
229 return string16(); | 225 return string16(); |
230 } | 226 } |
231 return InterruptReasonMessage(download_->GetLastReason()); | 227 return InterruptReasonMessage(download_->GetLastReason()); |
232 } | 228 } |
233 | 229 |
234 string16 DownloadItemModel::GetStatusText() const { | 230 string16 DownloadItemModel::GetStatusText() const { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 } | 445 } |
450 | 446 |
451 // In progress download with no known time left and non-zero completed bytes: | 447 // In progress download with no known time left and non-zero completed bytes: |
452 // "100/120 MB" or "100 MB" | 448 // "100/120 MB" or "100 MB" |
453 if (GetCompletedBytes() > 0) | 449 if (GetCompletedBytes() > 0) |
454 return size_ratio; | 450 return size_ratio; |
455 | 451 |
456 // Instead of displaying "0 B" we say "Starting..." | 452 // Instead of displaying "0 B" we say "Starting..." |
457 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); | 453 return l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING); |
458 } | 454 } |
OLD | NEW |