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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_ACCESSIBLE : | 270 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL_ACCESSIBLE : |
271 IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_ACCESSIBLE, | 271 IDS_ASH_STATUS_TRAY_BATTERY_TIME_LEFT_ACCESSIBLE, |
272 GetBatteryTimeAccessibilityString(hour, min)); | 272 GetBatteryTimeAccessibilityString(hour, min)); |
273 } | 273 } |
274 return battery_time_accessible.empty() ? | 274 return battery_time_accessible.empty() ? |
275 battery_percentage_accessible : | 275 battery_percentage_accessible : |
276 battery_percentage_accessible + base::ASCIIToUTF16(". ") + | 276 battery_percentage_accessible + base::ASCIIToUTF16(". ") + |
277 battery_time_accessible; | 277 battery_time_accessible; |
278 } | 278 } |
279 | 279 |
280 base::string16 PowerStatus::GetShortAccessibleNameString() const { | |
dmazzoni
2014/07/10 17:28:20
Can you call this function from GetAccessibleNameS
evy
2014/07/10 18:57:40
Done.
| |
281 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | |
282 if (IsBatteryFull()) { | |
283 return rb.GetLocalizedString( | |
284 IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE); | |
285 } | |
286 | |
287 return l10n_util::GetStringFUTF16( | |
288 IsBatteryCharging() | |
289 ? IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_CHARGING_ACCESSIBLE | |
290 : IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ACCESSIBLE, | |
291 base::IntToString16(GetRoundedBatteryPercent())); | |
292 } | |
293 | |
280 PowerStatus::PowerStatus() { | 294 PowerStatus::PowerStatus() { |
281 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 295 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
282 AddObserver(this); | 296 AddObserver(this); |
283 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 297 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
284 RequestStatusUpdate(); | 298 RequestStatusUpdate(); |
285 } | 299 } |
286 | 300 |
287 PowerStatus::~PowerStatus() { | 301 PowerStatus::~PowerStatus() { |
288 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 302 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
289 RemoveObserver(this); | 303 RemoveObserver(this); |
290 } | 304 } |
291 | 305 |
292 void PowerStatus::SetProtoForTesting( | 306 void PowerStatus::SetProtoForTesting( |
293 const power_manager::PowerSupplyProperties& proto) { | 307 const power_manager::PowerSupplyProperties& proto) { |
294 proto_ = proto; | 308 proto_ = proto; |
295 SanitizeProto(&proto_); | 309 SanitizeProto(&proto_); |
296 } | 310 } |
297 | 311 |
298 void PowerStatus::PowerChanged( | 312 void PowerStatus::PowerChanged( |
299 const power_manager::PowerSupplyProperties& proto) { | 313 const power_manager::PowerSupplyProperties& proto) { |
300 proto_ = proto; | 314 proto_ = proto; |
301 SanitizeProto(&proto_); | 315 SanitizeProto(&proto_); |
302 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); | 316 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); |
303 } | 317 } |
304 | 318 |
305 } // namespace ash | 319 } // namespace ash |
OLD | NEW |