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

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

Issue 5154009: Cleanup AdjustStringForLocaleDirection() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: further fixes Created 10 years, 1 month 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) 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 // 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 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 std::wstring GetProgressStatusText(DownloadItem* download) { 537 std::wstring GetProgressStatusText(DownloadItem* download) {
538 int64 total = download->total_bytes(); 538 int64 total = download->total_bytes();
539 int64 size = download->received_bytes(); 539 int64 size = download->received_bytes();
540 DataUnits amount_units = GetByteDisplayUnits(size); 540 DataUnits amount_units = GetByteDisplayUnits(size);
541 std::wstring received_size = UTF16ToWideHack(FormatBytes(size, amount_units, 541 std::wstring received_size = UTF16ToWideHack(FormatBytes(size, amount_units,
542 true)); 542 true));
543 std::wstring amount = received_size; 543 std::wstring amount = received_size;
544 544
545 // Adjust both strings for the locale direction since we don't yet know which 545 // Adjust both strings for the locale direction since we don't yet know which
546 // string we'll end up using for constructing the final progress string. 546 // string we'll end up using for constructing the final progress string.
547 std::wstring amount_localized; 547 base::i18n::AdjustStringForLocaleDirection(&amount);
548 if (base::i18n::AdjustStringForLocaleDirection(amount, &amount_localized)) {
549 amount.assign(amount_localized);
550 received_size.assign(amount_localized);
551 }
552 548
553 if (total) { 549 if (total) {
554 amount_units = GetByteDisplayUnits(total); 550 amount_units = GetByteDisplayUnits(total);
555 std::wstring total_text = 551 std::wstring total_text =
556 UTF16ToWideHack(FormatBytes(total, amount_units, true)); 552 UTF16ToWideHack(FormatBytes(total, amount_units, true));
557 std::wstring total_text_localized; 553 base::i18n::AdjustStringForLocaleDirection(&total_text);
558 if (base::i18n::AdjustStringForLocaleDirection(total_text,
559 &total_text_localized))
560 total_text.assign(total_text_localized);
561 554
555 base::i18n::AdjustStringForLocaleDirection(&received_size);
562 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE, 556 amount = l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_SIZE,
563 received_size, 557 received_size,
564 total_text); 558 total_text);
565 } else { 559 } else {
566 amount.assign(received_size); 560 amount.assign(received_size);
567 } 561 }
568 int64 current_speed = download->CurrentSpeed(); 562 int64 current_speed = download->CurrentSpeed();
569 amount_units = GetByteDisplayUnits(current_speed); 563 amount_units = GetByteDisplayUnits(current_speed);
570 std::wstring speed_text = UTF16ToWideHack(FormatSpeed(current_speed, 564 std::wstring speed_text = UTF16ToWideHack(FormatSpeed(current_speed,
571 amount_units, true)); 565 amount_units, true));
572 std::wstring speed_text_localized; 566 base::i18n::AdjustStringForLocaleDirection(&speed_text);
573 if (base::i18n::AdjustStringForLocaleDirection(speed_text,
574 &speed_text_localized))
575 speed_text.assign(speed_text_localized);
576 567
577 base::TimeDelta remaining; 568 base::TimeDelta remaining;
578 string16 time_remaining; 569 string16 time_remaining;
579 if (download->is_paused()) 570 if (download->is_paused())
580 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED); 571 time_remaining = l10n_util::GetStringUTF16(IDS_DOWNLOAD_PROGRESS_PAUSED);
581 else if (download->TimeRemaining(&remaining)) 572 else if (download->TimeRemaining(&remaining))
582 time_remaining = TimeFormat::TimeRemaining(remaining); 573 time_remaining = TimeFormat::TimeRemaining(remaining);
583 574
584 if (time_remaining.empty()) { 575 if (time_remaining.empty()) {
576 base::i18n::AdjustStringForLocaleDirection(&amount);
585 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, 577 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN,
586 speed_text, amount); 578 speed_text, amount);
587 } 579 }
588 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, 580 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text,
589 amount, UTF16ToWideHack(time_remaining)); 581 amount, UTF16ToWideHack(time_remaining));
590 } 582 }
591 583
592 #if !defined(OS_MACOSX) 584 #if !defined(OS_MACOSX)
593 void UpdateAppIconDownloadProgress(int download_count, 585 void UpdateAppIconDownloadProgress(int download_count,
594 bool progress_known, 586 bool progress_known,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 ExtensionsService* service = profile->GetExtensionsService(); 733 ExtensionsService* service = profile->GetExtensionsService();
742 if (!service || 734 if (!service ||
743 !service->IsDownloadFromGallery(info->url, info->referrer_url)) { 735 !service->IsDownloadFromGallery(info->url, info->referrer_url)) {
744 return true; 736 return true;
745 } 737 }
746 } 738 }
747 return false; 739 return false;
748 } 740 }
749 741
750 } // namespace download_util 742 } // namespace download_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698