search_result_tile_item_list_view.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Copyright 2014 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_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_LIST_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_LIST_VIEW_H_
  6. #include <vector>
  7. #include "ash/app_list/views/search_result_container_view.h"
  8. #include "ash/app_list/views/search_result_tile_item_view.h"
  9. #include "base/timer/timer.h"
  10. namespace views {
  11. class BoxLayout;
  12. class Separator;
  13. class Textfield;
  14. } // namespace views
  15. namespace ash {
  16. class AppListViewDelegate;
  17. // Displays a list of SearchResultTileItemView.
  18. class ASH_EXPORT SearchResultTileItemListView
  19. : public SearchResultContainerView {
  20. public:
  21. SearchResultTileItemListView(views::Textfield* search_box,
  22. AppListViewDelegate* view_delegate);
  23. SearchResultTileItemListView(const SearchResultTileItemListView&) = delete;
  24. SearchResultTileItemListView& operator=(const SearchResultTileItemListView&) =
  25. delete;
  26. ~SearchResultTileItemListView() override;
  27. // Overridden from SearchResultContainerView:
  28. SearchResultTileItemView* GetResultViewAt(size_t index) override;
  29. // Overridden from views::View:
  30. const char* GetClassName() const override;
  31. void Layout() override;
  32. const std::vector<SearchResultTileItemView*>& tile_views_for_test() const {
  33. return tile_views_;
  34. }
  35. // Overridden from SearchResultContainerView:
  36. void OnShownChanged() override;
  37. protected:
  38. // View overrides:
  39. void VisibilityChanged(View* starting_from, bool is_visible) override;
  40. private:
  41. // Overridden from SearchResultContainerView:
  42. int DoUpdate() override;
  43. std::vector<SearchResult*> GetDisplayResults();
  44. std::u16string GetUserTypedQuery();
  45. void OnPlayStoreImpressionTimer();
  46. // Cleans up when the view is hid due to closing the suggestion widow
  47. // or closing the launcher.
  48. void CleanUpOnViewHide();
  49. std::vector<SearchResultTileItemView*> tile_views_;
  50. std::vector<views::Separator*> separator_views_;
  51. // Owned by the views hierarchy.
  52. views::Textfield* search_box_ = nullptr;
  53. views::BoxLayout* layout_ = nullptr;
  54. std::u16string recent_playstore_query_;
  55. base::OneShotTimer playstore_impression_timer_;
  56. const bool is_app_reinstall_recommendation_enabled_;
  57. const size_t max_search_result_tiles_;
  58. };
  59. } // namespace ash
  60. #endif // ASH_APP_LIST_VIEWS_SEARCH_RESULT_TILE_ITEM_LIST_VIEW_H_