Avi Drissman | 3a215d1e | 2022-09-07 19:43:09 | [diff] [blame] | 1 | // Copyright 2021 The Chromium Authors |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_ |
| 6 | #define ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_ |
| 7 | |
| 8 | #include "ash/ash_export.h" |
| 9 | #include "base/gtest_prod_util.h" |
Arthur Sonzogni | 834e018f | 2023-04-22 10:20:02 | [diff] [blame] | 10 | #include "base/memory/raw_ptr.h" |
Henrique Ferreiro | fadda06 | 2022-12-01 16:27:14 | [diff] [blame] | 11 | #include "chromeos/ash/components/phonehub/camera_roll_manager.h" |
Allen Bauer | 912e8ff3 | 2023-11-08 21:13:11 | [diff] [blame] | 12 | #include "ui/base/metadata/metadata_header_macros.h" |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 13 | #include "ui/views/view.h" |
| 14 | #include "ui/views/view_model.h" |
| 15 | |
Henrique Ferreiro | 91fb61df | 2021-11-12 15:51:03 | [diff] [blame] | 16 | namespace ash { |
| 17 | |
Matt Walliser | 6eb407e | 2021-10-19 01:15:25 | [diff] [blame] | 18 | namespace phonehub { |
| 19 | class UserActionRecorder; |
Henrique Ferreiro | 91fb61df | 2021-11-12 15:51:03 | [diff] [blame] | 20 | } |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 21 | |
| 22 | // A view in Phone Hub bubble that allows user view and access recently taken |
| 23 | // photos and videos from a connected device. |
| 24 | // Contains the header and one or more lines of clickable thumbnails. |
| 25 | // This view will automatically hide if no Camera Roll items are available. |
Henrique Ferreiro | 91fb61df | 2021-11-12 15:51:03 | [diff] [blame] | 26 | class ASH_EXPORT CameraRollView : public views::View, |
| 27 | public phonehub::CameraRollManager::Observer { |
Allen Bauer | 912e8ff3 | 2023-11-08 21:13:11 | [diff] [blame] | 28 | METADATA_HEADER(CameraRollView, views::View) |
| 29 | |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 30 | public: |
Henrique Ferreiro | 91fb61df | 2021-11-12 15:51:03 | [diff] [blame] | 31 | CameraRollView(phonehub::CameraRollManager* camera_roll_manager, |
| 32 | phonehub::UserActionRecorder* user_action_recorder); |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 33 | ~CameraRollView() override; |
| 34 | CameraRollView(CameraRollView&) = delete; |
| 35 | CameraRollView operator=(CameraRollView&) = delete; |
| 36 | |
Henrique Ferreiro | 91fb61df | 2021-11-12 15:51:03 | [diff] [blame] | 37 | // phonehub::CameraRollManager::Observer: |
Jianbing | 4b597ff | 2021-10-29 01:03:05 | [diff] [blame] | 38 | void OnCameraRollViewUiStateUpdated() override; |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 39 | |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 40 | private: |
Matt Walliser | f0de2cd | 2022-01-07 22:19:22 | [diff] [blame] | 41 | friend class CameraRollViewTest; |
Jianbing | 4b597ff | 2021-10-29 01:03:05 | [diff] [blame] | 42 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, OptInAlready); |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 43 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout); |
Matt Walliser | f0de2cd | 2022-01-07 22:19:22 | [diff] [blame] | 44 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ImageThumbnail); |
| 45 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, VideoThumbnail); |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 46 | |
| 47 | class CameraRollItemsView : public views::View { |
Allen Bauer | 912e8ff3 | 2023-11-08 21:13:11 | [diff] [blame] | 48 | METADATA_HEADER(CameraRollItemsView, views::View) |
| 49 | |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 50 | public: |
| 51 | CameraRollItemsView(); |
| 52 | ~CameraRollItemsView() override; |
| 53 | CameraRollItemsView(CameraRollItemsView&) = delete; |
| 54 | CameraRollItemsView operator=(CameraRollItemsView&) = delete; |
| 55 | |
| 56 | void AddCameraRollItem(views::View* camera_roll_item); |
| 57 | void Reset(); |
| 58 | |
| 59 | // views::View: |
| 60 | gfx::Size CalculatePreferredSize() const override; |
| 61 | void Layout() override; |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 62 | |
| 63 | private: |
| 64 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout); |
Matt Walliser | f0de2cd | 2022-01-07 22:19:22 | [diff] [blame] | 65 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ImageThumbnail); |
| 66 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, VideoThumbnail); |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 67 | |
| 68 | gfx::Point GetCameraRollItemPosition(int index); |
| 69 | void CalculateIdealBounds(); |
| 70 | |
| 71 | views::ViewModelT<views::View> camera_roll_items_; |
| 72 | }; |
| 73 | |
| 74 | // Update the camera roll section to display the latest items. |
| 75 | void Update(); |
| 76 | |
Bartek Nowierski | deb7584 | 2023-12-27 02:32:42 | [diff] [blame^] | 77 | raw_ptr<phonehub::CameraRollManager> camera_roll_manager_ = nullptr; |
| 78 | raw_ptr<phonehub::UserActionRecorder> user_action_recorder_ = nullptr; |
| 79 | raw_ptr<CameraRollItemsView> items_view_ = nullptr; |
Matt Walliser | 184fd17 | 2022-04-28 19:01:19 | [diff] [blame] | 80 | bool content_present_metric_emitted_ = false; |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | } // namespace ash |
| 84 | |
| 85 | #endif // ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_ |