Index: ash/system/chromeos/power/power_status_view.cc |
diff --git a/ash/system/chromeos/power/power_status_view.cc b/ash/system/chromeos/power/power_status_view.cc |
index 56881a9eba70fc1ef76cec2ebc25a9c0d7a56002..77dc61e73d059ae75ff9cfe13f99d72a950512a1 100644 |
--- a/ash/system/chromeos/power/power_status_view.cc |
+++ b/ash/system/chromeos/power/power_status_view.cc |
@@ -10,7 +10,8 @@ |
#include "ash/system/chromeos/power/tray_power.h" |
#include "ash/system/tray/fixed_sized_image_view.h" |
#include "ash/system/tray/tray_constants.h" |
-#include "base/strings/string_number_conversions.h" |
+#include "base/i18n/message_formatter.h" |
+#include "base/i18n/time_formatting.h" |
#include "base/strings/utf_string_conversions.h" |
#include "grit/ash_strings.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -90,9 +91,9 @@ void PowerStatusView::UpdateText() { |
battery_time_status = |
rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL); |
} else { |
- battery_percentage = l10n_util::GetStringFUTF16( |
- IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ONLY, |
- base::IntToString16(status.GetRoundedBatteryPercent())); |
+ battery_percentage = base::i18n::MessageFormatter::FormatWithNumberedArgs( |
+ base::ASCIIToUTF16("{0,number,percent}"), |
+ static_cast<double>(status.GetRoundedBatteryPercent()) / 100.0); |
if (status.IsUsbChargerConnected()) { |
battery_time_status = rb.GetLocalizedString( |
IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); |
@@ -104,18 +105,11 @@ void PowerStatusView::UpdateText() { |
status.GetBatteryTimeToFull() : status.GetBatteryTimeToEmpty(); |
if (PowerStatus::ShouldDisplayBatteryTime(time) && |
!status.IsBatteryDischargingOnLinePower()) { |
- int hour = 0, min = 0; |
- PowerStatus::SplitTimeIntoHoursAndMinutes(time, &hour, &min); |
- base::string16 minute = min < 10 ? |
- base::ASCIIToUTF16("0") + base::IntToString16(min) : |
- base::IntToString16(min); |
- battery_time_status = |
- l10n_util::GetStringFUTF16( |
- status.IsBatteryCharging() ? |
- IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT : |
- IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, |
- base::IntToString16(hour), |
- minute); |
+ battery_time_status = l10n_util::GetStringFUTF16( |
+ status.IsBatteryCharging() |
+ ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT |
+ : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, |
+ TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC)); |
} |
} |
battery_percentage = battery_time_status.empty() ? |