| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/download/download_item.h" | 11 #include "chrome/browser/download/download_item.h" |
| 12 #include "chrome/browser/download/save_package.h" | 12 #include "chrome/browser/download/save_package.h" |
| 13 #include "chrome/common/time_format.h" | 13 #include "chrome/common/time_format.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/text/bytes_formatting.h" | 16 #include "ui/base/text/bytes_formatting.h" |
| 17 | 17 |
| 18 using base::TimeDelta; | 18 using base::TimeDelta; |
| 19 | 19 |
| 20 // ----------------------------------------------------------------------------- | 20 // ----------------------------------------------------------------------------- |
| 21 // DownloadItemModel | 21 // DownloadItemModel |
| 22 | 22 |
| 23 DownloadItemModel::DownloadItemModel(DownloadItem* download) | 23 DownloadItemModel::DownloadItemModel(DownloadItem* download) |
| 24 : BaseDownloadItemModel(download) { | 24 : BaseDownloadItemModel(download) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 void DownloadItemModel::CancelTask() { | 27 void DownloadItemModel::CancelTask() { |
| 28 download_->Cancel(true /* update history service */); | 28 download_->Cancel(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 string16 DownloadItemModel::GetStatusText() { | 31 string16 DownloadItemModel::GetStatusText() { |
| 32 int64 size = download_->received_bytes(); | 32 int64 size = download_->received_bytes(); |
| 33 int64 total = download_->total_bytes(); | 33 int64 total = download_->total_bytes(); |
| 34 | 34 |
| 35 ui::DataUnits amount_units = ui::GetByteDisplayUnits(total); | 35 ui::DataUnits amount_units = ui::GetByteDisplayUnits(total); |
| 36 string16 simple_size = ui::FormatBytesWithUnits(size, amount_units, false); | 36 string16 simple_size = ui::FormatBytesWithUnits(size, amount_units, false); |
| 37 | 37 |
| 38 // In RTL locales, we render the text "size/total" in an RTL context. This | 38 // In RTL locales, we render the text "size/total" in an RTL context. This |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 IDS_SAVE_PAGE_STATUS_INTERRUPTED, | 143 IDS_SAVE_PAGE_STATUS_INTERRUPTED, |
| 144 base::FormatNumber(size), | 144 base::FormatNumber(size), |
| 145 base::FormatNumber(total_size)); | 145 base::FormatNumber(total_size)); |
| 146 break; | 146 break; |
| 147 default: | 147 default: |
| 148 NOTREACHED(); | 148 NOTREACHED(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 return status_text; | 151 return status_text; |
| 152 } | 152 } |
| OLD | NEW |