OLD | NEW |
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" |
11 #include "ash/shell_delegate.h" | 11 #include "ash/shell_delegate.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
16 #include "chromeos/dbus/power_manager_client.h" | 16 #include "chromeos/dbus/power_manager_client.h" |
17 #include "grit/ash_resources.h" | 17 #include "grit/ash_resources.h" |
18 #include "grit/ash_strings.h" | 18 #include "grit/ash_strings.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/l10n/time_format.h" | 20 #include "ui/base/l10n/time_format.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
23 #include "ui/gfx/image/image_skia_operations.h" | 23 #include "ui/gfx/image/image_skia_operations.h" |
24 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 namespace internal { | |
28 | |
29 namespace { | 27 namespace { |
30 | 28 |
31 // Updates |proto| to ensure that its fields are consistent. | 29 // Updates |proto| to ensure that its fields are consistent. |
32 void SanitizeProto(power_manager::PowerSupplyProperties* proto) { | 30 void SanitizeProto(power_manager::PowerSupplyProperties* proto) { |
33 DCHECK(proto); | 31 DCHECK(proto); |
34 | 32 |
35 if (proto->battery_state() == | 33 if (proto->battery_state() == |
36 power_manager::PowerSupplyProperties_BatteryState_FULL) | 34 power_manager::PowerSupplyProperties_BatteryState_FULL) |
37 proto->set_battery_percent(100.0); | 35 proto->set_battery_percent(100.0); |
38 | 36 |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 SanitizeProto(&proto_); | 296 SanitizeProto(&proto_); |
299 } | 297 } |
300 | 298 |
301 void PowerStatus::PowerChanged( | 299 void PowerStatus::PowerChanged( |
302 const power_manager::PowerSupplyProperties& proto) { | 300 const power_manager::PowerSupplyProperties& proto) { |
303 proto_ = proto; | 301 proto_ = proto; |
304 SanitizeProto(&proto_); | 302 SanitizeProto(&proto_); |
305 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); | 303 FOR_EACH_OBSERVER(Observer, observers_, OnPowerStatusChanged()); |
306 } | 304 } |
307 | 305 |
308 } // namespace internal | |
309 } // namespace ash | 306 } // namespace ash |
OLD | NEW |