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

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

Issue 380943002: Added battery level and time to the status tray's accessible name. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed old view before storing a new one Created 6 years, 5 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
« no previous file with comments | « ash/system/chromeos/power/power_status.h ('k') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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.h" 5 #include "ash/system/chromeos/power/power_status.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "ash/shell.h" 10 #include "ash/shell.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 GetBatteryPercent() / 100.0 * (kNumPowerImages - 1)); 228 GetBatteryPercent() / 100.0 * (kNumPowerImages - 1));
229 index = std::max(std::min(index, kNumPowerImages - 2), 0); 229 index = std::max(std::min(index, kNumPowerImages - 2), 0);
230 } 230 }
231 231
232 gfx::Rect region( 232 gfx::Rect region(
233 offset * kBatteryImageWidth, index * kBatteryImageHeight, 233 offset * kBatteryImageWidth, index * kBatteryImageHeight,
234 kBatteryImageWidth, kBatteryImageHeight); 234 kBatteryImageWidth, kBatteryImageHeight);
235 return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region); 235 return gfx::ImageSkiaOperations::ExtractSubset(*all.ToImageSkia(), region);
236 } 236 }
237 237
238 base::string16 PowerStatus::GetAccessibleNameString() const { 238 base::string16 PowerStatus::GetAccessibleNameString(
239 bool full_description) const {
239 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 240 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
240 if (IsBatteryFull()) { 241 if (IsBatteryFull()) {
241 return rb.GetLocalizedString( 242 return rb.GetLocalizedString(
242 IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE); 243 IDS_ASH_STATUS_TRAY_BATTERY_FULL_CHARGE_ACCESSIBLE);
243 } 244 }
244 245
245 base::string16 battery_percentage_accessible = l10n_util::GetStringFUTF16( 246 base::string16 battery_percentage_accessible = l10n_util::GetStringFUTF16(
246 IsBatteryCharging() ? 247 IsBatteryCharging() ?
247 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_CHARGING_ACCESSIBLE : 248 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_CHARGING_ACCESSIBLE :
248 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ACCESSIBLE, 249 IDS_ASH_STATUS_TRAY_BATTERY_PERCENT_ACCESSIBLE,
249 base::IntToString16(GetRoundedBatteryPercent())); 250 base::IntToString16(GetRoundedBatteryPercent()));
251 if (!full_description)
252 return battery_percentage_accessible;
253
250 base::string16 battery_time_accessible = base::string16(); 254 base::string16 battery_time_accessible = base::string16();
251 const base::TimeDelta time = IsBatteryCharging() ? GetBatteryTimeToFull() : 255 const base::TimeDelta time = IsBatteryCharging() ? GetBatteryTimeToFull() :
252 GetBatteryTimeToEmpty(); 256 GetBatteryTimeToEmpty();
253 257
254 if (IsUsbChargerConnected()) { 258 if (IsUsbChargerConnected()) {
255 battery_time_accessible = rb.GetLocalizedString( 259 battery_time_accessible = rb.GetLocalizedString(
256 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE_ACCESSIBLE); 260 IDS_ASH_STATUS_TRAY_BATTERY_CHARGING_UNRELIABLE_ACCESSIBLE);
257 } else if (IsBatteryTimeBeingCalculated()) { 261 } else if (IsBatteryTimeBeingCalculated()) {
258 battery_time_accessible = rb.GetLocalizedString( 262 battery_time_accessible = rb.GetLocalizedString(
259 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_ACCESSIBLE); 263 IDS_ASH_STATUS_TRAY_BATTERY_CALCULATING_ACCESSIBLE);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 300 }
297 301
298 void PowerStatus::PowerChanged( 302 void PowerStatus::PowerChanged(
299 const power_manager::PowerSupplyProperties& proto) { 303 const power_manager::PowerSupplyProperties& proto) {
300 proto_ = proto; 304 proto_ = proto;
301 SanitizeProto(&proto_); 305 SanitizeProto(&proto_);
302 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); 306 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged());
303 } 307 }
304 308
305 } // namespace ash 309 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/power/power_status.h ('k') | ash/system/chromeos/power/tray_power.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698