[go: nahoru, domu]

blob: ffa5de987667943493601b890ccdb5ce70fa89ae [file] [log] [blame]
Abbas Nayebi54161382022-11-17 23:17:331// Copyright 2022 The Chromium Authors
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_APP_STREAM_LAUNCHER_VIEW_H_
6#define ASH_SYSTEM_PHONEHUB_APP_STREAM_LAUNCHER_VIEW_H_
7
Abbas Nayebi21b5ed12022-11-22 23:31:158#include <cstdint>
Abbas Nayebi54161382022-11-17 23:17:339#include <memory>
Henrique Ferreirofadda062022-12-01 16:27:1410
Abbas Nayebi54161382022-11-17 23:17:3311#include "ash/ash_export.h"
12#include "ash/system/phonehub/phone_hub_content_view.h"
Henrique Ferreirofadda062022-12-01 16:27:1413#include "chromeos/ash/components/phonehub/app_stream_launcher_data_model.h"
14#include "chromeos/ash/components/phonehub/notification.h"
15#include "chromeos/ash/components/phonehub/recent_app_click_observer.h"
16#include "chromeos/ash/components/phonehub/recent_apps_interaction_handler.h"
Abbas Nayebi54161382022-11-17 23:17:3317#include "ui/gfx/vector_icon_types.h"
18#include "ui/views/controls/button/button.h"
19#include "ui/views/view.h"
20
21namespace views {
22class Button;
23}
24namespace ash {
25
26namespace phonehub {
27class PhoneHubManager;
28}
29
30// A view of the Phone Hub panel, displaying the apps that user can launch for
31// app streaming.
Abbas Nayebi21b5ed12022-11-22 23:31:1532class ASH_EXPORT AppStreamLauncherView
33 : public PhoneHubContentView,
34 public phonehub::AppStreamLauncherDataModel::Observer {
Abbas Nayebi54161382022-11-17 23:17:3335 public:
36 explicit AppStreamLauncherView(phonehub::PhoneHubManager* phone_hub_manager);
37 ~AppStreamLauncherView() override;
38
39 // views::View:
40 void ChildPreferredSizeChanged(View* child) override;
41 void ChildVisibilityChanged(View* child) override;
42 const char* GetClassName() const override;
43
44 // PhoneHubContentView:
45 phone_hub_metrics::Screen GetScreenForMetrics() const override;
Pu Shi7d04c292023-04-11 20:13:5946 void OnBubbleClose() override;
Abbas Nayebi54161382022-11-17 23:17:3347
Abbas Nayebi21b5ed12022-11-22 23:31:1548 // phonehub::AppStreamLauncherDataModel::Observer:
49 void OnAppListChanged() override;
50
Abbas Nayebi5ef3f3d2022-11-29 00:06:2251 views::View* items_container_for_test() { return items_container_; }
52
Abbas Nayebi54161382022-11-17 23:17:3353 private:
54 friend class AppStreamLauncherViewTest;
55 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, OpenView);
Abbas Nayebi5ef3f3d2022-11-29 00:06:2256 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, AddItems);
57 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, ClickOnItem);
Abbas Nayebi54161382022-11-17 23:17:3358
59 std::unique_ptr<views::View> CreateAppListView();
Abbas Nayebi21b5ed12022-11-22 23:31:1560 std::unique_ptr<views::View> CreateItemView(
61 const phonehub::Notification::AppMetadata& app);
Pu Shia161460a2022-12-20 23:37:2962 std::unique_ptr<views::View> CreateListItemView(
63 const phonehub::Notification::AppMetadata& app);
Abbas Nayebi54161382022-11-17 23:17:3364 std::unique_ptr<views::View> CreateHeaderView();
65 std::unique_ptr<views::Button> CreateButton(
66 views::Button::PressedCallback callback,
67 const gfx::VectorIcon& icon,
68 int message_id);
Abbas Nayebi21b5ed12022-11-22 23:31:1569 void AppIconActivated(phonehub::Notification::AppMetadata app,
70 const ui::Event& event);
71
72 // Update the UI based on the information in the data model.
73 void UpdateFromDataModel();
Abbas Nayebi54161382022-11-17 23:17:3374
75 // Handles the click on the "back" arrow in the header.
76 void OnArrowBackActivated();
77
Pu Shia161460a2022-12-20 23:37:2978 void CreateListView(
79 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
80 void CreateGridView(
81 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
82
Abbas Nayebi54161382022-11-17 23:17:3383 views::Button* arrow_back_button_ = nullptr;
84 phonehub::PhoneHubManager* phone_hub_manager_;
85
86 // Contains all the apps
87 views::View* items_container_;
88
89 base::WeakPtrFactory<AppStreamLauncherView> weak_factory_{this};
90};
91
92} // namespace ash
93
94#endif // ASH_SYSTEM_PHONEHUB_APP_STREAM_LAUNCHER_VIEW_H_