diff options
Diffstat (limited to 'chrome/browser/download')
-rw-r--r-- | chrome/browser/download/download_item_model.cc | 32 | ||||
-rw-r--r-- | chrome/browser/download/download_util.cc | 52 |
2 files changed, 44 insertions, 40 deletions
diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index 457a34a..8b58751 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "base/i18n/number_formatting.h" #include "base/i18n/rtl.h" +#include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/browser/download/download_item.h" #include "chrome/browser/download/save_package.h" @@ -31,7 +32,8 @@ std::wstring DownloadItemModel::GetStatusText() { int64 total = download_->total_bytes(); DataUnits amount_units = GetByteDisplayUnits(total); - const std::wstring simple_size = FormatBytes(size, amount_units, false); + const string16 simple_size = WideToUTF16Hack(FormatBytes(size, amount_units, + false)); // In RTL locales, we render the text "size/total" in an RTL context. This // is problematic since a string such as "123/456 MB" is displayed @@ -42,38 +44,38 @@ std::wstring DownloadItemModel::GetStatusText() { base::i18n::GetDisplayStringInLTRDirectionality(&simple_total); TimeDelta remaining; - std::wstring simple_time; + string16 simple_time; if (download_->state() == DownloadItem::IN_PROGRESS && download_->is_paused()) { - simple_time = l10n_util::GetString(IDS_DOWNLOAD_PROGRESS_PAUSED); + simple_time = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); } else if (download_->TimeRemaining(&remaining)) { simple_time = download_->open_when_complete() ? TimeFormat::TimeRemainingShort(remaining) : TimeFormat::TimeRemaining(remaining); } - std::wstring status_text; + string16 status_text; switch (download_->state()) { case DownloadItem::IN_PROGRESS: if (download_->open_when_complete()) { if (simple_time.empty()) { status_text = - l10n_util::GetString(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); + l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_OPEN_WHEN_COMPLETE); } else { - status_text = l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_OPEN_IN, - simple_time); + status_text = l10n_util::GetStringFUTF16(IDS_DOWNLOAD_STATUS_OPEN_IN, + simple_time); } } else { if (simple_time.empty()) { // Instead of displaying "0 B" we keep the "Starting..." string. status_text = (size == 0) ? - l10n_util::GetString(IDS_DOWNLOAD_STATUS_STARTING) : - FormatBytes(size, GetByteDisplayUnits(size), true); + l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_STARTING) : + WideToUTF16Hack(FormatBytes(size, GetByteDisplayUnits(size), + true)); } else { - status_text = l10n_util::GetStringF(IDS_DOWNLOAD_STATUS_IN_PROGRESS, - simple_size, - simple_total, - simple_time); + status_text = l10n_util::GetStringFUTF16( + IDS_DOWNLOAD_STATUS_IN_PROGRESS, simple_size, + WideToUTF16Hack(simple_total), simple_time); } } break; @@ -81,7 +83,7 @@ std::wstring DownloadItemModel::GetStatusText() { status_text.clear(); break; case DownloadItem::CANCELLED: - status_text = l10n_util::GetString(IDS_DOWNLOAD_STATUS_CANCELED); + status_text = l10n_util::GetStringUTF16(IDS_DOWNLOAD_STATUS_CANCELED); break; case DownloadItem::REMOVING: break; @@ -89,7 +91,7 @@ std::wstring DownloadItemModel::GetStatusText() { NOTREACHED(); } - return status_text; + return UTF16ToWideHack(status_text); } // ----------------------------------------------------------------------------- diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index b62d8e0..d6f8907 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -18,6 +18,7 @@ #include "base/i18n/time_formatting.h" #include "base/path_service.h" #include "base/singleton.h" +#include "base/string16.h" #include "base/string_number_conversions.h" #include "base/sys_string_conversions.h" #include "base/utf_string_conversions.h" @@ -537,48 +538,49 @@ void DragDownload(const DownloadItem* download, DictionaryValue* CreateDownloadItemValue(DownloadItem* download, int id) { DictionaryValue* file_value = new DictionaryValue(); - file_value->SetInteger(L"started", - static_cast<int>(download->start_time().ToTimeT())); - file_value->SetString(L"since_string", - TimeFormat::RelativeDate(download->start_time(), NULL)); - file_value->SetString(L"date_string", - base::TimeFormatShortDate(download->start_time())); - file_value->SetInteger(L"id", id); - file_value->SetString(L"file_path", download->full_path().ToWStringHack()); + file_value->SetInteger("started", + static_cast<int>(download->start_time().ToTimeT())); + file_value->SetString("since_string", + TimeFormat::RelativeDate(download->start_time(), NULL)); + file_value->SetString("date_string", + WideToUTF16Hack(base::TimeFormatShortDate(download->start_time()))); + file_value->SetInteger("id", id); + file_value->SetString("file_path", + WideToUTF16Hack(download->full_path().ToWStringHack())); // Keep file names as LTR. std::wstring file_name = download->GetFileName().ToWStringHack(); base::i18n::GetDisplayStringInLTRDirectionality(&file_name); - file_value->SetString(L"file_name", file_name); - file_value->SetString(L"url", download->url().spec()); - file_value->SetBoolean(L"otr", download->is_otr()); + file_value->SetString("file_name", WideToUTF16Hack(file_name)); + file_value->SetString("url", download->url().spec()); + file_value->SetBoolean("otr", download->is_otr()); if (download->state() == DownloadItem::IN_PROGRESS) { if (download->safety_state() == DownloadItem::DANGEROUS) { - file_value->SetString(L"state", L"DANGEROUS"); + file_value->SetString("state", "DANGEROUS"); } else if (download->is_paused()) { - file_value->SetString(L"state", L"PAUSED"); + file_value->SetString("state", "PAUSED"); } else { - file_value->SetString(L"state", L"IN_PROGRESS"); + file_value->SetString("state", "IN_PROGRESS"); } - file_value->SetString(L"progress_status_text", - GetProgressStatusText(download)); + file_value->SetString("progress_status_text", + WideToUTF16Hack(GetProgressStatusText(download))); - file_value->SetInteger(L"percent", + file_value->SetInteger("percent", static_cast<int>(download->PercentComplete())); - file_value->SetInteger(L"received", + file_value->SetInteger("received", static_cast<int>(download->received_bytes())); } else if (download->state() == DownloadItem::CANCELLED) { - file_value->SetString(L"state", L"CANCELLED"); + file_value->SetString("state", "CANCELLED"); } else if (download->state() == DownloadItem::COMPLETE) { if (download->safety_state() == DownloadItem::DANGEROUS) { - file_value->SetString(L"state", L"DANGEROUS"); + file_value->SetString("state", "DANGEROUS"); } else { - file_value->SetString(L"state", L"COMPLETE"); + file_value->SetString("state", "COMPLETE"); } } - file_value->SetInteger(L"total", + file_value->SetInteger("total", static_cast<int>(download->total_bytes())); return file_value; @@ -622,9 +624,9 @@ std::wstring GetProgressStatusText(DownloadItem* download) { speed_text.assign(speed_text_localized); base::TimeDelta remaining; - std::wstring time_remaining; + string16 time_remaining; if (download->is_paused()) - time_remaining = l10n_util::GetString(IDS_DOWNLOAD_PROGRESS_PAUSED); + time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); else if (download->TimeRemaining(&remaining)) time_remaining = TimeFormat::TimeRemaining(remaining); @@ -633,7 +635,7 @@ std::wstring GetProgressStatusText(DownloadItem* download) { speed_text, amount); } return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, - amount, time_remaining); + amount, UTF16ToWideHack(time_remaining)); } #if !defined(OS_MACOSX) |