camera_mic_tray_item_view.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_UNIFIED_CAMERA_MIC_TRAY_ITEM_VIEW_H_
  5. #define ASH_SYSTEM_UNIFIED_CAMERA_MIC_TRAY_ITEM_VIEW_H_
  6. #include "ash/media/media_controller_impl.h"
  7. #include "ash/public/cpp/session/session_observer.h"
  8. #include "ash/system/tray/tray_item_view.h"
  9. namespace ash {
  10. // An indicator shown in UnifiedSystemTray when a VM is accessing the camera or
  11. // mic. We might want to extend this feature to the browser in the future.
  12. class ASH_EXPORT CameraMicTrayItemView : public TrayItemView,
  13. public SessionObserver,
  14. public MediaCaptureObserver {
  15. public:
  16. enum class Type {
  17. kCamera,
  18. kMic,
  19. };
  20. CameraMicTrayItemView(Shelf* shelf, Type type);
  21. ~CameraMicTrayItemView() override;
  22. CameraMicTrayItemView(const CameraMicTrayItemView&) = delete;
  23. CameraMicTrayItemView& operator=(const CameraMicTrayItemView&) = delete;
  24. std::u16string GetAccessibleNameString() const;
  25. // views::View:
  26. const char* GetClassName() const override;
  27. views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
  28. std::u16string GetTooltipText(const gfx::Point& p) const override;
  29. // SessionObserver:
  30. void OnActiveUserSessionChanged(const AccountId& account_id) override;
  31. // TrayItemView:
  32. void HandleLocaleChange() override;
  33. // MediaCaptureObserver:
  34. void OnVmMediaNotificationChanged(bool camera,
  35. bool mic,
  36. bool camera_and_mic) override;
  37. private:
  38. void Update();
  39. void FetchMessage();
  40. const Type type_;
  41. bool active_ = false;
  42. bool with_mic_ = false; // Only for `type_ == kCamera`.
  43. bool is_primary_session_ = false;
  44. std::u16string message_;
  45. };
  46. } // namespace ash
  47. #endif // ASH_SYSTEM_UNIFIED_CAMERA_MIC_TRAY_ITEM_VIEW_H_