[go: nahoru, domu]

blob: 165a145f7bd869f25b9b1d4180c4f3774fdf48b2 [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"
Elaine Chieneeeac4c2024-02-13 22:40:2219#include "ui/base/metadata/metadata_header_macros.h"
Abbas Nayebi54161382022-11-17 23:17:3320#include "ui/gfx/vector_icon_types.h"
21#include "ui/views/controls/button/button.h"
22#include "ui/views/view.h"
23
24namespace views {
25class Button;
26}
27namespace ash {
28
29namespace phonehub {
30class PhoneHubManager;
31}
32
33// A view of the Phone Hub panel, displaying the apps that user can launch for
34// app streaming.
Abbas Nayebi21b5ed12022-11-22 23:31:1535class ASH_EXPORT AppStreamLauncherView
36 : public PhoneHubContentView,
37 public phonehub::AppStreamLauncherDataModel::Observer {
Elaine Chieneeeac4c2024-02-13 22:40:2238 METADATA_HEADER(AppStreamLauncherView, PhoneHubContentView)
Abbas Nayebi54161382022-11-17 23:17:3339 public:
40 explicit AppStreamLauncherView(phonehub::PhoneHubManager* phone_hub_manager);
41 ~AppStreamLauncherView() override;
42
43 // views::View:
44 void ChildPreferredSizeChanged(View* child) override;
45 void ChildVisibilityChanged(View* child) override;
Abbas Nayebi54161382022-11-17 23:17:3346
47 // PhoneHubContentView:
48 phone_hub_metrics::Screen GetScreenForMetrics() const override;
Pu Shi7d04c292023-04-11 20:13:5949 void OnBubbleClose() override;
Abbas Nayebi54161382022-11-17 23:17:3350
Abbas Nayebi21b5ed12022-11-22 23:31:1551 // phonehub::AppStreamLauncherDataModel::Observer:
52 void OnAppListChanged() override;
53
Abbas Nayebi5ef3f3d2022-11-29 00:06:2254 views::View* items_container_for_test() { return items_container_; }
55
Abbas Nayebi54161382022-11-17 23:17:3356 private:
57 friend class AppStreamLauncherViewTest;
58 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, OpenView);
Abbas Nayebi5ef3f3d2022-11-29 00:06:2259 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, AddItems);
60 FRIEND_TEST_ALL_PREFIXES(AppStreamLauncherViewTest, ClickOnItem);
Abbas Nayebi54161382022-11-17 23:17:3361
62 std::unique_ptr<views::View> CreateAppListView();
Abbas Nayebi21b5ed12022-11-22 23:31:1563 std::unique_ptr<views::View> CreateItemView(
64 const phonehub::Notification::AppMetadata& app);
Pu Shia161460a2022-12-20 23:37:2965 std::unique_ptr<views::View> CreateListItemView(
66 const phonehub::Notification::AppMetadata& app);
Abbas Nayebi54161382022-11-17 23:17:3367 std::unique_ptr<views::View> CreateHeaderView();
68 std::unique_ptr<views::Button> CreateButton(
69 views::Button::PressedCallback callback,
70 const gfx::VectorIcon& icon,
71 int message_id);
Daniel Cheng667d1902023-12-01 23:16:3272 void AppIconActivated(phonehub::Notification::AppMetadata app);
Abbas Nayebi21b5ed12022-11-22 23:31:1573
74 // Update the UI based on the information in the data model.
75 void UpdateFromDataModel();
Abbas Nayebi54161382022-11-17 23:17:3376
77 // Handles the click on the "back" arrow in the header.
78 void OnArrowBackActivated();
79
Pu Shia161460a2022-12-20 23:37:2980 void CreateListView(
81 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
82 void CreateGridView(
83 const std::vector<phonehub::Notification::AppMetadata>* apps_list);
84
Bartek Nowierskideb75842023-12-27 02:32:4285 raw_ptr<views::Button, DanglingUntriaged> arrow_back_button_ = nullptr;
86 raw_ptr<phonehub::PhoneHubManager> phone_hub_manager_;
Abbas Nayebi54161382022-11-17 23:17:3387
88 // Contains all the apps
Bartek Nowierskideb75842023-12-27 02:32:4289 raw_ptr<views::View, DanglingUntriaged> 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_