add pagination info to DistilledPageProto
[chromium-blink-merge.git] / ui / app_list / views / start_page_view.h
blob2949ec5fd42de3b05735a3adb06fb1e9aa136dfa
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.
5 #ifndef UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_
6 #define UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "ui/app_list/app_list_export.h"
11 #include "ui/app_list/app_list_model.h"
12 #include "ui/app_list/app_list_view_delegate_observer.h"
13 #include "ui/app_list/views/search_box_view_delegate.h"
14 #include "ui/base/models/list_model_observer.h"
15 #include "ui/views/view.h"
17 namespace app_list {
19 class AppListMainView;
20 class AppListViewDelegate;
21 class SearchResultListView;
22 class TileItemView;
24 // The start page for the experimental app list.
25 class APP_LIST_EXPORT StartPageView : public views::View,
26 public ui::ListModelObserver,
27 public SearchBoxViewDelegate {
28 public:
29 StartPageView(AppListMainView* app_list_main_view,
30 AppListViewDelegate* view_delegate);
31 virtual ~StartPageView();
33 void Reset();
34 void ShowSearchResults();
36 bool IsShowingSearchResults() const;
38 void UpdateForTesting();
40 const std::vector<TileItemView*>& tile_views() const { return tile_views_; }
41 SearchBoxView* dummy_search_box_view() { return search_box_view_; }
43 // Overridden from views::View:
44 virtual bool OnKeyPressed(const ui::KeyEvent& event) override;
45 virtual void Layout() override;
47 private:
48 enum ShowState {
49 SHOW_START_PAGE,
50 SHOW_SEARCH_RESULTS,
53 void InitInstantContainer();
54 void InitTilesContainer();
56 void SetShowState(ShowState show_state);
57 void SetModel(AppListModel* model);
59 // Updates UI with model.
60 void Update();
62 // Schedules an Update() call using |update_factory_|. Does nothing if there
63 // is a pending call.
64 void ScheduleUpdate();
66 // Overridden from SearchBoxViewDelegate:
67 virtual void QueryChanged(SearchBoxView* sender) override;
69 // Overridden from ui::ListModelObserver:
70 virtual void ListItemsAdded(size_t start, size_t count) override;
71 virtual void ListItemsRemoved(size_t start, size_t count) override;
72 virtual void ListItemMoved(size_t index, size_t target_index) override;
73 virtual void ListItemsChanged(size_t start, size_t count) override;
75 // The parent view of ContentsView which is the parent of this view.
76 AppListMainView* app_list_main_view_;
78 AppListModel::SearchResults*
79 search_results_model_; // Owned by AppListSyncableService.
81 AppListViewDelegate* view_delegate_; // Owned by AppListView.
83 SearchBoxView* search_box_view_; // Owned by views hierarchy.
84 SearchResultListView* results_view_; // Owned by views hierarchy.
85 views::View* instant_container_; // Owned by views hierarchy.
86 views::View* tiles_container_; // Owned by views hierarchy.
88 std::vector<TileItemView*> tile_views_;
90 ShowState show_state_;
92 // ScheduleUpdate() generates a single weak pointer; if one exists then an
93 // update is pending. Further calls to ScheduleUpdate() will have no effect.
94 // Once the Update() completes, the weak pointer is invalidated.
95 base::WeakPtrFactory<StartPageView> update_factory_;
97 DISALLOW_COPY_AND_ASSIGN(StartPageView);
100 } // namespace app_list
102 #endif // UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_