Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 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 | |
| 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" |
Jianbing | 4b597ff | 2021-10-29 01:03:05 | [diff] [blame^] | 9 | #include "ash/system/phonehub/camera_roll_opt_in_view.h" |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 10 | #include "base/gtest_prod_util.h" |
| 11 | #include "chromeos/components/phonehub/camera_roll_manager.h" |
| 12 | #include "ui/views/view.h" |
| 13 | #include "ui/views/view_model.h" |
| 14 | |
Matt Walliser | 6eb407e | 2021-10-19 01:15:25 | [diff] [blame] | 15 | namespace chromeos { |
| 16 | namespace phonehub { |
| 17 | class UserActionRecorder; |
| 18 | } // namespace phonehub |
| 19 | } // namespace chromeos |
| 20 | |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 21 | namespace ash { |
| 22 | |
| 23 | // A view in Phone Hub bubble that allows user view and access recently taken |
| 24 | // photos and videos from a connected device. |
| 25 | // Contains the header and one or more lines of clickable thumbnails. |
| 26 | // This view will automatically hide if no Camera Roll items are available. |
| 27 | class ASH_EXPORT CameraRollView |
| 28 | : public views::View, |
| 29 | public chromeos::phonehub::CameraRollManager::Observer { |
| 30 | public: |
Matt Walliser | 6eb407e | 2021-10-19 01:15:25 | [diff] [blame] | 31 | CameraRollView(chromeos::phonehub::CameraRollManager* camera_roll_manager, |
| 32 | chromeos::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 | |
| 37 | // chromeos::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 | |
| 40 | // views::View: |
| 41 | const char* GetClassName() const override; |
| 42 | |
| 43 | private: |
Jianbing | 4b597ff | 2021-10-29 01:03:05 | [diff] [blame^] | 44 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, DisplayOptInView); |
| 45 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, OptInAlready); |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 46 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout); |
| 47 | |
| 48 | class CameraRollItemsView : public views::View { |
| 49 | public: |
| 50 | CameraRollItemsView(); |
| 51 | ~CameraRollItemsView() override; |
| 52 | CameraRollItemsView(CameraRollItemsView&) = delete; |
| 53 | CameraRollItemsView operator=(CameraRollItemsView&) = delete; |
| 54 | |
| 55 | void AddCameraRollItem(views::View* camera_roll_item); |
| 56 | void Reset(); |
| 57 | |
| 58 | // views::View: |
| 59 | gfx::Size CalculatePreferredSize() const override; |
| 60 | void Layout() override; |
| 61 | const char* GetClassName() const override; |
| 62 | |
| 63 | private: |
| 64 | FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout); |
| 65 | |
| 66 | gfx::Point GetCameraRollItemPosition(int index); |
| 67 | void CalculateIdealBounds(); |
| 68 | |
| 69 | views::ViewModelT<views::View> camera_roll_items_; |
| 70 | }; |
| 71 | |
| 72 | // Update the camera roll section to display the latest items. |
| 73 | void Update(); |
| 74 | |
| 75 | chromeos::phonehub::CameraRollManager* camera_roll_manager_ = nullptr; |
Matt Walliser | 6eb407e | 2021-10-19 01:15:25 | [diff] [blame] | 76 | chromeos::phonehub::UserActionRecorder* user_action_recorder_ = nullptr; |
Jianbing | 4b597ff | 2021-10-29 01:03:05 | [diff] [blame^] | 77 | CameraRollOptInView* opt_in_view_ = nullptr; |
Matt Walliser | 98e8fe8e | 2021-09-29 22:57:18 | [diff] [blame] | 78 | CameraRollItemsView* items_view_ = nullptr; |
| 79 | }; |
| 80 | |
| 81 | } // namespace ash |
| 82 | |
| 83 | #endif // ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_ |