adaptive_charging_notification_controller.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_NOTIFICATION_CONTROLLER_H_
  5. #define ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_NOTIFICATION_CONTROLLER_H_
  6. #include <string>
  7. #include "ash/ash_export.h"
  8. #include "base/memory/weak_ptr.h"
  9. #include "third_party/abseil-cpp/absl/types/optional.h"
  10. #include "ui/message_center/public/cpp/notification_delegate.h"
  11. namespace ash {
  12. class ASH_EXPORT AdaptiveChargingNotificationController
  13. : public message_center::NotificationObserver {
  14. public:
  15. AdaptiveChargingNotificationController();
  16. AdaptiveChargingNotificationController(
  17. const AdaptiveChargingNotificationController&) = delete;
  18. AdaptiveChargingNotificationController& operator=(
  19. const AdaptiveChargingNotificationController&) = delete;
  20. virtual ~AdaptiveChargingNotificationController();
  21. // Show the adaptive charging notification. There are two possible
  22. // scenarios:
  23. // 1. When the battery is kept at 80% indefinitely (i.e. no value of
  24. // |hours_to_full| is provided), the notification is a
  25. // normal notification.
  26. // 2. When the battery is temporary kept at 80% (i.e. |hours_to_full| has
  27. // a value), the notification will have higher priority (SYSTEM_PRIORITY).
  28. void ShowAdaptiveChargingNotification(
  29. absl::optional<int> hours_to_full = absl::nullopt);
  30. void CloseAdaptiveChargingNotification(bool by_user = false);
  31. bool ShouldShowNotification();
  32. // message_center::NotificationObserver:
  33. void Click(const absl::optional<int>& button_index,
  34. const absl::optional<std::u16string>& reply) override;
  35. private:
  36. base::WeakPtrFactory<AdaptiveChargingNotificationController>
  37. weak_ptr_factory_{this};
  38. };
  39. } // namespace ash
  40. #endif // ASH_SYSTEM_POWER_ADAPTIVE_CHARGING_NOTIFICATION_CONTROLLER_H_