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

Unified Diff: chrome/browser/dom_ui/downloads_ui.cc

Issue 42550: Add a progress meter to the downloads page.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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/app/theme/download_progress_foreground32.png ('k') | chrome/browser/resources/downloads.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_ui/downloads_ui.cc
===================================================================
--- chrome/browser/dom_ui/downloads_ui.cc (revision 12332)
+++ chrome/browser/dom_ui/downloads_ui.cc (working copy)
@@ -178,6 +178,9 @@
// Return the download that is referred to in a given value.
DownloadItem* GetDownloadByValue(const Value* value);
+ // Get the localized status text for an in-progress download.
+ std::wstring GetProgressStatusText(DownloadItem* download);
+
// Current search text.
std::wstring search_text_;
@@ -389,8 +392,10 @@
} else {
file_value->SetString(L"state", L"IN_PROGRESS");
}
- file_value->SetInteger(L"speed",
- static_cast<int>(download->CurrentSpeed()));
+
+ file_value->SetString(L"progress_status_text",
+ GetProgressStatusText(download));
+
file_value->SetInteger(L"percent",
static_cast<int>(download->PercentComplete()));
file_value->SetInteger(L"received",
@@ -439,6 +444,45 @@
return NULL;
}
+std::wstring DownloadsDOMHandler::GetProgressStatusText(DownloadItem* download) {
+ int64 total = download->total_bytes();
+ int64 size = download->received_bytes();
+ DataUnits amount_units = GetByteDisplayUnits(size);
+ std::wstring received_size = FormatBytes(size, amount_units, true);
+ std::wstring amount = received_size;
+
+ // Adjust both strings for the locale direction since we don't yet know which
+ // string we'll end up using for constructing the final progress string.
+ std::wstring amount_localized;
+ if (l10n_util::AdjustStringForLocaleDirection(amount, &amount_localized)) {
+ amount.assign(amount_localized);
+ received_size.assign(amount_localized);
+ }
+
+ amount_units = GetByteDisplayUnits(total);
+ std::wstring total_text = FormatBytes(total, amount_units, true);
+ std::wstring total_text_localized;
+ if (l10n_util::AdjustStringForLocaleDirection(total_text,
+ &total_text_localized))
Ben Goodger (Google) 2009/03/24 05:14:29 can you indent this to the next (?
+ total_text.assign(total_text_localized);
+
+ amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE,
+ received_size,
+ total_text);
+
+ amount_units = GetByteDisplayUnits(download->CurrentSpeed());
+ std::wstring speed_text = FormatSpeed(download->CurrentSpeed(),
+ amount_units, true);
Ben Goodger (Google) 2009/03/24 05:14:29 4 space indent
+ std::wstring speed_text_localized;
+ if (l10n_util::AdjustStringForLocaleDirection(speed_text,
+ &speed_text_localized))
Ben Goodger (Google) 2009/03/24 05:14:29 indent to next (
+ speed_text.assign(speed_text_localized);
+
+ return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SPEED,
+ speed_text,
+ amount);
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « chrome/app/theme/download_progress_foreground32.png ('k') | chrome/browser/resources/downloads.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698