| 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/chromeos/power/tray_power.h" | 5 #include "ash/system/chromeos/power/tray_power.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_delegate.h" | 9 #include "ash/shell_delegate.h" |
| 10 #include "ash/system/chromeos/power/power_status_view.h" | 10 #include "ash/system/chromeos/power/power_status_view.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 TrayPower::~TrayPower() { | 212 TrayPower::~TrayPower() { |
| 213 if (PowerManagerHandler::IsInitialized()) | 213 if (PowerManagerHandler::IsInitialized()) |
| 214 PowerManagerHandler::Get()->RemoveObserver(this); | 214 PowerManagerHandler::Get()->RemoveObserver(this); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // static | 217 // static |
| 218 bool TrayPower::IsBatteryChargingUnreliable( | 218 bool TrayPower::IsBatteryChargingUnreliable( |
| 219 const chromeos::PowerSupplyStatus& supply_status) { | 219 const chromeos::PowerSupplyStatus& supply_status) { |
| 220 // Sometimes devices can get into a state where the battery is almost fully | 220 return |
| 221 // charged and the power subsystem reports "neither charging nor discharging" | 221 supply_status.battery_state == |
| 222 // despite the battery not at 100%. For now, only report unreliable charging | 222 PowerSupplyStatus::NEITHER_CHARGING_NOR_DISCHARGING || |
| 223 // on USB. | 223 supply_status.battery_state == |
| 224 // TODO(derat): Update this when the power manager code is refactored for M29. | 224 PowerSupplyStatus::CONNECTED_TO_USB; |
| 225 return supply_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB; | |
| 226 } | 225 } |
| 227 | 226 |
| 228 // static | 227 // static |
| 229 int TrayPower::GetBatteryImageIndex( | 228 int TrayPower::GetBatteryImageIndex( |
| 230 const chromeos::PowerSupplyStatus& supply_status) { | 229 const chromeos::PowerSupplyStatus& supply_status) { |
| 231 int image_index = 0; | 230 int image_index = 0; |
| 232 if (supply_status.battery_percentage >= 100) { | 231 if (supply_status.battery_percentage >= 100) { |
| 233 image_index = kNumPowerImages - 1; | 232 image_index = kNumPowerImages - 1; |
| 234 } else if (!supply_status.battery_is_present) { | 233 } else if (!supply_status.battery_is_present) { |
| 235 image_index = kNumPowerImages; | 234 image_index = kNumPowerImages; |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 return false; | 477 return false; |
| 479 case NOTIFICATION_CRITICAL: | 478 case NOTIFICATION_CRITICAL: |
| 480 return false; | 479 return false; |
| 481 } | 480 } |
| 482 NOTREACHED(); | 481 NOTREACHED(); |
| 483 return false; | 482 return false; |
| 484 } | 483 } |
| 485 | 484 |
| 486 } // namespace internal | 485 } // namespace internal |
| 487 } // namespace ash | 486 } // namespace ash |
| OLD | NEW |