#ifndef ASH_SYSTEM_POWER_POWER_NOTIFICATION_CONTROLLER_H_
#define ASH_SYSTEM_POWER_POWER_NOTIFICATION_CONTROLLER_H_
#include <memory>
#include "ash/system/power/power_status.h"
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
namespace message_center {
class MessageCenter;
}
namespace ash {
class BatteryNotification;
class DualRoleNotification;
class ASH_EXPORT PowerNotificationController : public PowerStatus::Observer {
public:
enum NotificationState {
NOTIFICATION_NONE,
NOTIFICATION_LOW_POWER,
NOTIFICATION_CRITICAL,
};
explicit PowerNotificationController(
message_center::MessageCenter* message_center);
PowerNotificationController(const PowerNotificationController&) = delete;
PowerNotificationController& operator=(const PowerNotificationController&) =
delete;
~PowerNotificationController() override;
void NotifyUsbNotificationClosedByUser();
private:
FRIEND_TEST_ALL_PREFIXES(PowerNotificationControllerTest,
MaybeShowUsbChargerNotification);
FRIEND_TEST_ALL_PREFIXES(PowerNotificationControllerTest,
UpdateNotificationState);
friend class PowerNotificationControllerTest;
void OnPowerStatusChanged() override;
bool MaybeShowUsbChargerNotification();
void MaybeShowDualRoleNotification();
bool UpdateNotificationState();
bool UpdateNotificationStateForRemainingTime();
bool UpdateNotificationStateForRemainingPercentage();
static constexpr int kCriticalMinutes = 5;
static constexpr int kLowPowerMinutes = 15;
static constexpr int kNoWarningMinutes = 30;
static constexpr int kCriticalPercentage = 5;
static constexpr int kLowPowerPercentage = 10;
static constexpr int kNoWarningPercentage = 15;
static const char kUsbNotificationId[];
const raw_ptr<message_center::MessageCenter, ExperimentalAsh>
message_center_;
std::unique_ptr<BatteryNotification> battery_notification_;
std::unique_ptr<DualRoleNotification> dual_role_notification_;
NotificationState notification_state_ = NOTIFICATION_NONE;
bool battery_was_full_ = false;
bool usb_charger_was_connected_ = false;
bool line_power_was_connected_ = false;
bool usb_notification_dismissed_ = false;
};
}
#endif