[go: nahoru, domu]

blob: a8bcbafe11909441415d52d0ed4a0f6049693447 [file] [log] [blame]
Matt Walliser98e8fe8e2021-09-29 22:57:181// 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"
Jianbing4b597ff2021-10-29 01:03:059#include "ash/system/phonehub/camera_roll_opt_in_view.h"
Matt Walliser98e8fe8e2021-09-29 22:57:1810#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 Walliser6eb407e2021-10-19 01:15:2515namespace chromeos {
16namespace phonehub {
17class UserActionRecorder;
18} // namespace phonehub
19} // namespace chromeos
20
Matt Walliser98e8fe8e2021-09-29 22:57:1821namespace 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.
27class ASH_EXPORT CameraRollView
28 : public views::View,
29 public chromeos::phonehub::CameraRollManager::Observer {
30 public:
Matt Walliser6eb407e2021-10-19 01:15:2531 CameraRollView(chromeos::phonehub::CameraRollManager* camera_roll_manager,
32 chromeos::phonehub::UserActionRecorder* user_action_recorder);
Matt Walliser98e8fe8e2021-09-29 22:57:1833 ~CameraRollView() override;
34 CameraRollView(CameraRollView&) = delete;
35 CameraRollView operator=(CameraRollView&) = delete;
36
37 // chromeos::phonehub::CameraRollManager::Observer:
Jianbing4b597ff2021-10-29 01:03:0538 void OnCameraRollViewUiStateUpdated() override;
Matt Walliser98e8fe8e2021-09-29 22:57:1839
40 // views::View:
41 const char* GetClassName() const override;
42
43 private:
Jianbing4b597ff2021-10-29 01:03:0544 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, DisplayOptInView);
45 FRIEND_TEST_ALL_PREFIXES(CameraRollViewTest, OptInAlready);
Matt Walliser98e8fe8e2021-09-29 22:57:1846 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 Walliser6eb407e2021-10-19 01:15:2576 chromeos::phonehub::UserActionRecorder* user_action_recorder_ = nullptr;
Jianbing4b597ff2021-10-29 01:03:0577 CameraRollOptInView* opt_in_view_ = nullptr;
Matt Walliser98e8fe8e2021-09-29 22:57:1878 CameraRollItemsView* items_view_ = nullptr;
79};
80
81} // namespace ash
82
83#endif // ASH_SYSTEM_PHONEHUB_CAMERA_ROLL_VIEW_H_