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

Side by Side Diff: ash/common/system/chromeos/power/power_status_view.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 | « ash/common/system/chromeos/power/battery_notification.cc ('k') | base/i18n/time_formatting.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/power_status_view.h" 5 #include "ash/common/system/chromeos/power/power_status_view.h"
6 6
7 #include "ash/common/material_design/material_design_controller.h" 7 #include "ash/common/material_design/material_design_controller.h"
8 #include "ash/common/system/chromeos/power/power_status.h" 8 #include "ash/common/system/chromeos/power/power_status.h"
9 #include "ash/common/system/chromeos/power/tray_power.h" 9 #include "ash/common/system/chromeos/power/tray_power.h"
10 #include "ash/common/system/tray/fixed_sized_image_view.h" 10 #include "ash/common/system/tray/fixed_sized_image_view.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE); 117 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
118 } else if (status.IsBatteryTimeBeingCalculated()) { 118 } else if (status.IsBatteryTimeBeingCalculated()) {
119 battery_time_status = 119 battery_time_status =
120 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); 120 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
121 } else { 121 } else {
122 base::TimeDelta time = status.IsBatteryCharging() 122 base::TimeDelta time = status.IsBatteryCharging()
123 ? status.GetBatteryTimeToFull() 123 ? status.GetBatteryTimeToFull()
124 : status.GetBatteryTimeToEmpty(); 124 : status.GetBatteryTimeToEmpty();
125 if (PowerStatus::ShouldDisplayBatteryTime(time) && 125 if (PowerStatus::ShouldDisplayBatteryTime(time) &&
126 !status.IsBatteryDischargingOnLinePower()) { 126 !status.IsBatteryDischargingOnLinePower()) {
127 base::string16 duration;
128 if (!base::TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC,
129 &duration))
130 LOG(ERROR) << "Failed to format duration " << time.ToInternalValue();
127 battery_time_status = l10n_util::GetStringFUTF16( 131 battery_time_status = l10n_util::GetStringFUTF16(
128 status.IsBatteryCharging() 132 status.IsBatteryCharging()
129 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT 133 ? IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_SHORT
130 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT, 134 : IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_SHORT,
131 TimeDurationFormat(time, base::DURATION_WIDTH_NUMERIC)); 135 duration);
132 } 136 }
133 } 137 }
134 } 138 }
135 percentage_label_->SetVisible(!battery_percentage.empty()); 139 percentage_label_->SetVisible(!battery_percentage.empty());
136 percentage_label_->SetText(battery_percentage); 140 percentage_label_->SetText(battery_percentage);
137 separator_label_->SetVisible(!battery_percentage.empty() && 141 separator_label_->SetVisible(!battery_percentage.empty() &&
138 !battery_time_status.empty()); 142 !battery_time_status.empty());
139 time_status_label_->SetVisible(!battery_time_status.empty()); 143 time_status_label_->SetVisible(!battery_time_status.empty());
140 time_status_label_->SetText(battery_time_status); 144 time_status_label_->SetText(battery_time_status);
141 145
(...skipping 25 matching lines...) Expand all
167 171
168 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) { 172 void PowerStatusView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
169 if (!MaterialDesignController::IsSystemTrayMenuMaterial()) 173 if (!MaterialDesignController::IsSystemTrayMenuMaterial())
170 return; 174 return;
171 175
172 node_data->role = ui::AX_ROLE_LABEL_TEXT; 176 node_data->role = ui::AX_ROLE_LABEL_TEXT;
173 node_data->SetName(accessible_name_); 177 node_data->SetName(accessible_name_);
174 } 178 }
175 179
176 } // namespace ash 180 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/chromeos/power/battery_notification.cc ('k') | base/i18n/time_formatting.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698