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" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 if (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) | 143 if (reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) |
144 status_text = size_text + status_text; | 144 status_text = size_text + status_text; |
145 break; | 145 break; |
146 default: | 146 default: |
147 NOTREACHED(); | 147 NOTREACHED(); |
148 } | 148 } |
149 | 149 |
150 return status_text; | 150 return status_text; |
151 } | 151 } |
152 | 152 |
| 153 string16 DownloadItemModel::GetTooltipText(const gfx::Font& font, |
| 154 int max_width) const { |
| 155 string16 tooltip = ui::ElideFilename( |
| 156 download_->GetFileNameToReportUser(), font, max_width); |
| 157 content::DownloadInterruptReason reason = download_->GetLastReason(); |
| 158 if (download_->GetState() == DownloadItem::INTERRUPTED && |
| 159 reason != content::DOWNLOAD_INTERRUPT_REASON_USER_CANCELED) { |
| 160 tooltip += ASCIIToUTF16("\n"); |
| 161 tooltip += ui::ElideText(InterruptReasonStatusMessage(reason), |
| 162 font, max_width, ui::ELIDE_AT_END); |
| 163 } |
| 164 return tooltip; |
| 165 } |
| 166 |
153 int DownloadItemModel::PercentComplete() const { | 167 int DownloadItemModel::PercentComplete() const { |
154 #if defined(OS_CHROMEOS) | 168 #if defined(OS_CHROMEOS) |
155 // For GData uploads, progress is based on the number of bytes | 169 // For GData uploads, progress is based on the number of bytes |
156 // uploaded. Progress is unknown until the upload starts. | 170 // uploaded. Progress is unknown until the upload starts. |
157 if (gdata::GDataDownloadObserver::IsGDataDownload(download_)) | 171 if (gdata::GDataDownloadObserver::IsGDataDownload(download_)) |
158 return gdata::GDataDownloadObserver::PercentComplete(download_); | 172 return gdata::GDataDownloadObserver::PercentComplete(download_); |
159 #endif | 173 #endif |
160 return download_->PercentComplete(); | 174 return download_->PercentComplete(); |
161 } | 175 } |
162 | 176 |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 break; | 360 break; |
347 default: | 361 default: |
348 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; | 362 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; |
349 break; | 363 break; |
350 } | 364 } |
351 | 365 |
352 status_text = l10n_util::GetStringUTF16(string_id); | 366 status_text = l10n_util::GetStringUTF16(string_id); |
353 | 367 |
354 return status_text; | 368 return status_text; |
355 } | 369 } |
OLD | NEW |