screen_capture_tray_item_view.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_UNIFIED_SCREEN_CAPTURE_TRAY_ITEM_VIEW_H_
  5. #define ASH_SYSTEM_UNIFIED_SCREEN_CAPTURE_TRAY_ITEM_VIEW_H_
  6. #include <string>
  7. #include "ash/multi_capture/multi_capture_service_client.h"
  8. #include "ash/system/tray/tray_item_view.h"
  9. #include "base/containers/fixed_flat_set.h"
  10. #include "base/memory/weak_ptr.h"
  11. namespace url {
  12. class Origin;
  13. }
  14. namespace ash {
  15. // An indicator shown in UnifiedSystemTray when a web application is using
  16. // screen capturing.
  17. class ASH_EXPORT ScreenCaptureTrayItemView
  18. : public TrayItemView,
  19. public MultiCaptureServiceClient::Observer {
  20. public:
  21. explicit ScreenCaptureTrayItemView(Shelf* shelf);
  22. ScreenCaptureTrayItemView(const ScreenCaptureTrayItemView&) = delete;
  23. ScreenCaptureTrayItemView& operator=(const ScreenCaptureTrayItemView&) =
  24. delete;
  25. ~ScreenCaptureTrayItemView() override;
  26. // views::View:
  27. const char* GetClassName() const override;
  28. views::View* GetTooltipHandlerForPoint(const gfx::Point& point) override;
  29. std::u16string GetTooltipText(const gfx::Point& point) const override;
  30. // TrayItemView:
  31. void HandleLocaleChange() override {}
  32. // MultiCaptureServiceClient::Observer:
  33. void MultiCaptureStarted(const std::string& label,
  34. const url::Origin& origin) override;
  35. void MultiCaptureStopped(const std::string& label) override;
  36. private:
  37. void Refresh();
  38. base::flat_set<std::string> request_ids_;
  39. base::WeakPtrFactory<ScreenCaptureTrayItemView> weak_ptr_factory_{this};
  40. };
  41. } // namespace ash
  42. #endif // ASH_SYSTEM_UNIFIED_SCREEN_CAPTURE_TRAY_ITEM_VIEW_H_