camera_roll_thumbnail.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_PHONEHUB_CAMERA_ROLL_THUMBNAIL_H_
  5. #define ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_THUMBNAIL_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/components/phonehub/camera_roll_item.h"
  8. #include "ash/system/phonehub/camera_roll_menu_model.h"
  9. #include "ash/system/phonehub/phone_hub_metrics.h"
  10. #include "ui/base/metadata/metadata_header_macros.h"
  11. #include "ui/base/models/simple_menu_model.h"
  12. #include "ui/gfx/canvas.h"
  13. #include "ui/views/context_menu_controller.h"
  14. #include "ui/views/controls/button/menu_button.h"
  15. #include "ui/views/controls/menu/menu_runner.h"
  16. namespace ash {
  17. namespace phonehub {
  18. class CameraRollManager;
  19. class UserActionRecorder;
  20. } // namespace phonehub
  21. class ASH_EXPORT CameraRollThumbnail : public views::MenuButton,
  22. public views::ContextMenuController {
  23. public:
  24. METADATA_HEADER(CameraRollThumbnail);
  25. CameraRollThumbnail(const int index,
  26. const phonehub::CameraRollItem& item,
  27. phonehub::CameraRollManager* camera_roll_manager,
  28. phonehub::UserActionRecorder* user_action_recorder);
  29. ~CameraRollThumbnail() override;
  30. CameraRollThumbnail(CameraRollThumbnail&) = delete;
  31. CameraRollThumbnail operator=(CameraRollThumbnail&) = delete;
  32. // views::ContextMenuController:
  33. void ShowContextMenuForViewImpl(views::View* source,
  34. const gfx::Point& point,
  35. ui::MenuSourceType source_type) override;
  36. // views::MenuButton:
  37. void PaintButtonContents(gfx::Canvas* canvas) override;
  38. private:
  39. FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ImageThumbnail);
  40. FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, VideoThumbnail);
  41. FRIEND_TEST_ALL_PREFIXES(CameraRollThumbnailTest, ImageThumbnail);
  42. FRIEND_TEST_ALL_PREFIXES(CameraRollThumbnailTest, VideoThumbnail);
  43. FRIEND_TEST_ALL_PREFIXES(CameraRollThumbnailTest, LeftClickDownload);
  44. FRIEND_TEST_ALL_PREFIXES(CameraRollThumbnailTest, RightClickOpenMenu);
  45. void ButtonPressed();
  46. ui::SimpleMenuModel* GetMenuModel();
  47. void DownloadRequested();
  48. phone_hub_metrics::CameraRollMediaType GetMediaType();
  49. const int index_;
  50. const phonehub::proto::CameraRollItemMetadata metadata_;
  51. const bool video_type_;
  52. const gfx::ImageSkia image_;
  53. std::unique_ptr<CameraRollMenuModel> menu_model_;
  54. std::unique_ptr<views::MenuRunner> menu_runner_;
  55. phonehub::CameraRollManager* camera_roll_manager_ = nullptr;
  56. phonehub::UserActionRecorder* user_action_recorder_ = nullptr;
  57. };
  58. } // namespace ash
  59. #endif // ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_THUMBNAIL_H_