[go: nahoru, domu]

blob: 0f7e3d4a5b9857a9da99f725e25c807a380f86d4 [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"
Daniel Chengbceeb1f2023-05-11 19:19:3413#include "base/gtest_prod_util.h"
Arthur Sonzogni834e018f2023-04-22 10:20:0214#include "base/memory/raw_ptr.h"
Henrique Ferreirofadda062022-12-01 16:27:1415#include "chromeos/ash/components/phonehub/app_stream_launcher_data_model.h"
16#include "chromeos/ash/components/phonehub/notification.h"
17#include "chromeos/ash/components/phonehub/recent_app_click_observer.h"
18#include "chromeos/ash/components/phonehub/recent_apps_interaction_handler.h"
Abbas Nayebi54161382022-11-17 23:17:3319#include "ui/gfx/vector_icon_types.h"
20#include "ui/views/controls/button/button.h"
21#include "ui/views/view.h"
22
23namespace views {
24class Button;
25}
26namespace ash {
27
28namespace phonehub {
29class PhoneHubManager;
30}
31
32// A view of the Phone Hub panel, displaying the apps that user can launch for
33// app streaming.
Abbas Nayebi21b5ed12022-11-22 23:31:1534class ASH_EXPORT AppStreamLauncherView
35 : public PhoneHubContentView,
36 public phonehub::AppStreamLauncherDataModel::Observer {
Abbas Nayebi54161382022-11-17 23:17:3337 public:
38 explicit AppStreamLauncherView(phonehub::PhoneHubManager* phone_hub_manager);
39 ~AppStreamLauncherView() override;
40
41 // views::View:
42 void ChildPreferredSizeChanged(View* child) override;
43 void ChildVisibilityChanged(View* child) override;
44 const char* GetClassName() const override;
45
46 // PhoneHubContentView:
47 phone_hub_metrics::Screen GetScreenForMetrics() const override;
Pu Shi7d04c292023-04-11 20:13:5948 void OnBubbleClose() override;
Abbas Nayebi54161382022-11-17 23:17:3349
Abbas Nayebi21b5ed12022-11-22 23:31:1550 // phonehub::AppStreamLauncherDataModel::Observer:
51 void OnAppListChanged() override;
52
Abbas Nayebi5ef3f3d2022-11-29 00:06:2253 views::View* items_container_for_test() { return items_container_; }
54
Abbas Nayebi54161382022-11-17 23:17:3355 private:
56 friend class AppStreamLauncherViewTest;
57 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, OpenView);
Abbas Nayebi5ef3f3d2022-11-29 00:06:2258 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, AddItems);
59 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, ClickOnItem);
Abbas Nayebi54161382022-11-17 23:17:3360
61 std::unique_ptr<views::View> CreateAppListView();
Abbas Nayebi21b5ed12022-11-22 23:31:1562 std::unique_ptr<views::View> CreateItemView(
63 const phonehub::Notification::AppMetadata& app);
Pu Shia161460a2022-12-20 23:37:2964 std::unique_ptr<views::View> CreateListItemView(
65 const phonehub::Notification::AppMetadata& app);
Abbas Nayebi54161382022-11-17 23:17:3366 std::unique_ptr<views::View> CreateHeaderView();
67 std::unique_ptr<views::Button> CreateButton(
68 views::Button::PressedCallback callback,
69 const gfx::VectorIcon& icon,
70 int message_id);
Daniel Cheng667d1902023-12-01 23:16:3271 void AppIconActivated(phonehub::Notification::AppMetadata app);
Abbas Nayebi21b5ed12022-11-22 23:31:1572
73 // Update the UI based on the information in the data model.
74 void UpdateFromDataModel();
Abbas Nayebi54161382022-11-17 23:17:3375
76 // Handles the click on the "back" arrow in the header.
77 void OnArrowBackActivated();
78
Pu Shia161460a2022-12-20 23:37:2979 void CreateListView(
80 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
81 void CreateGridView(
82 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
83
Arthur Sonzogni34efeb82023-08-17 12:55:1184 raw_ptr<views::Button, DanglingUntriaged | ExperimentalAsh>
85 arrow_back_button_ = nullptr;
Arthur Sonzogni834e018f2023-04-22 10:20:0286 raw_ptr<phonehub::PhoneHubManager, ExperimentalAsh> phone_hub_manager_;
Abbas Nayebi54161382022-11-17 23:17:3387
88 // Contains all the apps
Arthur Sonzogni34efeb82023-08-17 12:55:1189 raw_ptr<views::View, DanglingUntriaged | ExperimentalAsh> items_container_;
Abbas Nayebi54161382022-11-17 23:17:3390
91 base::WeakPtrFactory<AppStreamLauncherView> weak_factory_{this};
92};
93
94} // namespace ash
95
96#endif // ASH_SYSTEM_PHONEHUB_APP_STREAM_LAUNCHER_VIEW_H_