app_list_main_view.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2013 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_APP_LIST_MAIN_VIEW_H_
  5. #define ASH_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_
  6. #include "ash/app_list/model/search/search_model.h"
  7. #include "ash/app_list/views/search_box_view_delegate.h"
  8. #include "ash/ash_export.h"
  9. #include "base/memory/weak_ptr.h"
  10. #include "base/timer/timer.h"
  11. #include "ui/views/view.h"
  12. namespace ash {
  13. class AppListView;
  14. class AppListViewDelegate;
  15. class ApplicationDragAndDropHost;
  16. class ContentsView;
  17. class PaginationModel;
  18. class SearchBoxView;
  19. class SearchBoxViewBase;
  20. // AppListMainView contains the normal view of the app list, which is shown
  21. // when the user is signed in.
  22. class ASH_EXPORT AppListMainView : public views::View,
  23. public SearchBoxViewDelegate {
  24. public:
  25. AppListMainView(AppListViewDelegate* delegate, AppListView* app_list_view);
  26. AppListMainView(const AppListMainView&) = delete;
  27. AppListMainView& operator=(const AppListMainView&) = delete;
  28. ~AppListMainView() override;
  29. void Init(int initial_apps_page, SearchBoxView* search_box_view);
  30. void ShowAppListWhenReady();
  31. SearchBoxView* search_box_view() const { return search_box_view_; }
  32. // If |drag_and_drop_host| is not nullptr it will be called upon drag and drop
  33. // operations outside the application list.
  34. void SetDragAndDropHostOfCurrentAppList(
  35. ApplicationDragAndDropHost* drag_and_drop_host);
  36. ContentsView* contents_view() const { return contents_view_; }
  37. AppListViewDelegate* view_delegate() { return delegate_; }
  38. // Called when the search box's visibility is changed.
  39. void NotifySearchBoxVisibilityChanged();
  40. // Overridden from views::View:
  41. const char* GetClassName() const override;
  42. void Layout() override;
  43. private:
  44. // Adds the ContentsView.
  45. void AddContentsViews();
  46. // Gets the PaginationModel owned by the AppsGridView.
  47. PaginationModel* GetAppsPaginationModel();
  48. // Overridden from SearchBoxViewDelegate:
  49. void QueryChanged(const std::u16string& trimmed_query,
  50. bool initiated_by_user) override;
  51. void AssistantButtonPressed() override;
  52. void CloseButtonPressed() override;
  53. void ActiveChanged(SearchBoxViewBase* sender) override;
  54. void OnSearchBoxKeyEvent(ui::KeyEvent* event) override;
  55. bool CanSelectSearchResults() override;
  56. AppListViewDelegate* delegate_; // Owned by parent view (AppListView).
  57. // Created by AppListView. Owned by views hierarchy.
  58. SearchBoxView* search_box_view_ = nullptr;
  59. ContentsView* contents_view_ = nullptr; // Owned by views hierarchy.
  60. AppListView* const app_list_view_; // Owned by views hierarchy.
  61. };
  62. } // namespace ash
  63. #endif // ASH_APP_LIST_VIEWS_APP_LIST_MAIN_VIEW_H_