Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Download utility implementation | 5 // Download utility implementation |
| 6 | 6 |
| 7 #include "chrome/browser/download/download_util.h" | 7 #include "chrome/browser/download/download_util.h" |
| 8 | 8 |
| 9 #if defined(OS_WIN) | 9 #if defined(OS_WIN) |
| 10 #include <shobjidl.h> | 10 #include <shobjidl.h> |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 if (base::i18n::AdjustStringForLocaleDirection(total_text, | 575 if (base::i18n::AdjustStringForLocaleDirection(total_text, |
| 576 &total_text_localized)) | 576 &total_text_localized)) |
| 577 total_text.assign(total_text_localized); | 577 total_text.assign(total_text_localized); |
| 578 | 578 |
| 579 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, | 579 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, |
| 580 received_size, | 580 received_size, |
| 581 total_text); | 581 total_text); |
| 582 } else { | 582 } else { |
| 583 amount.assign(received_size); | 583 amount.assign(received_size); |
| 584 } | 584 } |
| 585 amount_units = GetByteDisplayUnits(download->CurrentSpeed()); | 585 std::wstring speed_text; |
| 586 std::wstring speed_text = | 586 if (download->is_paused()) { |
|
Paweł Hajdan Jr.
2010/11/10 12:14:02
This seems wrong. Why not do that in download->Cur
| |
| 587 UTF16ToWideHack(FormatSpeed(download->CurrentSpeed(), amount_units, | 587 // If the download is paused, set the rate to 0B/s. |
| 588 true)); | 588 amount_units = GetByteDisplayUnits(0); |
| 589 speed_text = UTF16ToWideHack(FormatSpeed(0, amount_units, true)); | |
| 590 } else { | |
| 591 amount_units = GetByteDisplayUnits(download->CurrentSpeed()); | |
| 592 speed_text = UTF16ToWideHack(FormatSpeed(download->CurrentSpeed(), | |
| 593 amount_units, true)); | |
| 594 } | |
| 589 std::wstring speed_text_localized; | 595 std::wstring speed_text_localized; |
| 590 if (base::i18n::AdjustStringForLocaleDirection(speed_text, | 596 if (base::i18n::AdjustStringForLocaleDirection(speed_text, |
| 591 &speed_text_localized)) | 597 &speed_text_localized)) |
| 592 speed_text.assign(speed_text_localized); | 598 speed_text.assign(speed_text_localized); |
| 593 | 599 |
| 594 base::TimeDelta remaining; | 600 base::TimeDelta remaining; |
| 595 string16 time_remaining; | 601 string16 time_remaining; |
| 596 if (download->is_paused()) | 602 if (download->is_paused()) |
| 597 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); | 603 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); |
| 598 else if (download->TimeRemaining(&remaining)) | 604 else if (download->TimeRemaining(&remaining)) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 758 ExtensionsService* service = profile->GetExtensionsService(); | 764 ExtensionsService* service = profile->GetExtensionsService(); |
| 759 if (!service || | 765 if (!service || |
| 760 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 766 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
| 761 return true; | 767 return true; |
| 762 } | 768 } |
| 763 } | 769 } |
| 764 return false; | 770 return false; |
| 765 } | 771 } |
| 766 | 772 |
| 767 } // namespace download_util | 773 } // namespace download_util |
| OLD | NEW |