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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 IDR_AURA_UBER_TRAY_POWER_SMALL_DARK : IDR_AURA_UBER_TRAY_POWER_SMALL); | 274 IDR_AURA_UBER_TRAY_POWER_SMALL_DARK : IDR_AURA_UBER_TRAY_POWER_SMALL); |
275 } | 275 } |
276 gfx::Rect region( | 276 gfx::Rect region( |
277 image_offset * kBatteryImageWidth, | 277 image_offset * kBatteryImageWidth, |
278 image_index * kBatteryImageHeight, | 278 image_index * kBatteryImageHeight, |
279 kBatteryImageWidth, kBatteryImageHeight); | 279 kBatteryImageWidth, kBatteryImageHeight); |
280 return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region); | 280 return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region); |
281 } | 281 } |
282 | 282 |
283 // static | 283 // static |
284 gfx::Image TrayPower::GetUsbChargerNotificationImage() { | |
285 // TODO(jamescook): Use a specialized art asset here. | |
286 gfx::ImageSkia icon = | |
287 GetBatteryImage(kNumPowerImages - 1, 0, true, ICON_LIGHT); | |
288 return gfx::Image(icon); | |
289 } | |
290 | |
291 // static | |
292 base::string16 TrayPower::GetAccessibleNameString( | 284 base::string16 TrayPower::GetAccessibleNameString( |
293 const chromeos::PowerSupplyStatus& supply_status) { | 285 const chromeos::PowerSupplyStatus& supply_status) { |
294 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 286 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
295 if (supply_status.line_power_on && supply_status.battery_is_full) { | 287 if (supply_status.line_power_on && supply_status.battery_is_full) { |
296 return rb.GetLocalizedString( | 288 return rb.GetLocalizedString( |
297 IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE); | 289 IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE); |
298 } | 290 } |
299 bool charging_unreliable = | 291 bool charging_unreliable = |
300 IsBatteryChargingUnreliable(supply_status); | 292 IsBatteryChargingUnreliable(supply_status); |
301 if (supply_status.battery_percentage < 0.0f) { | 293 if (supply_status.battery_percentage < 0.0f) { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 428 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
437 const char kNotificationId[] = "usb-charger"; | 429 const char kNotificationId[] = "usb-charger"; |
438 // Check for a USB charger being connected. | 430 // Check for a USB charger being connected. |
439 if (new_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB && | 431 if (new_status.battery_state == PowerSupplyStatus::CONNECTED_TO_USB && |
440 old_status.battery_state != PowerSupplyStatus::CONNECTED_TO_USB) { | 432 old_status.battery_state != PowerSupplyStatus::CONNECTED_TO_USB) { |
441 scoped_ptr<Notification> notification(new Notification( | 433 scoped_ptr<Notification> notification(new Notification( |
442 message_center::NOTIFICATION_TYPE_SIMPLE, | 434 message_center::NOTIFICATION_TYPE_SIMPLE, |
443 kNotificationId, | 435 kNotificationId, |
444 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_TITLE), | 436 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_TITLE), |
445 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_MESSAGE), | 437 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOW_POWER_CHARGER_MESSAGE), |
446 GetUsbChargerNotificationImage(), | 438 rb.GetImageNamed(IDR_AURA_NOTIFICATION_LOW_POWER_CHARGER), |
447 base::string16(), | 439 base::string16(), |
448 std::string(), | 440 std::string(), |
449 message_center::RichNotificationData(), | 441 message_center::RichNotificationData(), |
450 NULL)); | 442 NULL)); |
451 message_center_->AddNotification(notification.Pass()); | 443 message_center_->AddNotification(notification.Pass()); |
452 return true; | 444 return true; |
453 } | 445 } |
454 | 446 |
455 // Check for unplug of a USB charger while the USB charger notification is | 447 // Check for unplug of a USB charger while the USB charger notification is |
456 // showing. | 448 // showing. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 return false; | 528 return false; |
537 case NOTIFICATION_CRITICAL: | 529 case NOTIFICATION_CRITICAL: |
538 return false; | 530 return false; |
539 } | 531 } |
540 NOTREACHED(); | 532 NOTREACHED(); |
541 return false; | 533 return false; |
542 } | 534 } |
543 | 535 |
544 } // namespace internal | 536 } // namespace internal |
545 } // namespace ash | 537 } // namespace ash |
OLD | NEW |