OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/observer_list.h" | 9 #include "base/observer_list.h" |
10 | 10 |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 namespace dbus { | 13 namespace dbus { |
14 class Bus; | 14 class Bus; |
15 class ObjectProxy; | 15 class ObjectProxy; |
16 class Response; | 16 class Response; |
17 class Signal; | 17 class Signal; |
18 } // namespace | 18 } // namespace |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
| 22 // This is the local struct that is used in Chrome. |
| 23 struct PowerSupplyStatus { |
| 24 bool line_power_on; |
| 25 |
| 26 bool battery_is_present; |
| 27 bool battery_is_full; |
| 28 |
| 29 // Time in seconds until the battery is empty or full, 0 for unknown. |
| 30 int64 battery_seconds_to_empty; |
| 31 int64 battery_seconds_to_full; |
| 32 |
| 33 double battery_percentage; |
| 34 |
| 35 PowerSupplyStatus(); |
| 36 const std::string& ToString() const; |
| 37 }; |
| 38 |
22 // PowerManagerClient is used to communicate with the power manager. | 39 // PowerManagerClient is used to communicate with the power manager. |
23 class PowerManagerClient { | 40 class PowerManagerClient { |
24 public: | 41 public: |
25 // Interface for observing changes from the power manager. | 42 // Interface for observing changes from the power manager. |
26 class Observer { | 43 class Observer { |
27 public: | 44 public: |
28 // Called when the brightness is changed. | 45 // Called when the brightness is changed. |
29 // |level| is of the range [0, 100]. | 46 // |level| is of the range [0, 100]. |
30 // |user_initiated| is true if the action is initiated by the user. | 47 // |user_initiated| is true if the action is initiated by the user. |
31 virtual void BrightnessChanged(int level, bool user_initiated) = 0; | 48 virtual void BrightnessChanged(int level, bool user_initiated) {} |
| 49 |
| 50 // Called when power supply polling takes place. |status| is a data |
| 51 // structure that contains the current state of the power supply. |
| 52 virtual void PowerChanged(const PowerSupplyStatus& status) {} |
32 }; | 53 }; |
33 | 54 |
34 // Adds and removes the observer. | 55 // Adds and removes the observer. |
35 virtual void AddObserver(Observer* observer) = 0; | 56 virtual void AddObserver(Observer* observer) = 0; |
36 virtual void RemoveObserver(Observer* observer) = 0; | 57 virtual void RemoveObserver(Observer* observer) = 0; |
37 | 58 |
38 // Decreases the screen brightness. |allow_off| controls whether or not | 59 // Decreases the screen brightness. |allow_off| controls whether or not |
39 // it's allowed to turn off the back light. | 60 // it's allowed to turn off the back light. |
40 virtual void DecreaseScreenBrightness(bool allow_off) = 0; | 61 virtual void DecreaseScreenBrightness(bool allow_off) = 0; |
41 | 62 |
42 // Increases the screen brightness. | 63 // Increases the screen brightness. |
43 virtual void IncreaseScreenBrightness() = 0; | 64 virtual void IncreaseScreenBrightness() = 0; |
44 | 65 |
| 66 // UI initiated request for status update. |
| 67 virtual void RequestStatusUpdate() = 0; |
| 68 |
45 // Creates the instance. | 69 // Creates the instance. |
46 static PowerManagerClient* Create(dbus::Bus* bus); | 70 static PowerManagerClient* Create(dbus::Bus* bus); |
47 | 71 |
48 virtual ~PowerManagerClient(); | 72 virtual ~PowerManagerClient(); |
49 | 73 |
50 protected: | 74 protected: |
51 // Create() should be used instead. | 75 // Create() should be used instead. |
52 PowerManagerClient(); | 76 PowerManagerClient(); |
53 | 77 |
54 private: | 78 private: |
55 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); | 79 DISALLOW_COPY_AND_ASSIGN(PowerManagerClient); |
56 }; | 80 }; |
57 | 81 |
58 } // namespace chromeos | 82 } // namespace chromeos |
59 | 83 |
60 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ | 84 #endif // CHROME_BROWSER_CHROMEOS_DBUS_POWER_MANAGER_CLIENT_H_ |
OLD | NEW |