OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromeos/power/power_status.h" | 5 #include "ash/system/chromeos/power/power_status.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; | 41 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; |
42 if ((on_line_power && proto->battery_time_to_full_sec() < 0) || | 42 if ((on_line_power && proto->battery_time_to_full_sec() < 0) || |
43 (!on_line_power && proto->battery_time_to_empty_sec() < 0)) | 43 (!on_line_power && proto->battery_time_to_empty_sec() < 0)) |
44 proto->set_is_calculating_battery_time(true); | 44 proto->set_is_calculating_battery_time(true); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 base::string16 GetBatteryTimeAccessibilityString(int hour, int min) { | 48 base::string16 GetBatteryTimeAccessibilityString(int hour, int min) { |
49 DCHECK(hour || min); | 49 DCHECK(hour || min); |
50 if (hour && !min) { | 50 if (hour && !min) { |
51 return ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromHours(hour)); | 51 return ui::TimeFormat::Simple(ui::TimeFormat::kDuration, |
| 52 ui::TimeFormat::kLong, |
| 53 base::TimeDelta::FromHours(hour)); |
52 } | 54 } |
53 if (min && !hour) { | 55 if (min && !hour) { |
54 return ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromMinutes(min)); | 56 return ui::TimeFormat::Simple(ui::TimeFormat::kDuration, |
| 57 ui::TimeFormat::kLong, |
| 58 base::TimeDelta::FromMinutes(min)); |
55 } | 59 } |
56 return l10n_util::GetStringFUTF16( | 60 return l10n_util::GetStringFUTF16( |
57 IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE, | 61 IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE, |
58 ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromHours(hour)), | 62 ui::TimeFormat::Simple(ui::TimeFormat::kDuration, |
59 ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromMinutes(min))); | 63 ui::TimeFormat::kLong, |
| 64 base::TimeDelta::FromHours(hour)), |
| 65 ui::TimeFormat::Simple(ui::TimeFormat::kDuration, |
| 66 ui::TimeFormat::kLong, |
| 67 base::TimeDelta::FromMinutes(min))); |
60 } | 68 } |
61 | 69 |
62 static PowerStatus* g_power_status = NULL; | 70 static PowerStatus* g_power_status = NULL; |
63 | 71 |
64 // Minimum battery percentage rendered in UI. | 72 // Minimum battery percentage rendered in UI. |
65 const int kMinBatteryPercent = 1; | 73 const int kMinBatteryPercent = 1; |
66 | 74 |
67 // Width and height of battery images. | 75 // Width and height of battery images. |
68 const int kBatteryImageHeight = 25; | 76 const int kBatteryImageHeight = 25; |
69 const int kBatteryImageWidth = 25; | 77 const int kBatteryImageWidth = 25; |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 | 300 |
293 void PowerStatus::PowerChanged( | 301 void PowerStatus::PowerChanged( |
294 const power_manager::PowerSupplyProperties& proto) { | 302 const power_manager::PowerSupplyProperties& proto) { |
295 proto_ = proto; | 303 proto_ = proto; |
296 SanitizeProto(&proto_); | 304 SanitizeProto(&proto_); |
297 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); | 305 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); |
298 } | 306 } |
299 | 307 |
300 } // namespace internal | 308 } // namespace internal |
301 } // namespace ash | 309 } // namespace ash |
OLD | NEW |