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

Side by Side Diff: ash/system/chromeos/power/power_status_view.cc

Issue 15993020: REVERTED cros: Update charging not reliable battery status (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ash/system/chromeos/power/tray_power.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/system/chromeos/power/power_status_view.h" 5 #include "ash/system/chromeos/power/power_status_view.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/chromeos/power/tray_power.h" 9 #include "ash/system/chromeos/power/tray_power.h"
10 #include "ash/system/tray/fixed_sized_image_view.h" 10 #include "ash/system/tray/fixed_sized_image_view.h"
(...skipping 14 matching lines...) Expand all
25 namespace { 25 namespace {
26 26
27 // Top/bottom padding of the text items. 27 // Top/bottom padding of the text items.
28 const int kPaddingVertical = 10; 28 const int kPaddingVertical = 10;
29 // Specify min width of status label for layout. 29 // Specify min width of status label for layout.
30 const int kLabelMinWidth = 120; 30 const int kLabelMinWidth = 120;
31 // Padding between battery status text and battery icon on default view. 31 // Padding between battery status text and battery icon on default view.
32 const int kPaddingBetweenBatteryStatusAndIcon = 3; 32 const int kPaddingBetweenBatteryStatusAndIcon = 3;
33 // Minimum battery percentage rendered in UI. 33 // Minimum battery percentage rendered in UI.
34 const int kMinBatteryPercent = 1; 34 const int kMinBatteryPercent = 1;
35
36 base::string16 GetChargingUnreliableString() {
37 // String is intentionally hard-coded in English for backport to M28 only.
38 // See crbug.com/246336 for details.
39 return UTF8ToUTF16("Low-power charger");
40 }
41
35 } // namespace 42 } // namespace
36 43
37 PowerStatusView::PowerStatusView(ViewType view_type, 44 PowerStatusView::PowerStatusView(ViewType view_type,
38 bool default_view_right_align) 45 bool default_view_right_align)
39 : default_view_right_align_(default_view_right_align), 46 : default_view_right_align_(default_view_right_align),
40 status_label_(NULL), 47 status_label_(NULL),
41 time_label_(NULL), 48 time_label_(NULL),
42 time_status_label_(NULL), 49 time_status_label_(NULL),
43 percentage_label_(NULL), 50 percentage_label_(NULL),
44 icon_(NULL), 51 icon_(NULL),
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 124 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
118 base::string16 battery_percentage; 125 base::string16 battery_percentage;
119 base::string16 battery_time_status; 126 base::string16 battery_time_status;
120 bool is_charging_unreliable = 127 bool is_charging_unreliable =
121 TrayPower::IsBatteryChargingUnreliable(supply_status_); 128 TrayPower::IsBatteryChargingUnreliable(supply_status_);
122 if (supply_status_.line_power_on && supply_status_.battery_is_full) { 129 if (supply_status_.line_power_on && supply_status_.battery_is_full) {
123 battery_time_status = 130 battery_time_status =
124 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL); 131 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_FULL);
125 } else if (supply_status_.battery_percentage < 0.0f) { 132 } else if (supply_status_.battery_percentage < 0.0f) {
126 battery_time_status = 133 battery_time_status =
127 is_charging_unreliable ? 134 is_charging_unreliable
128 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE) : 135 ? GetChargingUnreliableString()
Daniel Erat 2013/06/04 19:23:15 this style seems strange to me -- i think that i'v
129 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); 136 : rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
130 } else { 137 } else {
131 battery_percentage = l10n_util::GetStringFUTF16( 138 battery_percentage = l10n_util::GetStringFUTF16(
132 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ONLY, 139 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ONLY,
133 base::IntToString16(TrayPower::GetRoundedBatteryPercentage( 140 base::IntToString16(TrayPower::GetRoundedBatteryPercentage(
134 supply_status_.battery_percentage))); 141 supply_status_.battery_percentage)));
135 if (is_charging_unreliable) { 142 if (is_charging_unreliable) {
136 battery_time_status = rb.GetLocalizedString( 143 battery_time_status = GetChargingUnreliableString();
137 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE);
138 } else { 144 } else {
139 if (supply_status_.is_calculating_battery_time) { 145 if (supply_status_.is_calculating_battery_time) {
140 battery_time_status = 146 battery_time_status =
141 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING); 147 rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING);
142 } else { 148 } else {
143 base::TimeDelta time = base::TimeDelta::FromSeconds( 149 base::TimeDelta time = base::TimeDelta::FromSeconds(
144 supply_status_.line_power_on ? 150 supply_status_.line_power_on ?
145 supply_status_.battery_seconds_to_full : 151 supply_status_.battery_seconds_to_full :
146 supply_status_.battery_seconds_to_empty); 152 supply_status_.battery_seconds_to_empty);
147 int hour = time.InHours(); 153 int hour = time.InHours();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } else { 206 } else {
201 status_label_->SetText( 207 status_label_->SetText(
202 l10n_util::GetStringFUTF16( 208 l10n_util::GetStringFUTF16(
203 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT, 209 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT,
204 base::IntToString16(TrayPower::GetRoundedBatteryPercentage( 210 base::IntToString16(TrayPower::GetRoundedBatteryPercentage(
205 supply_status_.battery_percentage)))); 211 supply_status_.battery_percentage))));
206 } 212 }
207 } 213 }
208 214
209 if (is_charging_unreliable) { 215 if (is_charging_unreliable) {
210 time_label_->SetText( 216 time_label_->SetText(GetChargingUnreliableString());
211 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
212 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE));
213 } else if (supply_status_.is_calculating_battery_time) { 217 } else if (supply_status_.is_calculating_battery_time) {
214 time_label_->SetText( 218 time_label_->SetText(
215 ui::ResourceBundle::GetSharedInstance().GetLocalizedString( 219 ui::ResourceBundle::GetSharedInstance().GetLocalizedString(
216 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING)); 220 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING));
217 } else if (hour || min) { 221 } else if (hour || min) {
218 if (supply_status_.line_power_on) { 222 if (supply_status_.line_power_on) {
219 time_label_->SetText( 223 time_label_->SetText(
220 l10n_util::GetStringFUTF16( 224 l10n_util::GetStringFUTF16(
221 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL, 225 IDS_ASH_STATUS_TRAY_BATTERY_TIME_UNTIL_FULL,
222 base::IntToString16(hour), 226 base::IntToString16(hour),
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 308
305 // Move the time_status_label_ closer to percentage_label_. 309 // Move the time_status_label_ closer to percentage_label_.
306 if (percentage_label_ && time_status_label_ && 310 if (percentage_label_ && time_status_label_ &&
307 percentage_label_->visible() && time_status_label_->visible()) { 311 percentage_label_->visible() && time_status_label_->visible()) {
308 time_status_label_->SetX(percentage_label_->bounds().right() + 1); 312 time_status_label_->SetX(percentage_label_->bounds().right() + 1);
309 } 313 }
310 } 314 }
311 315
312 } // namespace internal 316 } // namespace internal
313 } // namespace ash 317 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/system/chromeos/power/tray_power.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698