| 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 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ | 5 #ifndef ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ |
| 6 #define ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ | 6 #define ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 struct VectorIcon; | 21 struct VectorIcon; |
| 22 } | 22 } |
| 23 | 23 |
| 24 namespace ash { | 24 namespace ash { |
| 25 | 25 |
| 26 // PowerStatus is a singleton that receives updates about the system's | 26 // PowerStatus is a singleton that receives updates about the system's |
| 27 // power status from chromeos::PowerManagerClient and makes the information | 27 // power status from chromeos::PowerManagerClient and makes the information |
| 28 // available to interested classes within Ash. | 28 // available to interested classes within Ash. |
| 29 class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { | 29 class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer { |
| 30 public: | 30 public: |
| 31 // Different styles of battery icons. | |
| 32 enum IconSet { ICON_LIGHT, ICON_DARK }; | |
| 33 | |
| 34 // Interface for classes that wish to be notified when the power status | 31 // Interface for classes that wish to be notified when the power status |
| 35 // has changed. | 32 // has changed. |
| 36 class Observer { | 33 class Observer { |
| 37 public: | 34 public: |
| 38 // Called when the power status changes. | 35 // Called when the power status changes. |
| 39 virtual void OnPowerStatusChanged() = 0; | 36 virtual void OnPowerStatusChanged() = 0; |
| 40 | 37 |
| 41 protected: | 38 protected: |
| 42 virtual ~Observer() {} | 39 virtual ~Observer() {} |
| 43 }; | 40 }; |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Returns a list of available power sources which the user may select. | 182 // Returns a list of available power sources which the user may select. |
| 186 std::vector<PowerSource> GetPowerSources() const; | 183 std::vector<PowerSource> GetPowerSources() const; |
| 187 | 184 |
| 188 // Returns the ID of the currently used power source, or an empty string if no | 185 // Returns the ID of the currently used power source, or an empty string if no |
| 189 // power source is selected. | 186 // power source is selected. |
| 190 std::string GetCurrentPowerSourceID() const; | 187 std::string GetCurrentPowerSourceID() const; |
| 191 | 188 |
| 192 // Returns information about the image that would be returned by | 189 // Returns information about the image that would be returned by |
| 193 // GetBatteryImage(). This can be cached and compared against future objects | 190 // GetBatteryImage(). This can be cached and compared against future objects |
| 194 // returned by this method to avoid creating new images unnecessarily. | 191 // returned by this method to avoid creating new images unnecessarily. |
| 195 BatteryImageInfo GetBatteryImageInfo(IconSet icon_set) const; | 192 BatteryImageInfo GetBatteryImageInfo() const; |
| 196 | 193 |
| 197 // A helper function called by GetBatteryImageInfo(). Populates the fields of | 194 // A helper function called by GetBatteryImageInfo(). Populates the fields of |
| 198 // |info|. | 195 // |info|. |
| 199 void CalculateBatteryImageInfo(BatteryImageInfo* info) const; | 196 void CalculateBatteryImageInfo(BatteryImageInfo* info) const; |
| 200 | 197 |
| 198 // The size of the image GetBatteryImage will return, in DIP. |
| 199 static gfx::Size GetBatteryImageSizeInDip(); |
| 200 |
| 201 // Creates a new image that should be shown for the battery's current state. | 201 // Creates a new image that should be shown for the battery's current state. |
| 202 gfx::ImageSkia GetBatteryImage(const BatteryImageInfo& info) const; | 202 gfx::ImageSkiaRep GetBatteryImage(const BatteryImageInfo& info, |
| 203 float scale) const; |
| 203 | 204 |
| 204 // Returns an string describing the current state for accessibility. | 205 // Returns an string describing the current state for accessibility. |
| 205 base::string16 GetAccessibleNameString(bool full_description) const; | 206 base::string16 GetAccessibleNameString(bool full_description) const; |
| 206 | 207 |
| 207 // Updates |proto_|. Does not notify observers. | 208 // Updates |proto_|. Does not notify observers. |
| 208 void SetProtoForTesting(const power_manager::PowerSupplyProperties& proto); | 209 void SetProtoForTesting(const power_manager::PowerSupplyProperties& proto); |
| 209 | 210 |
| 210 protected: | 211 protected: |
| 211 PowerStatus(); | 212 PowerStatus(); |
| 212 ~PowerStatus() override; | 213 ~PowerStatus() override; |
| 213 | 214 |
| 214 private: | 215 private: |
| 215 // Overriden from PowerManagerClient::Observer. | 216 // Overriden from PowerManagerClient::Observer. |
| 216 void PowerChanged(const power_manager::PowerSupplyProperties& proto) override; | 217 void PowerChanged(const power_manager::PowerSupplyProperties& proto) override; |
| 217 | 218 |
| 218 base::ObserverList<Observer> observers_; | 219 base::ObserverList<Observer> observers_; |
| 219 | 220 |
| 220 // Current state. | 221 // Current state. |
| 221 power_manager::PowerSupplyProperties proto_; | 222 power_manager::PowerSupplyProperties proto_; |
| 222 | 223 |
| 223 DISALLOW_COPY_AND_ASSIGN(PowerStatus); | 224 DISALLOW_COPY_AND_ASSIGN(PowerStatus); |
| 224 }; | 225 }; |
| 225 | 226 |
| 226 } // namespace ash | 227 } // namespace ash |
| 227 | 228 |
| 228 #endif // ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ | 229 #endif // ASH_COMMON_SYSTEM_CHROMEOS_POWER_POWER_STATUS_H_ |
| OLD | NEW |