| Index: ash/common/system/chromeos/power/power_status.h
|
| diff --git a/ash/common/system/chromeos/power/power_status.h b/ash/common/system/chromeos/power/power_status.h
|
| index 26c4b1947ad5f8b34cf4c6feb463cbadbba7a480..0706afd2c8acae676c7acd67e9b6fc32a744bfdd 100644
|
| --- a/ash/common/system/chromeos/power/power_status.h
|
| +++ b/ash/common/system/chromeos/power/power_status.h
|
| @@ -9,6 +9,7 @@
|
| #include <vector>
|
|
|
| #include "ash/ash_export.h"
|
| +#include "ash/common/material_design/material_design_controller.h"
|
| #include "base/macros.h"
|
| #include "base/observer_list.h"
|
| #include "base/strings/string16.h"
|
| @@ -24,6 +25,15 @@ namespace ash {
|
| // available to interested classes within Ash.
|
| class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer {
|
| public:
|
| + // Types of badges which can be drawn over top of a battery icon.
|
| + enum IconBadge {
|
| + ICON_BADGE_NONE,
|
| + ICON_BADGE_ALERT,
|
| + ICON_BADGE_BOLT,
|
| + ICON_BADGE_X,
|
| + ICON_BADGE_UNRELIABLE
|
| + };
|
| +
|
| // Different styles of battery icons.
|
| enum IconSet {
|
| ICON_LIGHT,
|
| @@ -67,24 +77,49 @@ class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer {
|
| // updating onscreen icons (GetBatteryImage() creates a new image on each
|
| // call).
|
| struct BatteryImageInfo {
|
| - BatteryImageInfo() : resource_id(-1), offset(-1), index(-1) {}
|
| + BatteryImageInfo()
|
| + : resource_id(-1),
|
| + offset(-1),
|
| + index(-1),
|
| + icon_badge(ICON_BADGE_NONE),
|
| + fill_level(-1) {}
|
|
|
| bool operator==(const BatteryImageInfo& o) const {
|
| + if (ash::MaterialDesignController::UseMaterialDesignSystemIcons())
|
| + return icon_badge == o.icon_badge && fill_level == o.fill_level;
|
| +
|
| + // TODO(tdanderson): |resource_id|, |offset|, and |index| are only used
|
| + // for non-MD. Remove these once MD is enabled by default. See
|
| + // crbug.com/614453.
|
| return resource_id == o.resource_id && offset == o.offset &&
|
| index == o.index;
|
| }
|
| +
|
| bool operator!=(const BatteryImageInfo& o) const { return !(*this == o); }
|
|
|
| // Resource ID of the image containing the specific battery icon to use.
|
| + // Only used in non-MD.
|
| int resource_id;
|
|
|
| // Horizontal offset in the battery icon array image. The USB / "unreliable
|
| // charging" image has a single column of icons; the other image contains a
|
| // "battery" column on the left and a "line power" column on the right.
|
| + // Only used in non-MD.
|
| int offset;
|
|
|
| - // Vertical offset corresponding to the current battery level.
|
| + // Vertical offset corresponding to the current battery level. Only used in
|
| + // non-MD.
|
| int index;
|
| +
|
| + // The badge (lightning bolt, exclamation mark, etc) that should be drawn
|
| + // on top of the battery icon. Only used for MD.
|
| + // TODO(tdanderson): Consider using gfx::VectorIconId instead of this enum
|
| + // once all possible badges have been vectorized. See crbug.com/617298.
|
| + IconBadge icon_badge;
|
| +
|
| + // A value between 0 and kBatteryImageHeightMD representing the height
|
| + // (in pixels) of the battery's fill level. Only used for MD.
|
| + int fill_level;
|
| };
|
|
|
| // Maximum battery time-to-full or time-to-empty that should be displayed
|
| @@ -193,8 +228,23 @@ class ASH_EXPORT PowerStatus : public chromeos::PowerManagerClient::Observer {
|
| // returned by this method to avoid creating new images unnecessarily.
|
| BatteryImageInfo GetBatteryImageInfo(IconSet icon_set) const;
|
|
|
| + // A helper function called by GetBatteryImageInfo(). Populates the
|
| + // MD-specific fields of |info|.
|
| + void CalculateBatteryImageInfoMD(BatteryImageInfo* info) const;
|
| +
|
| + // A helper function called by GetBatteryImageInfo(). Populates the
|
| + // non-MD-specific fields of |info|.
|
| + void CalculateBatteryImageInfoNonMD(BatteryImageInfo* info,
|
| + const IconSet& icon_set) const;
|
| +
|
| // Creates a new image that should be shown for the battery's current state.
|
| - gfx::ImageSkia GetBatteryImage(IconSet icon_set) const;
|
| + gfx::ImageSkia GetBatteryImage(const BatteryImageInfo& info) const;
|
| +
|
| + // A version of GetBatteryImage() that is used when material design is not
|
| + // enabled.
|
| + // TODO(tdanderson): Remove this once material design is enabled by default.
|
| + // See crbug.com/614453.
|
| + gfx::ImageSkia GetBatteryImageNonMD(const BatteryImageInfo& info) const;
|
|
|
| // Returns an string describing the current state for accessibility.
|
| base::string16 GetAccessibleNameString(bool full_description) const;
|
|
|