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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 font, max_width, ui::ELIDE_AT_END); | 87 font, max_width, ui::ELIDE_AT_END); |
88 } | 88 } |
89 return tooltip; | 89 return tooltip; |
90 } | 90 } |
91 | 91 |
92 int DownloadItemModel::PercentComplete() const { | 92 int DownloadItemModel::PercentComplete() const { |
93 #if defined(OS_CHROMEOS) | 93 #if defined(OS_CHROMEOS) |
94 // For Drive uploads, progress is based on the number of bytes | 94 // For Drive uploads, progress is based on the number of bytes |
95 // uploaded. Progress is unknown until the upload starts. | 95 // uploaded. Progress is unknown until the upload starts. |
96 if (IsDriveDownload()) | 96 if (IsDriveDownload()) |
97 return gdata::DriveDownloadObserver::PercentComplete(download_); | 97 return drive::DriveDownloadObserver::PercentComplete(download_); |
98 #endif | 98 #endif |
99 return download_->PercentComplete(); | 99 return download_->PercentComplete(); |
100 } | 100 } |
101 | 101 |
102 string16 DownloadItemModel::GetWarningText(const gfx::Font& font, | 102 string16 DownloadItemModel::GetWarningText(const gfx::Font& font, |
103 int base_width) const { | 103 int base_width) const { |
104 // Should only be called if IsDangerous(). | 104 // Should only be called if IsDangerous(). |
105 DCHECK(IsDangerous()); | 105 DCHECK(IsDangerous()); |
106 switch (download_->GetDangerType()) { | 106 switch (download_->GetDangerType()) { |
107 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: | 107 case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL: |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 int64 DownloadItemModel::GetTotalBytes() const { | 179 int64 DownloadItemModel::GetTotalBytes() const { |
180 return download_->AllDataSaved() ? download_->GetReceivedBytes() : | 180 return download_->AllDataSaved() ? download_->GetReceivedBytes() : |
181 download_->GetTotalBytes(); | 181 download_->GetTotalBytes(); |
182 } | 182 } |
183 | 183 |
184 int64 DownloadItemModel::GetCompletedBytes() const { | 184 int64 DownloadItemModel::GetCompletedBytes() const { |
185 #if defined(OS_CHROMEOS) | 185 #if defined(OS_CHROMEOS) |
186 // For Drive downloads, the size is the count of bytes uploaded. | 186 // For Drive downloads, the size is the count of bytes uploaded. |
187 if (IsDriveDownload()) | 187 if (IsDriveDownload()) |
188 return gdata::DriveDownloadObserver::GetUploadedBytes(download_); | 188 return drive::DriveDownloadObserver::GetUploadedBytes(download_); |
189 #endif | 189 #endif |
190 return download_->GetReceivedBytes(); | 190 return download_->GetReceivedBytes(); |
191 } | 191 } |
192 | 192 |
193 bool DownloadItemModel::IsDriveDownload() const { | 193 bool DownloadItemModel::IsDriveDownload() const { |
194 #if defined(OS_CHROMEOS) | 194 #if defined(OS_CHROMEOS) |
195 return gdata::DriveDownloadObserver::IsDriveDownload(download_); | 195 return drive::DriveDownloadObserver::IsDriveDownload(download_); |
196 #else | 196 #else |
197 return false; | 197 return false; |
198 #endif | 198 #endif |
199 } | 199 } |
200 | 200 |
201 string16 DownloadItemModel::GetProgressSizesString() const { | 201 string16 DownloadItemModel::GetProgressSizesString() const { |
202 string16 size_ratio; | 202 string16 size_ratio; |
203 int64 size = GetCompletedBytes(); | 203 int64 size = GetCompletedBytes(); |
204 int64 total = GetTotalBytes(); | 204 int64 total = GetTotalBytes(); |
205 if (total > 0) { | 205 if (total > 0) { |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 break; | 392 break; |
393 default: | 393 default: |
394 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; | 394 string_id = IDS_DOWNLOAD_INTERRUPTED_STATUS; |
395 break; | 395 break; |
396 } | 396 } |
397 | 397 |
398 status_text = l10n_util::GetStringUTF16(string_id); | 398 status_text = l10n_util::GetStringUTF16(string_id); |
399 | 399 |
400 return status_text; | 400 return status_text; |
401 } | 401 } |
OLD | NEW |