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..1281c112fbe7f0a2df0110cf2653ebe1a679bdb6 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), |
+ is_line_power_connected_(false) { |
PowerStatus::Get()->AddObserver(this); |
} |
@@ -162,6 +166,13 @@ void TrayPower::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { |
} |
void TrayPower::OnPowerStatusChanged() { |
+ RecordExternalPowerSupply(); |
+ |
+ if (PowerStatus::Get()->IsOriginalSpringChargerConnected()) { |
Daniel Erat
2013/12/10 00:08:58
shouldn't this also check !HasUserConfirmedSafeSpr
jennyz
2013/12/10 19:14:11
The logic for checking if the dialog should be sho
|
+ ash::Shell::GetInstance()->system_tray_delegate()-> |
+ ShowSpringChargerReplacementDialog(); |
Daniel Erat
2013/12/10 00:08:58
should the dialog be hidden when the charger is un
jennyz
2013/12/10 19:14:11
Once the dialog is shown, user has to complete the
|
+ } |
+ |
bool battery_alert = UpdateNotificationState(); |
if (power_tray_) |
power_tray_->UpdateStatus(battery_alert); |
@@ -301,5 +312,36 @@ bool TrayPower::UpdateNotificationStateForRemainingPercentage() { |
return false; |
} |
+void TrayPower::RecordExternalPowerSupply() { |
+ if (!PowerStatus::Get()->IsLinePowerConnected()) { |
+ is_line_power_connected_ = false; |
+ return; |
+ } |
+ |
+ if (is_line_power_connected_) |
+ return; |
+ |
+ is_line_power_connected_ = true; |
+ ExternalPowerSupply current_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 : ORIGINAL_SPRING_CHARGER; |
+ } else { |
+ current_charger = UNKNOWN_CHARGER; |
Daniel Erat
2013/12/10 00:08:58
nit: if you just initialize current_charger to UNK
jennyz
2013/12/10 19:14:11
Done.
|
+ } |
+ |
+ if (current_charger != UNKNOWN_CHARGER) { |
+ UMA_HISTOGRAM_ENUMERATION("PowerSupply.ExternalPowerSupply", |
Daniel Erat
2013/12/10 00:08:58
where did this name come from? all of the histogra
jennyz
2013/12/10 19:14:11
Done.
|
+ current_charger, |
+ NUM_EXTERNAL_POWER_SUPPLY); |
+ } |
+} |
+ |
} // namespace internal |
} // namespace ash |