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

Unified Diff: chrome/browser/chromeos/status/power_menu_button.cc

Issue 8536048: Make power button in status view invisible until we are sure battery is supported on device. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: a Created 9 years, 1 month 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 | « no previous file | chrome/browser/chromeos/status/power_menu_button_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/status/power_menu_button.cc
diff --git a/chrome/browser/chromeos/status/power_menu_button.cc b/chrome/browser/chromeos/status/power_menu_button.cc
index 4783238cd2dd022d577ce2b5a61e9aa14a191e1b..bab18b4098ccc688e8d9151d669ba7229f0fd31c 100644
--- a/chrome/browser/chromeos/status/power_menu_button.cc
+++ b/chrome/browser/chromeos/status/power_menu_button.cc
@@ -116,10 +116,6 @@ SkBitmap GetImageWithPercentage(ImageSize size, ImageType type,
return GetImage(size, type, battery_index);
}
-SkBitmap GetMissingImage(ImageSize size) {
- return GetImage(size, DISCHARGING, kNumPowerImages);
-}
-
SkBitmap GetUnknownImage(ImageSize size) {
return GetImage(size, CHARGING, kNumPowerImages);
}
@@ -157,12 +153,13 @@ class BatteryIconView : public views::View {
protected:
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
SkBitmap image;
- if (!battery_is_present_) {
- image = GetMissingImage(LARGE);
- } else {
+ if (battery_is_present_) {
image = GetImageWithPercentage(LARGE,
line_power_on_ ? CHARGING : DISCHARGING,
battery_percentage_);
+ } else {
+ NOTREACHED();
+ return;
}
const int image_x = 0;
const int image_y = (height() - image.height()) / 2;
@@ -321,6 +318,13 @@ void PowerMenuButton::UpdateIconAndLabelInfo() {
battery_is_present_ = power_status_.battery_is_present;
line_power_on_ = power_status_.line_power_on;
+ bool should_be_visible = battery_is_present_;
+ if (should_be_visible != IsVisible())
+ SetVisible(should_be_visible);
+
+ if (!should_be_visible)
+ return;
+
// If fully charged, always show 100% even if internal number is a bit less.
if (power_status_.battery_is_full)
battery_percentage_ = 100.0;
@@ -334,19 +338,13 @@ void PowerMenuButton::UpdateIconAndLabelInfo() {
TimeDelta::FromSeconds(
power_status_.battery_seconds_to_empty));
- string16 tooltip_text;
- if (!battery_is_present_) {
- SetIcon(GetMissingImage(SMALL));
- tooltip_text = l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_BATTERY);
DaveMoore 2011/11/16 23:35:27 Please remove the string too
- } else {
- SetIcon(GetImageWithPercentage(
- SMALL, line_power_on_ ? CHARGING : DISCHARGING, battery_percentage_));
- const int message_id = line_power_on_ ?
- IDS_STATUSBAR_BATTERY_CHARGING_PERCENTAGE :
- IDS_STATUSBAR_BATTERY_USING_PERCENTAGE;
- tooltip_text = l10n_util::GetStringFUTF16(
- message_id, base::IntToString16(static_cast<int>(battery_percentage_)));
- }
+ SetIcon(GetImageWithPercentage(
+ SMALL, line_power_on_ ? CHARGING : DISCHARGING, battery_percentage_));
+ const int message_id = line_power_on_ ?
+ IDS_STATUSBAR_BATTERY_CHARGING_PERCENTAGE :
+ IDS_STATUSBAR_BATTERY_USING_PERCENTAGE;
+ string16 tooltip_text = l10n_util::GetStringFUTF16(
+ message_id, base::IntToString16(static_cast<int>(battery_percentage_)));
SetTooltipText(tooltip_text);
SetAccessibleName(tooltip_text);
SchedulePaint();
« no previous file with comments | « no previous file | chrome/browser/chromeos/status/power_menu_button_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698