OLD | NEW |
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/system/power/power_status_view.h" | 5 #include "ash/system/power/power_status_view.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/power/tray_power.h" | 9 #include "ash/system/power/tray_power.h" |
10 #include "ash/system/tray/fixed_sized_image_view.h" | 10 #include "ash/system/tray/fixed_sized_image_view.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 } | 233 } |
234 } | 234 } |
235 } else { | 235 } else { |
236 time_label_->SetText(base::string16()); | 236 time_label_->SetText(base::string16()); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 int PowerStatusView::GetRoundedBatteryPercentage() const { | 240 int PowerStatusView::GetRoundedBatteryPercentage() const { |
241 DCHECK(supply_status_.battery_percentage >= 0.0f); | 241 DCHECK(supply_status_.battery_percentage >= 0.0f); |
242 return std::max(kMinBatteryPercent, | 242 return std::max(kMinBatteryPercent, |
243 static_cast<int>(supply_status_.battery_percentage)); | 243 static_cast<int>(supply_status_.battery_percentage + 0.5)); |
244 } | 244 } |
245 | 245 |
246 base::string16 PowerStatusView::GetBatteryTimeAccessibilityString( | 246 base::string16 PowerStatusView::GetBatteryTimeAccessibilityString( |
247 int hour, int min) { | 247 int hour, int min) { |
248 DCHECK(hour || min); | 248 DCHECK(hour || min); |
249 if (hour && !min) { | 249 if (hour && !min) { |
250 return Shell::GetInstance()->delegate()->GetTimeDurationLongString( | 250 return Shell::GetInstance()->delegate()->GetTimeDurationLongString( |
251 base::TimeDelta::FromHours(hour)); | 251 base::TimeDelta::FromHours(hour)); |
252 } else if (min && !hour) { | 252 } else if (min && !hour) { |
253 return Shell::GetInstance()->delegate()->GetTimeDurationLongString( | 253 return Shell::GetInstance()->delegate()->GetTimeDurationLongString( |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 | 299 |
300 // Move the time_status_label_ closer to percentage_label_. | 300 // Move the time_status_label_ closer to percentage_label_. |
301 if (percentage_label_ && time_status_label_ && | 301 if (percentage_label_ && time_status_label_ && |
302 percentage_label_->visible() && time_status_label_->visible()) { | 302 percentage_label_->visible() && time_status_label_->visible()) { |
303 time_status_label_->SetX(percentage_label_->bounds().right() + 1); | 303 time_status_label_->SetX(percentage_label_->bounds().right() + 1); |
304 } | 304 } |
305 } | 305 } |
306 | 306 |
307 } // namespace internal | 307 } // namespace internal |
308 } // namespace ash | 308 } // namespace ash |
OLD | NEW |