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

Unified Diff: ash/system/power/power_status_view.cc

Issue 10907037: Only update system power indicators on change (Closed) Base URL: https://git.chromium.org/git/chromium/src@git-svn
Patch Set: Nit fixes.:wq Created 8 years, 3 months 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
Index: ash/system/power/power_status_view.cc
diff --git a/ash/system/power/power_status_view.cc b/ash/system/power/power_status_view.cc
index 0746ed68a8bf71e6df718c6c4d72bb25e9ba9853..c63a4bc3ee7d1eb34d4c4bc03a8c764d02d977ef 100644
--- a/ash/system/power/power_status_view.cc
+++ b/ash/system/power/power_status_view.cc
@@ -39,6 +39,7 @@ PowerStatusView::PowerStatusView(ViewType view_type,
time_label_(NULL),
time_status_label_(NULL),
icon_(NULL),
+ icon_image_index_(-1),
view_type_(view_type) {
if (view_type == VIEW_DEFAULT) {
time_status_label_ = new views::Label;
@@ -179,10 +180,10 @@ void PowerStatusView::UpdateTextForNotificationView() {
} else if (hour || min) {
if (supply_status_.line_power_on) {
time_label_->SetText(
- l10n_util::GetStringFUTF16(
- IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
- base::IntToString16(hour),
- base::IntToString16(min)));
+ l10n_util::GetStringFUTF16(
+ IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
+ base::IntToString16(hour),
+ base::IntToString16(min)));
} else {
// This is a low battery warning, which prompts user when battery
// time left is not much (ie in minutes).
@@ -190,7 +191,7 @@ void PowerStatusView::UpdateTextForNotificationView() {
ShellDelegate* delegate = Shell::GetInstance()->delegate();
if (delegate) {
time_label_->SetText(delegate->GetTimeRemainingString(
- base::TimeDelta::FromMinutes(min)));
+ base::TimeDelta::FromMinutes(min)));
} else {
time_label_->SetText(string16());
}
@@ -198,13 +199,21 @@ void PowerStatusView::UpdateTextForNotificationView() {
} else {
time_label_->SetText(string16());
}
-
}
void PowerStatusView::UpdateIcon() {
if (icon_) {
- icon_->SetImage(TrayPower::GetBatteryImage(supply_status_, ICON_DARK,
- icon_->GetImage()));
+ int index = TrayPower::GetBatteryImageIndex(supply_status_);
+ if (icon_image_index_ != index) {
+ icon_image_index_ = index;
+ if (icon_image_index_ == -1) {
+ // Default in case supply_status_ is uncertain.
+ icon_->SetImage(icon_->GetImage());
Daniel Erat 2012/09/11 23:31:04 didn't see any explanation for this: it looks like
+ } else {
+ icon_->SetImage(
+ TrayPower::GetBatteryImage(icon_image_index_, ICON_DARK));
+ }
+ }
icon_->SetVisible(true);
}
}

Powered by Google App Engine
This is Rietveld 408576698