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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 bool PowerStatus::IsMainsChargerConnected() const { | 181 bool PowerStatus::IsMainsChargerConnected() const { |
182 return proto_.external_power() == | 182 return proto_.external_power() == |
183 power_manager::PowerSupplyProperties_ExternalPower_AC; | 183 power_manager::PowerSupplyProperties_ExternalPower_AC; |
184 } | 184 } |
185 | 185 |
186 bool PowerStatus::IsUsbChargerConnected() const { | 186 bool PowerStatus::IsUsbChargerConnected() const { |
187 return proto_.external_power() == | 187 return proto_.external_power() == |
188 power_manager::PowerSupplyProperties_ExternalPower_USB; | 188 power_manager::PowerSupplyProperties_ExternalPower_USB; |
189 } | 189 } |
190 | 190 |
| 191 bool PowerStatus::IsOriginalSpringChargerConnected() const { |
| 192 // Use the hard coded enum integer value for |
| 193 // PowerSupplyProperties_ExternalPower_ORIGINAL_SPRING_CHARGER |
| 194 // in purpose of backport compatibility. |
| 195 // TODO(jennyz): change this to use |
| 196 // PowerSupplyProperties_ExternalPower_ORIGINAL_SPRING_CHARGER on trunk |
| 197 // after the change has been merged. |
| 198 return proto_.external_power() == 3; |
| 199 } |
| 200 |
191 gfx::ImageSkia PowerStatus::GetBatteryImage(IconSet icon_set) const { | 201 gfx::ImageSkia PowerStatus::GetBatteryImage(IconSet icon_set) const { |
192 gfx::Image all; | 202 gfx::Image all; |
193 if (IsUsbChargerConnected()) { | 203 if (IsUsbChargerConnected()) { |
194 all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 204 all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
195 icon_set == ICON_DARK ? | 205 icon_set == ICON_DARK ? |
196 IDR_AURA_UBER_TRAY_POWER_SMALL_CHARGING_UNRELIABLE_DARK : | 206 IDR_AURA_UBER_TRAY_POWER_SMALL_CHARGING_UNRELIABLE_DARK : |
197 IDR_AURA_UBER_TRAY_POWER_SMALL_CHARGING_UNRELIABLE); | 207 IDR_AURA_UBER_TRAY_POWER_SMALL_CHARGING_UNRELIABLE); |
198 } else { | 208 } else { |
199 all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 209 all = ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
200 icon_set == ICON_DARK ? | 210 icon_set == ICON_DARK ? |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 | 297 |
288 void PowerStatus::PowerChanged( | 298 void PowerStatus::PowerChanged( |
289 const power_manager::PowerSupplyProperties& proto) { | 299 const power_manager::PowerSupplyProperties& proto) { |
290 proto_ = proto; | 300 proto_ = proto; |
291 SanitizeProto(&proto_); | 301 SanitizeProto(&proto_); |
292 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); | 302 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); |
293 } | 303 } |
294 | 304 |
295 } // namespace internal | 305 } // namespace internal |
296 } // namespace ash | 306 } // namespace ash |
OLD | NEW |