snooping_protection_view.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_SYSTEM_HUMAN_PRESENCE_SNOOPING_PROTECTION_VIEW_H_
  5. #define ASH_SYSTEM_HUMAN_PRESENCE_SNOOPING_PROTECTION_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/public/cpp/session/session_controller.h"
  8. #include "ash/public/cpp/session/session_observer.h"
  9. #include "ash/system/human_presence/snooping_protection_controller.h"
  10. #include "ash/system/tray/tray_item_view.h"
  11. #include "base/scoped_observation.h"
  12. #include "components/session_manager/session_manager_types.h"
  13. #include "third_party/skia/include/core/SkColor.h"
  14. namespace ash {
  15. // The icon in the system tray notifying a user that a second person has been
  16. // detected looking over their shoulder.
  17. class ASH_EXPORT SnoopingProtectionView
  18. : public TrayItemView,
  19. public SessionObserver,
  20. public SnoopingProtectionController::Observer {
  21. public:
  22. explicit SnoopingProtectionView(Shelf* shelf);
  23. SnoopingProtectionView(const SnoopingProtectionView&) = delete;
  24. SnoopingProtectionView& operator=(const SnoopingProtectionView&) = delete;
  25. ~SnoopingProtectionView() override;
  26. // views::TrayItemView:
  27. const char* GetClassName() const override;
  28. void HandleLocaleChange() override;
  29. void OnThemeChanged() override;
  30. // SessionObserver:
  31. void OnSessionStateChanged(session_manager::SessionState state) override;
  32. // SnoopingProtectionController::Observer:
  33. void OnSnoopingStatusChanged(bool snooper) override;
  34. void OnSnoopingProtectionControllerDestroyed() override;
  35. private:
  36. // Updates the system tray icon to use the color corresponding to the current
  37. // session state (e.g. darker during OOBE).
  38. void UpdateIconColor(session_manager::SessionState session_state);
  39. base::ScopedObservation<SessionController, SessionObserver>
  40. session_observation_{this};
  41. base::ScopedObservation<SnoopingProtectionController,
  42. SnoopingProtectionController::Observer>
  43. controller_observation_{this};
  44. // Must be last.
  45. base::WeakPtrFactory<SnoopingProtectionView> weak_ptr_factory_{this};
  46. };
  47. } // namespace ash
  48. #endif // ASH_SYSTEM_HUMAN_PRESENCE_SNOOPING_PROTECTION_VIEW_H_