[go: nahoru, domu]

blob: 5ef3ca48f98b115075bc36fd04505bccdde1641a [file] [log] [blame]
Avi Drissman3a215d1e2022-09-07 19:43:091// Copyright 2021 The Chromium Authors
Matt Walliser98e8fe8e2021-09-29 22:57:182// 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 Sonzogni834e018f2023-04-22 10:20:0210#include "base/memory/raw_ptr.h"
Henrique Ferreirofadda062022-12-01 16:27:1411#include "chromeos/ash/components/phonehub/camera_roll_manager.h"
Allen Bauer912e8ff32023-11-08 21:13:1112#include "ui/base/metadata/metadata_header_macros.h"
Matt Walliser98e8fe8e2021-09-29 22:57:1813#include "ui/views/view.h"
14#include "ui/views/view_model.h"
15
Henrique Ferreiro91fb61df2021-11-12 15:51:0316namespace ash {
17
Matt Walliser6eb407e2021-10-19 01:15:2518namespace phonehub {
19class UserActionRecorder;
Henrique Ferreiro91fb61df2021-11-12 15:51:0320}
Matt Walliser98e8fe8e2021-09-29 22:57:1821
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 Ferreiro91fb61df2021-11-12 15:51:0326class ASH_EXPORT CameraRollView : public views::View,
27 public phonehub::CameraRollManager::Observer {
Allen Bauer912e8ff32023-11-08 21:13:1128 METADATA_HEADER(CameraRollView, views::View)
29
Matt Walliser98e8fe8e2021-09-29 22:57:1830 public:
Henrique Ferreiro91fb61df2021-11-12 15:51:0331 CameraRollView(phonehub::CameraRollManager* camera_roll_manager,
32 phonehub::UserActionRecorder* user_action_recorder);
Matt Walliser98e8fe8e2021-09-29 22:57:1833 ~CameraRollView() override;
34 CameraRollView(CameraRollView&) = delete;
35 CameraRollView operator=(CameraRollView&) = delete;
36
Henrique Ferreiro91fb61df2021-11-12 15:51:0337 // phonehub::CameraRollManager::Observer:
Jianbing4b597ff2021-10-29 01:03:0538 void OnCameraRollViewUiStateUpdated() override;
Matt Walliser98e8fe8e2021-09-29 22:57:1839
Matt Walliser98e8fe8e2021-09-29 22:57:1840 private:
Matt Walliserf0de2cd2022-01-07 22:19:2241 friend class CameraRollViewTest;
Jianbing4b597ff2021-10-29 01:03:0542 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, OptInAlready);
Matt Walliser98e8fe8e2021-09-29 22:57:1843 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout);
Matt Walliserf0de2cd2022-01-07 22:19:2244 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ImageThumbnail);
45 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, VideoThumbnail);
Matt Walliser98e8fe8e2021-09-29 22:57:1846
47 class CameraRollItemsView : public views::View {
Allen Bauer912e8ff32023-11-08 21:13:1148 METADATA_HEADER(CameraRollItemsView, views::View)
49
Matt Walliser98e8fe8e2021-09-29 22:57:1850 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 Walliser98e8fe8e2021-09-29 22:57:1862
63 private:
64 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ViewLayout);
Matt Walliserf0de2cd2022-01-07 22:19:2265 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, ImageThumbnail);
66 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, VideoThumbnail);
Matt Walliser98e8fe8e2021-09-29 22:57:1867
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 Nowierskideb75842023-12-27 02:32:4277 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 Walliser184fd172022-04-28 19:01:1980 bool content_present_metric_emitted_ = false;
Matt Walliser98e8fe8e2021-09-29 22:57:1881};
82
83} // namespace ash
84
85#endif // ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_