Chromium Code Reviews| Index: ash/system/chromeos/power/tray_power.cc |
| diff --git a/ash/system/chromeos/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc |
| index 1fdd6a95edcdb03717e7f55ffd2d747c601c6a6f..ac49440595e703595bbd4501dee7777f1bdce817 100644 |
| --- a/ash/system/chromeos/power/tray_power.cc |
| +++ b/ash/system/chromeos/power/tray_power.cc |
| @@ -5,13 +5,16 @@ |
| #include "ash/system/chromeos/power/tray_power.h" |
| #include "ash/ash_switches.h" |
| +#include "ash/shell.h" |
| #include "ash/system/chromeos/power/power_status_view.h" |
| #include "ash/system/date/date_view.h" |
| #include "ash/system/system_notifier.h" |
| +#include "ash/system/tray/system_tray_delegate.h" |
| #include "ash/system/tray/tray_constants.h" |
| #include "ash/system/tray/tray_notification_view.h" |
| #include "ash/system/tray/tray_utils.h" |
| #include "base/command_line.h" |
| +#include "base/metrics/histogram.h" |
| #include "grit/ash_resources.h" |
| #include "grit/ash_strings.h" |
| #include "third_party/icu/source/i18n/unicode/fieldpos.h" |
| @@ -108,7 +111,8 @@ TrayPower::TrayPower(SystemTray* system_tray, MessageCenter* message_center) |
| power_tray_(NULL), |
| notification_view_(NULL), |
| notification_state_(NOTIFICATION_NONE), |
| - usb_charger_was_connected_(false) { |
| + usb_charger_was_connected_(false), |
| + line_power_was_connected_(false) { |
| PowerStatus::Get()->AddObserver(this); |
| } |
| @@ -162,6 +166,13 @@ void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
| } |
| void TrayPower::OnPowerStatusChanged() { |
| + RecordChargerType(); |
| + |
| + if (PowerStatus::Get()->IsOriginalSpringChargerConnected()) { |
| + ash::Shell::GetInstance()->system_tray_delegate()-> |
| + ShowSpringChargerReplacementDialog(); |
| + } |
| + |
| bool battery_alert = UpdateNotificationState(); |
| if (power_tray_) |
| power_tray_->UpdateStatus(battery_alert); |
| @@ -301,5 +312,34 @@ bool TrayPower::UpdateNotificationStateForRemainingPercentage() { |
| return false; |
| } |
| +void TrayPower::RecordChargerType() { |
| + if (!PowerStatus::Get()->IsLinePowerConnected()) { |
| + line_power_was_connected_ = false; |
| + return; |
| + } |
|
Daniel Erat
2013/12/10 19:21:54
you can remove this if you follow the below sugges
jennyz
2013/12/10 19:50:14
Done.
|
| + |
| + if (line_power_was_connected_) |
|
Daniel Erat
2013/12/10 19:21:54
you can change this to:
if (!PowerStatus::Get()
jennyz
2013/12/10 19:50:14
Done.
|
| + return; |
| + |
| + line_power_was_connected_ = true; |
|
Daniel Erat
2013/12/10 19:21:54
move this line to the end of OnPowerStatusChanged(
jennyz
2013/12/10 19:50:14
Done.
|
| + ChargerType current_charger = UNKNOWN_CHARGER; |
| + if (PowerStatus::Get()->IsMainsChargerConnected()) { |
| + current_charger = MAINS_CHARGER; |
| + } else if (PowerStatus::Get()->IsUsbChargerConnected()) { |
| + current_charger = USB_CHARGER; |
| + } else if (PowerStatus::Get()->IsOriginalSpringChargerConnected()) { |
| + current_charger = |
| + ash::Shell::GetInstance()->system_tray_delegate()-> |
| + HasUserConfirmedSafeSpringCharger() ? |
| + SAFE_SPRING_CHARGER : UNCONFIRMED_SPRING_CHARGER; |
| + } |
| + |
| + if (current_charger != UNKNOWN_CHARGER) { |
| + UMA_HISTOGRAM_ENUMERATION("Power.ChargerType", |
| + current_charger, |
| + CHARGER_TYPE_COUNT); |
| + } |
| +} |
| + |
| } // namespace internal |
| } // namespace ash |