| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (base::i18n::AdjustStringForLocaleDirection(total_text, | 558 if (base::i18n::AdjustStringForLocaleDirection(total_text, |
| 559 &total_text_localized)) | 559 &total_text_localized)) |
| 560 total_text.assign(total_text_localized); | 560 total_text.assign(total_text_localized); |
| 561 | 561 |
| 562 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, | 562 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, |
| 563 received_size, | 563 received_size, |
| 564 total_text); | 564 total_text); |
| 565 } else { | 565 } else { |
| 566 amount.assign(received_size); | 566 amount.assign(received_size); |
| 567 } | 567 } |
| 568 std::wstring speed_text; | 568 int64 current_speed = download->CurrentSpeed(); |
| 569 if (download->is_paused()) { | 569 amount_units = GetByteDisplayUnits(current_speed); |
| 570 // If the download is paused, set the rate to 0B/s. | 570 std::wstring speed_text = UTF16ToWideHack(FormatSpeed(current_speed, |
| 571 amount_units = GetByteDisplayUnits(0); | 571 amount_units, true)); |
| 572 speed_text = UTF16ToWideHack(FormatSpeed(0, amount_units, true)); | |
| 573 } else { | |
| 574 amount_units = GetByteDisplayUnits(download->CurrentSpeed()); | |
| 575 speed_text = UTF16ToWideHack(FormatSpeed(download->CurrentSpeed(), | |
| 576 amount_units, true)); | |
| 577 } | |
| 578 std::wstring speed_text_localized; | 572 std::wstring speed_text_localized; |
| 579 if (base::i18n::AdjustStringForLocaleDirection(speed_text, | 573 if (base::i18n::AdjustStringForLocaleDirection(speed_text, |
| 580 &speed_text_localized)) | 574 &speed_text_localized)) |
| 581 speed_text.assign(speed_text_localized); | 575 speed_text.assign(speed_text_localized); |
| 582 | 576 |
| 583 base::TimeDelta remaining; | 577 base::TimeDelta remaining; |
| 584 string16 time_remaining; | 578 string16 time_remaining; |
| 585 if (download->is_paused()) | 579 if (download->is_paused()) |
| 586 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); | 580 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); |
| 587 else if (download->TimeRemaining(&remaining)) | 581 else if (download->TimeRemaining(&remaining)) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 747 ExtensionsService* service = profile->GetExtensionsService(); | 741 ExtensionsService* service = profile->GetExtensionsService(); |
| 748 if (!service || | 742 if (!service || |
| 749 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { | 743 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { |
| 750 return true; | 744 return true; |
| 751 } | 745 } |
| 752 } | 746 } |
| 753 return false; | 747 return false; |
| 754 } | 748 } |
| 755 | 749 |
| 756 } // namespace download_util | 750 } // namespace download_util |
| 757 | |
| OLD | NEW |