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

Unified Diff: chrome/browser/download/download_util.cc

Issue 3165009: Convert TimeFormat (chrome/common/time_format.*) to string16 (from wstring). (Closed)
Patch Set: bar 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/download/download_util.cc
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc
index b62d8e0709601ad32256222d945c4791b9f9364e..d6f8907c8b8ff13b39ababb0584b595d5cdf23ff 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)
« no previous file with comments | « chrome/browser/download/download_item_model.cc ('k') | chrome/browser/sync/profile_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698