privacy_screen_toast_controller.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // Copyright 2020 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_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_
  5. #define ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/display/privacy_screen_controller.h"
  8. #include "ash/system/privacy_screen/privacy_screen_toast_view.h"
  9. #include "ash/system/tray/tray_bubble_view.h"
  10. #include "base/timer/timer.h"
  11. namespace ash {
  12. class UnifiedSystemTray;
  13. // Controller class for the privacy screen toast, which is shown when the
  14. // privacy screen is toggled on/off.
  15. class ASH_EXPORT PrivacyScreenToastController
  16. : public TrayBubbleView::Delegate,
  17. public PrivacyScreenController::Observer {
  18. public:
  19. explicit PrivacyScreenToastController(UnifiedSystemTray* tray);
  20. ~PrivacyScreenToastController() override;
  21. PrivacyScreenToastController(PrivacyScreenToastController&) = delete;
  22. PrivacyScreenToastController operator=(PrivacyScreenToastController&) =
  23. delete;
  24. // Shows the toast explicitly. Normally, this is done automatically through
  25. // the PrivacyScreenToastController observer in this class.
  26. void ShowToast();
  27. // Hides the toast if it is shown. Normally, it times out and automatically
  28. // closes.
  29. void HideToast();
  30. // Stops the timer to autoclose the toast.
  31. void StopAutocloseTimer();
  32. // Triggers a timer to automatically close the toast.
  33. void StartAutoCloseTimer();
  34. private:
  35. // Updates the toast UI with the current privacy screen state.
  36. void UpdateToastView();
  37. void ButtonPressed();
  38. // TrayBubbleView::Delegate:
  39. void BubbleViewDestroyed() override;
  40. void OnMouseEnteredView() override;
  41. void OnMouseExitedView() override;
  42. std::u16string GetAccessibleNameForBubble() override;
  43. // PrivacyScreenController::Observer:
  44. void OnPrivacyScreenSettingChanged(bool enabled, bool notify_ui) override;
  45. UnifiedSystemTray* const tray_;
  46. TrayBubbleView* bubble_view_ = nullptr;
  47. views::Widget* bubble_widget_ = nullptr;
  48. PrivacyScreenToastView* toast_view_ = nullptr;
  49. bool mouse_hovered_ = false;
  50. base::OneShotTimer close_timer_;
  51. };
  52. } // namespace ash
  53. #endif // ASH_SYSTEM_PRIVACY_SCREEN_PRIVACY_SCREEN_TOAST_CONTROLLER_H_