Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 7189076: Localize strings, speeds. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright dates Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "grit/generated_resources.h" 44 #include "grit/generated_resources.h"
45 #include "grit/locale_settings.h" 45 #include "grit/locale_settings.h"
46 #include "grit/theme_resources.h" 46 #include "grit/theme_resources.h"
47 #include "net/base/mime_util.h" 47 #include "net/base/mime_util.h"
48 #include "net/base/net_util.h" 48 #include "net/base/net_util.h"
49 #include "skia/ext/image_operations.h" 49 #include "skia/ext/image_operations.h"
50 #include "third_party/skia/include/core/SkPath.h" 50 #include "third_party/skia/include/core/SkPath.h"
51 #include "third_party/skia/include/core/SkShader.h" 51 #include "third_party/skia/include/core/SkShader.h"
52 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
53 #include "ui/base/resource/resource_bundle.h" 53 #include "ui/base/resource/resource_bundle.h"
54 #include "ui/base/text/bytes_formatting.h"
54 #include "ui/gfx/canvas_skia.h" 55 #include "ui/gfx/canvas_skia.h"
55 #include "ui/gfx/image/image.h" 56 #include "ui/gfx/image/image.h"
56 #include "ui/gfx/rect.h" 57 #include "ui/gfx/rect.h"
57 58
58 #if defined(TOOLKIT_VIEWS) 59 #if defined(TOOLKIT_VIEWS)
59 #include "ui/base/dragdrop/os_exchange_data.h" 60 #include "ui/base/dragdrop/os_exchange_data.h"
60 #include "views/drag_utils.h" 61 #include "views/drag_utils.h"
61 #endif 62 #endif
62 63
63 #if defined(TOOLKIT_USES_GTK) 64 #if defined(TOOLKIT_USES_GTK)
(...skipping 653 matching lines...) Expand 10 before | Expand all | Expand 10 after
717 } else { 718 } else {
718 NOTREACHED() << "state undefined"; 719 NOTREACHED() << "state undefined";
719 } 720 }
720 721
721 return file_value; 722 return file_value;
722 } 723 }
723 724
724 string16 GetProgressStatusText(DownloadItem* download) { 725 string16 GetProgressStatusText(DownloadItem* download) {
725 int64 total = download->total_bytes(); 726 int64 total = download->total_bytes();
726 int64 size = download->received_bytes(); 727 int64 size = download->received_bytes();
727 DataUnits amount_units = GetByteDisplayUnits(size); 728 string16 received_size = ui::FormatBytes(size);
728 string16 received_size = FormatBytes(size, amount_units, true);
729 string16 amount = received_size; 729 string16 amount = received_size;
730 730
731 // Adjust both strings for the locale direction since we don't yet know which 731 // Adjust both strings for the locale direction since we don't yet know which
732 // string we'll end up using for constructing the final progress string. 732 // string we'll end up using for constructing the final progress string.
733 base::i18n::AdjustStringForLocaleDirection(&amount); 733 base::i18n::AdjustStringForLocaleDirection(&amount);
734 734
735 if (total) { 735 if (total) {
736 amount_units = GetByteDisplayUnits(total); 736 string16 total_text = ui::FormatBytes(total);
737 string16 total_text = FormatBytes(total, amount_units, true);
738 base::i18n::AdjustStringForLocaleDirection(&total_text); 737 base::i18n::AdjustStringForLocaleDirection(&total_text);
739 738
740 base::i18n::AdjustStringForLocaleDirection(&received_size); 739 base::i18n::AdjustStringForLocaleDirection(&received_size);
741 amount = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, 740 amount = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_SIZE,
742 received_size, 741 received_size,
743 total_text); 742 total_text);
744 } else { 743 } else {
745 amount.assign(received_size); 744 amount.assign(received_size);
746 } 745 }
747 int64 current_speed = download->CurrentSpeed(); 746 int64 current_speed = download->CurrentSpeed();
748 amount_units = GetByteDisplayUnits(current_speed); 747 string16 speed_text = ui::FormatSpeed(current_speed);
749 string16 speed_text = FormatSpeed(current_speed, amount_units, true);
750 base::i18n::AdjustStringForLocaleDirection(&speed_text); 748 base::i18n::AdjustStringForLocaleDirection(&speed_text);
751 749
752 base::TimeDelta remaining; 750 base::TimeDelta remaining;
753 string16 time_remaining; 751 string16 time_remaining;
754 if (download->is_paused()) 752 if (download->is_paused())
755 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); 753 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED);
756 else if (download->TimeRemaining(&remaining)) 754 else if (download->TimeRemaining(&remaining))
757 time_remaining = TimeFormat::TimeRemaining(remaining); 755 time_remaining = TimeFormat::TimeRemaining(remaining);
758 756
759 if (time_remaining.empty()) { 757 if (time_remaining.empty()) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 FilePath GetCrDownloadPath(const FilePath& suggested_path) { 907 FilePath GetCrDownloadPath(const FilePath& suggested_path) {
910 FilePath::StringType file_name; 908 FilePath::StringType file_name;
911 base::SStringPrintf( 909 base::SStringPrintf(
912 &file_name, 910 &file_name,
913 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), 911 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"),
914 suggested_path.value().c_str()); 912 suggested_path.value().c_str());
915 return FilePath(file_name); 913 return FilePath(file_name);
916 } 914 }
917 915
918 } // namespace download_util 916 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698