phone_hub_recent_apps_view.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // 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. #ifndef ASH_SYSTEM_PHONEHUB_PHONE_HUB_RECENT_APPS_VIEW_H_
  5. #define ASH_SYSTEM_PHONEHUB_PHONE_HUB_RECENT_APPS_VIEW_H_
  6. #include "ash/ash_export.h"
  7. #include "ash/components/phonehub/recent_apps_interaction_handler.h"
  8. #include "base/gtest_prod_util.h"
  9. #include "ui/views/view.h"
  10. #include "ui/views/view_model.h"
  11. namespace ash {
  12. // A view in Phone Hub bubble that allows user to relaunch a streamed app from
  13. // the recent apps list.
  14. class ASH_EXPORT PhoneHubRecentAppsView
  15. : public views::View,
  16. public phonehub::RecentAppsInteractionHandler::Observer {
  17. public:
  18. explicit PhoneHubRecentAppsView(
  19. phonehub::RecentAppsInteractionHandler* recent_apps_interaction_handler);
  20. ~PhoneHubRecentAppsView() override;
  21. PhoneHubRecentAppsView(PhoneHubRecentAppsView&) = delete;
  22. PhoneHubRecentAppsView operator=(PhoneHubRecentAppsView&) = delete;
  23. // phonehub::RecentAppsInteractionHandler::Observer:
  24. void OnRecentAppsUiStateUpdated() override;
  25. // views::View:
  26. const char* GetClassName() const override;
  27. private:
  28. FRIEND_TEST_ALL_PREFIXES(RecentAppButtonsViewTest, TaskViewVisibility);
  29. FRIEND_TEST_ALL_PREFIXES(RecentAppButtonsViewTest,
  30. SingleRecentAppButtonsView);
  31. FRIEND_TEST_ALL_PREFIXES(RecentAppButtonsViewTest,
  32. MultipleRecentAppButtonsView);
  33. class PlaceholderView;
  34. class RecentAppButtonsView : public views::View {
  35. public:
  36. RecentAppButtonsView();
  37. ~RecentAppButtonsView() override;
  38. RecentAppButtonsView(RecentAppButtonsView&) = delete;
  39. RecentAppButtonsView operator=(RecentAppButtonsView&) = delete;
  40. // views::View:
  41. gfx::Size CalculatePreferredSize() const override;
  42. void Layout() override;
  43. const char* GetClassName() const override;
  44. views::View* AddRecentAppButton(
  45. std::unique_ptr<views::View> recent_app_button);
  46. void Reset();
  47. };
  48. // Update the view to reflect the most recently opened apps.
  49. void Update();
  50. RecentAppButtonsView* recent_app_buttons_view_ = nullptr;
  51. std::vector<views::View*> recent_app_button_list_;
  52. phonehub::RecentAppsInteractionHandler* recent_apps_interaction_handler_ =
  53. nullptr;
  54. PlaceholderView* placeholder_view_ = nullptr;
  55. };
  56. } // namespace ash
  57. #endif // ASH_SYSTEM_PHONEHUB_PHONE_HUB_RECENT_APPS_VIEW_H_