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

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: typo 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "grit/generated_resources.h" 47 #include "grit/generated_resources.h"
48 #include "grit/locale_settings.h" 48 #include "grit/locale_settings.h"
49 #include "grit/theme_resources.h" 49 #include "grit/theme_resources.h"
50 #include "net/base/mime_util.h" 50 #include "net/base/mime_util.h"
51 #include "net/base/net_util.h" 51 #include "net/base/net_util.h"
52 #include "skia/ext/image_operations.h" 52 #include "skia/ext/image_operations.h"
53 #include "third_party/skia/include/core/SkPath.h" 53 #include "third_party/skia/include/core/SkPath.h"
54 #include "third_party/skia/include/core/SkShader.h" 54 #include "third_party/skia/include/core/SkShader.h"
55 #include "ui/base/l10n/l10n_util.h" 55 #include "ui/base/l10n/l10n_util.h"
56 #include "ui/base/resource/resource_bundle.h" 56 #include "ui/base/resource/resource_bundle.h"
57 #include "ui/base/text/bytes_formatting.h"
57 #include "ui/gfx/canvas_skia.h" 58 #include "ui/gfx/canvas_skia.h"
58 #include "ui/gfx/image/image.h" 59 #include "ui/gfx/image/image.h"
59 #include "ui/gfx/rect.h" 60 #include "ui/gfx/rect.h"
60 61
61 #if defined(TOOLKIT_VIEWS) 62 #if defined(TOOLKIT_VIEWS)
62 #include "ui/base/dragdrop/os_exchange_data.h" 63 #include "ui/base/dragdrop/os_exchange_data.h"
63 #include "views/drag_utils.h" 64 #include "views/drag_utils.h"
64 #endif 65 #endif
65 66
66 #if defined(TOOLKIT_USES_GTK) 67 #if defined(TOOLKIT_USES_GTK)
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } else { 758 } else {
758 NOTREACHED() << "state undefined"; 759 NOTREACHED() << "state undefined";
759 } 760 }
760 761
761 return file_value; 762 return file_value;
762 } 763 }
763 764
764 string16 GetProgressStatusText(DownloadItem* download) { 765 string16 GetProgressStatusText(DownloadItem* download) {
765 int64 total = download->total_bytes(); 766 int64 total = download->total_bytes();
766 int64 size = download->received_bytes(); 767 int64 size = download->received_bytes();
767 DataUnits amount_units = GetByteDisplayUnits(size); 768 string16 received_size = ui::FormatBytes(size, ui::DATA_UNITS_NATURAL, true);
768 string16 received_size = FormatBytes(size, amount_units, true);
769 string16 amount = received_size; 769 string16 amount = received_size;
770 770
771 // Adjust both strings for the locale direction since we don't yet know which 771 // Adjust both strings for the locale direction since we don't yet know which
772 // string we'll end up using for constructing the final progress string. 772 // string we'll end up using for constructing the final progress string.
773 base::i18n::AdjustStringForLocaleDirection(&amount); 773 base::i18n::AdjustStringForLocaleDirection(&amount);
774 774
775 if (total) { 775 if (total) {
776 amount_units = GetByteDisplayUnits(total); 776 string16 total_text = ui::FormatBytes(total, ui::DATA_UNITS_NATURAL, true);
777 string16 total_text = FormatBytes(total, amount_units, true);
778 base::i18n::AdjustStringForLocaleDirection(&total_text); 777 base::i18n::AdjustStringForLocaleDirection(&total_text);
779 778
780 base::i18n::AdjustStringForLocaleDirection(&received_size); 779 base::i18n::AdjustStringForLocaleDirection(&received_size);
781 amount = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, 780 amount = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_TAB_PROGRESS_SIZE,
782 received_size, 781 received_size,
783 total_text); 782 total_text);
784 } else { 783 } else {
785 amount.assign(received_size); 784 amount.assign(received_size);
786 } 785 }
787 int64 current_speed = download->CurrentSpeed(); 786 int64 current_speed = download->CurrentSpeed();
788 amount_units = GetByteDisplayUnits(current_speed); 787 string16 speed_text = ui::FormatSpeed(current_speed,
789 string16 speed_text = FormatSpeed(current_speed, amount_units, true); 788 ui::DATA_UNITS_NATURAL,
789 true);
790 base::i18n::AdjustStringForLocaleDirection(&speed_text); 790 base::i18n::AdjustStringForLocaleDirection(&speed_text);
791 791
792 base::TimeDelta remaining; 792 base::TimeDelta remaining;
793 string16 time_remaining; 793 string16 time_remaining;
794 if (download->is_paused()) 794 if (download->is_paused())
795 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); 795 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED);
796 else if (download->TimeRemaining(&remaining)) 796 else if (download->TimeRemaining(&remaining))
797 time_remaining = TimeFormat::TimeRemaining(remaining); 797 time_remaining = TimeFormat::TimeRemaining(remaining);
798 798
799 if (time_remaining.empty()) { 799 if (time_remaining.empty()) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 FilePath GetCrDownloadPath(const FilePath& suggested_path) { 949 FilePath GetCrDownloadPath(const FilePath& suggested_path) {
950 FilePath::StringType file_name; 950 FilePath::StringType file_name;
951 base::SStringPrintf( 951 base::SStringPrintf(
952 &file_name, 952 &file_name,
953 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"), 953 PRFilePathLiteral FILE_PATH_LITERAL(".crdownload"),
954 suggested_path.value().c_str()); 954 suggested_path.value().c_str());
955 return FilePath(file_name); 955 return FilePath(file_name);
956 } 956 }
957 957
958 } // namespace download_util 958 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698