Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1085)

Unified Diff: ash/system/chromeos/power/tray_power.cc

Issue 102373006: Merge 240486 "Implement the spring charger replacement UI and ad..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1650/src/
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/power/tray_power.h ('k') | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/chromeos/power/tray_power.cc
===================================================================
--- ash/system/chromeos/power/tray_power.cc (revision 240507)
+++ ash/system/chromeos/power/tray_power.cc (working copy)
@@ -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"
@@ -118,7 +121,8 @@
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);
}
@@ -172,6 +176,13 @@
}
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);
@@ -192,6 +203,7 @@
HideNotificationView();
usb_charger_was_connected_ = PowerStatus::Get()->IsUsbChargerConnected();
+ line_power_was_connected_ = PowerStatus::Get()->IsLinePowerConnected();
}
bool TrayPower::MaybeShowUsbChargerNotification() {
@@ -304,5 +316,29 @@
return false;
}
+void TrayPower::RecordChargerType() {
+ if (!PowerStatus::Get()->IsLinePowerConnected() ||
+ line_power_was_connected_)
+ return;
+
+ 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
« no previous file with comments | « ash/system/chromeos/power/tray_power.h ('k') | ash/system/tray/default_system_tray_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698