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

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

Issue 147443007: Add support for localized time strings with two units, eg. "2 hours 17 minutes" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address Tony's comments Created 6 years, 9 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
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 30 matching lines...) Expand all
41 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED; 41 power_manager::PowerSupplyProperties_ExternalPower_DISCONNECTED;
42 if ((on_line_power && proto->battery_time_to_full_sec() < 0) || 42 if ((on_line_power && proto->battery_time_to_full_sec() < 0) ||
43 (!on_line_power && proto->battery_time_to_empty_sec() < 0)) 43 (!on_line_power && proto->battery_time_to_empty_sec() < 0))
44 proto->set_is_calculating_battery_time(true); 44 proto->set_is_calculating_battery_time(true);
45 } 45 }
46 } 46 }
47 47
48 base::string16 GetBatteryTimeAccessibilityString(int hour, int min) { 48 base::string16 GetBatteryTimeAccessibilityString(int hour, int min) {
49 DCHECK(hour || min); 49 DCHECK(hour || min);
50 if (hour && !min) { 50 if (hour && !min) {
51 return ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromHours(hour)); 51 return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
52 ui::TimeFormat::LENGTH_LONG,
53 base::TimeDelta::FromHours(hour));
52 } 54 }
53 if (min && !hour) { 55 if (min && !hour) {
54 return ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromMinutes(min)); 56 return ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
57 ui::TimeFormat::LENGTH_LONG,
58 base::TimeDelta::FromMinutes(min));
55 } 59 }
56 return l10n_util::GetStringFUTF16( 60 return l10n_util::GetStringFUTF16(
57 IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE, 61 IDS_ASH_STATUS_TRAY_BATTERY_TIME_ACCESSIBLE,
58 ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromHours(hour)), 62 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
59 ui::TimeFormat::TimeDurationLong(base::TimeDelta::FromMinutes(min))); 63 ui::TimeFormat::LENGTH_LONG,
64 base::TimeDelta::FromHours(hour)),
65 ui::TimeFormat::Simple(ui::TimeFormat::FORMAT_DURATION,
66 ui::TimeFormat::LENGTH_LONG,
67 base::TimeDelta::FromMinutes(min)));
60 } 68 }
61 69
62 static PowerStatus* g_power_status = NULL; 70 static PowerStatus* g_power_status = NULL;
63 71
64 // Minimum battery percentage rendered in UI. 72 // Minimum battery percentage rendered in UI.
65 const int kMinBatteryPercent = 1; 73 const int kMinBatteryPercent = 1;
66 74
67 // Width and height of battery images. 75 // Width and height of battery images.
68 const int kBatteryImageHeight = 25; 76 const int kBatteryImageHeight = 25;
69 const int kBatteryImageWidth = 25; 77 const int kBatteryImageWidth = 25;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 300
293 void PowerStatus::PowerChanged( 301 void PowerStatus::PowerChanged(
294 const power_manager::PowerSupplyProperties& proto) { 302 const power_manager::PowerSupplyProperties& proto) {
295 proto_ = proto; 303 proto_ = proto;
296 SanitizeProto(&proto_); 304 SanitizeProto(&proto_);
297 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); 305 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged());
298 } 306 }
299 307
300 } // namespace internal 308 } // namespace internal
301 } // namespace ash 309 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/resolution_notification_controller.cc ('k') | ash/system/chromeos/power/power_status_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698