[go: nahoru, domu]

blob: db55554e5919aa7f043f1f2e2a1cdc30d587807f [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;
46
Abbas Nayebi21b5ed12022-11-22 23:31:1547 // phonehub::AppStreamLauncherDataModel::Observer:
48 void OnAppListChanged() override;
49
Abbas Nayebi5ef3f3d2022-11-29 00:06:2250 views::View* items_container_for_test() { return items_container_; }
51
Abbas Nayebi54161382022-11-17 23:17:3352 private:
53 friend class AppStreamLauncherViewTest;
54 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, OpenView);
Abbas Nayebi5ef3f3d2022-11-29 00:06:2255 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, AddItems);
56 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, ClickOnItem);
Abbas Nayebi54161382022-11-17 23:17:3357
58 std::unique_ptr<views::View> CreateAppListView();
Abbas Nayebi21b5ed12022-11-22 23:31:1559 std::unique_ptr<views::View> CreateItemView(
60 const phonehub::Notification::AppMetadata& app);
Pu Shia161460a2022-12-20 23:37:2961 std::unique_ptr<views::View> CreateListItemView(
62 const phonehub::Notification::AppMetadata& app);
Abbas Nayebi54161382022-11-17 23:17:3363 std::unique_ptr<views::View> CreateHeaderView();
64 std::unique_ptr<views::Button> CreateButton(
65 views::Button::PressedCallback callback,
66 const gfx::VectorIcon& icon,
67 int message_id);
Abbas Nayebi21b5ed12022-11-22 23:31:1568 void AppIconActivated(phonehub::Notification::AppMetadata app,
69 const ui::Event& event);
70
71 // Update the UI based on the information in the data model.
72 void UpdateFromDataModel();
Abbas Nayebi54161382022-11-17 23:17:3373
74 // Handles the click on the "back" arrow in the header.
75 void OnArrowBackActivated();
76
Pu Shia161460a2022-12-20 23:37:2977 void CreateListView(
78 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
79 void CreateGridView(
80 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
81
Abbas Nayebi54161382022-11-17 23:17:3382 views::Button* arrow_back_button_ = nullptr;
83 phonehub::PhoneHubManager* phone_hub_manager_;
84
85 // Contains all the apps
86 views::View* items_container_;
87
88 base::WeakPtrFactory<AppStreamLauncherView> weak_factory_{this};
89};
90
91} // namespace ash
92
93#endif // ASH_SYSTEM_PHONEHUB_APP_STREAM_LAUNCHER_VIEW_H_