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

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

Issue 3108027: Convert GetDisplayStringInLTRDirectionality from wstring to string16. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 4 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
OLDNEW
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 #include "chrome/browser/download/download_item_model.h" 5 #include "chrome/browser/download/download_item_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/i18n/number_formatting.h" 8 #include "base/i18n/number_formatting.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 22 matching lines...) Expand all
33 33
34 DataUnits amount_units = GetByteDisplayUnits(total); 34 DataUnits amount_units = GetByteDisplayUnits(total);
35 const string16 simple_size = WideToUTF16Hack(FormatBytes(size, amount_units, 35 const string16 simple_size = WideToUTF16Hack(FormatBytes(size, amount_units,
36 false)); 36 false));
37 37
38 // In RTL locales, we render the text "size/total" in an RTL context. This 38 // In RTL locales, we render the text "size/total" in an RTL context. This
39 // is problematic since a string such as "123/456 MB" is displayed 39 // is problematic since a string such as "123/456 MB" is displayed
40 // as "MB 123/456" because it ends with an LTR run. In order to solve this, 40 // as "MB 123/456" because it ends with an LTR run. In order to solve this,
41 // we mark the total string as an LTR string if the UI layout is 41 // we mark the total string as an LTR string if the UI layout is
42 // right-to-left so that the string "456 MB" is treated as an LTR run. 42 // right-to-left so that the string "456 MB" is treated as an LTR run.
43 std::wstring simple_total = FormatBytes(total, amount_units, true); 43 string16 simple_total = WideToUTF16Hack(FormatBytes(total, amount_units,
44 base::i18n::GetDisplayStringInLTRDirectionality(&simple_total); 44 true));
45 simple_total = base::i18n::GetDisplayStringInLTRDirectionality(simple_total);
45 46
46 TimeDelta remaining; 47 TimeDelta remaining;
47 string16 simple_time; 48 string16 simple_time;
48 if (download_->state() == DownloadItem::IN_PROGRESS && 49 if (download_->state() == DownloadItem::IN_PROGRESS &&
49 download_->is_paused()) { 50 download_->is_paused()) {
50 simple_time = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); 51 simple_time = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED);
51 } else if (download_->TimeRemaining(&remaining)) { 52 } else if (download_->TimeRemaining(&remaining)) {
52 simple_time = download_->open_when_complete() ? 53 simple_time = download_->open_when_complete() ?
53 TimeFormat::TimeRemainingShort(remaining) : 54 TimeFormat::TimeRemainingShort(remaining) :
54 TimeFormat::TimeRemaining(remaining); 55 TimeFormat::TimeRemaining(remaining);
(...skipping 12 matching lines...) Expand all
67 } 68 }
68 } else { 69 } else {
69 if (simple_time.empty()) { 70 if (simple_time.empty()) {
70 // Instead of displaying "0 B" we keep the "Starting..." string. 71 // Instead of displaying "0 B" we keep the "Starting..." string.
71 status_text = (size == 0) ? 72 status_text = (size == 0) ?
72 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING) : 73 l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING) :
73 WideToUTF16Hack(FormatBytes(size, GetByteDisplayUnits(size), 74 WideToUTF16Hack(FormatBytes(size, GetByteDisplayUnits(size),
74 true)); 75 true));
75 } else { 76 } else {
76 status_text = l10n_util::GetStringFUTF16( 77 status_text = l10n_util::GetStringFUTF16(
77 IDS_DOWNLOAD_STATUS_IN_PROGRESS, simple_size, 78 IDS_DOWNLOAD_STATUS_IN_PROGRESS, simple_size, simple_total,
78 WideToUTF16Hack(simple_total), simple_time); 79 simple_time);
79 } 80 }
80 } 81 }
81 break; 82 break;
82 case DownloadItem::COMPLETE: 83 case DownloadItem::COMPLETE:
83 status_text.clear(); 84 status_text.clear();
84 break; 85 break;
85 case DownloadItem::CANCELLED: 86 case DownloadItem::CANCELLED:
86 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELED); 87 status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELED);
87 break; 88 break;
88 case DownloadItem::REMOVING: 89 case DownloadItem::REMOVING:
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 status_text = l10n_util::GetString(IDS_SAVE_PAGE_STATUS_CANCELED); 126 status_text = l10n_util::GetString(IDS_SAVE_PAGE_STATUS_CANCELED);
126 break; 127 break;
127 case DownloadItem::REMOVING: 128 case DownloadItem::REMOVING:
128 break; 129 break;
129 default: 130 default:
130 NOTREACHED(); 131 NOTREACHED();
131 } 132 }
132 133
133 return status_text; 134 return status_text;
134 } 135 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698