eche_alert_generator.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2021 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_WEBUI_ECHE_APP_UI_ECHE_ALERT_GENERATOR_H_
  5. #define ASH_WEBUI_ECHE_APP_UI_ECHE_ALERT_GENERATOR_H_
  6. #include <string>
  7. #include "ash/webui/eche_app_ui/mojom/eche_app.mojom.h"
  8. #include "components/prefs/pref_change_registrar.h"
  9. #include "mojo/public/cpp/bindings/receiver.h"
  10. class PrefService;
  11. namespace ash {
  12. namespace eche_app {
  13. class LaunchAppHelper;
  14. extern const char kEcheAppScreenLockNotifierId[];
  15. extern const char kEcheAppRetryConnectionNotifierId[];
  16. extern const char kEcheAppInactivityNotifierId[];
  17. extern const char kEcheAppFromWebWithoutButtonNotifierId[];
  18. extern const char kEcheAppLearnMoreUrl[];
  19. extern const char kEcheAppToastId[];
  20. // Implements the ShowNotification interface to allow WebUI show the native
  21. // notification and toast.
  22. class EcheAlertGenerator : public mojom::NotificationGenerator {
  23. public:
  24. explicit EcheAlertGenerator(LaunchAppHelper* launch_app_helper,
  25. PrefService* pref_service);
  26. ~EcheAlertGenerator() override;
  27. EcheAlertGenerator(const EcheAlertGenerator&) = delete;
  28. EcheAlertGenerator& operator=(const EcheAlertGenerator&) = delete;
  29. // mojom::NotificationGenerator:
  30. void ShowNotification(const std::u16string& title,
  31. const std::u16string& message,
  32. mojom::WebNotificationType type) override;
  33. void ShowToast(const std::u16string& text) override;
  34. void Bind(mojo::PendingReceiver<mojom::NotificationGenerator> receiver);
  35. private:
  36. void OnEnableScreenLockChanged();
  37. mojo::Receiver<mojom::NotificationGenerator> notification_receiver_{this};
  38. LaunchAppHelper* launch_app_helper_;
  39. PrefService* pref_service_;
  40. PrefChangeRegistrar pref_change_registrar_;
  41. };
  42. } // namespace eche_app
  43. } // namespace ash
  44. #endif // ASH_WEBUI_ECHE_APP_UI_ECHE_ALERT_GENERATOR_H_