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

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

Issue 107103004: Implement the spring charger replacement UI. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Point iFrame to production site. 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
diff --git a/ash/system/chromeos/power/tray_power.cc b/ash/system/chromeos/power/tray_power.cc
index 1fdd6a95edcdb03717e7f55ffd2d747c601c6a6f..8bc68d5ec4e9506a16076a88bd6447baf4275d84 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);
@@ -182,6 +193,7 @@ void TrayPower::OnPowerStatusChanged() {
HideNotificationView();
usb_charger_was_connected_ = PowerStatus::Get()->IsUsbChargerConnected();
+ line_power_was_connected_ = PowerStatus::Get()->IsLinePowerConnected();
}
bool TrayPower::MaybeShowUsbChargerNotification() {
@@ -301,5 +313,29 @@ bool TrayPower::UpdateNotificationStateForRemainingPercentage() {
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