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

Side by Side Diff: ash/common/system/chromeos/power/battery_notification.cc

Issue 2734883003: base: Make TimeDurationFormat* report failures. (Closed)
Patch Set: log locale Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | ash/common/system/chromeos/power/power_status_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "ash/common/system/chromeos/power/battery_notification.h" 5 #include "ash/common/system/chromeos/power/battery_notification.h"
6 6
7 #include "ash/common/system/chromeos/power/power_status.h" 7 #include "ash/common/system/chromeos/power/power_status.h"
8 #include "ash/common/system/system_notifier.h" 8 #include "ash/common/system/system_notifier.h"
9 #include "ash/resources/grit/ash_resources.h" 9 #include "ash/resources/grit/ash_resources.h"
10 #include "ash/strings/grit/ash_strings.h" 10 #include "ash/strings/grit/ash_strings.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 const base::TimeDelta time = status.IsBatteryCharging() 55 const base::TimeDelta time = status.IsBatteryCharging()
56 ? status.GetBatteryTimeToFull() 56 ? status.GetBatteryTimeToFull()
57 : status.GetBatteryTimeToEmpty(); 57 : status.GetBatteryTimeToEmpty();
58 base::string16 time_message; 58 base::string16 time_message;
59 if (status.IsUsbChargerConnected()) { 59 if (status.IsUsbChargerConnected()) {
60 time_message = l10n_util::GetStringUTF16( 60 time_message = l10n_util::GetStringUTF16(
61 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); 61 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
62 } else if (PowerStatus::ShouldDisplayBatteryTime(time) && 62 } else if (PowerStatus::ShouldDisplayBatteryTime(time) &&
63 !status.IsBatteryDischargingOnLinePower()) { 63 !status.IsBatteryDischargingOnLinePower()) {
64 if (status.IsBatteryCharging()) { 64 if (status.IsBatteryCharging()) {
65 base::string16 duration;
66 if (!TimeDurationFormat(time, base::DURATION_WIDTH_NARROW, &duration))
67 LOG(ERROR) << "Failed to format duration " << time.ToInternalValue();
65 time_message = l10n_util::GetStringFUTF16( 68 time_message = l10n_util::GetStringFUTF16(
66 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, 69 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, duration);
67 TimeDurationFormat(time, base::DURATION_WIDTH_NARROW));
68 } else { 70 } else {
69 // This is a low battery warning prompting the user in minutes. 71 // This is a low battery warning prompting the user in minutes.
70 time_message = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING, 72 time_message = ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_REMAINING,
71 ui::TimeFormat::LENGTH_LONG, time); 73 ui::TimeFormat::LENGTH_LONG, time);
72 } 74 }
73 } 75 }
74 76
75 if (!time_message.empty()) 77 if (!time_message.empty())
76 message = message + base::ASCIIToUTF16("\n") + time_message; 78 message = message + base::ASCIIToUTF16("\n") + time_message;
77 79
(...skipping 24 matching lines...) Expand all
102 104
103 void BatteryNotification::Update( 105 void BatteryNotification::Update(
104 TrayPower::NotificationState notification_state) { 106 TrayPower::NotificationState notification_state) {
105 if (message_center_->FindVisibleNotificationById(kBatteryNotificationId)) { 107 if (message_center_->FindVisibleNotificationById(kBatteryNotificationId)) {
106 message_center_->UpdateNotification(kBatteryNotificationId, 108 message_center_->UpdateNotification(kBatteryNotificationId,
107 CreateNotification(notification_state)); 109 CreateNotification(notification_state));
108 } 110 }
109 } 111 }
110 112
111 } // namespace ash 113 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/chromeos/power/power_status_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698