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"
19 class AppListMainView
;
20 class AppListViewDelegate
;
21 class SearchResultListView
;
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 AppListViewDelegateObserver
{
30 StartPageView(AppListMainView
* app_list_main_view
,
31 AppListViewDelegate
* view_delegate
);
32 virtual ~StartPageView();
35 void ShowSearchResults();
37 bool IsShowingSearchResults() const;
39 void UpdateForTesting();
41 const std::vector
<TileItemView
*>& tile_views() const { return tile_views_
; }
42 SearchBoxView
* dummy_search_box_view() { return search_box_view_
; }
44 // Overridden from views::View:
45 virtual bool OnKeyPressed(const ui::KeyEvent
& event
) OVERRIDE
;
46 virtual void Layout() OVERRIDE
;
54 void InitInstantContainer();
55 void InitTilesContainer();
57 void SetShowState(ShowState show_state
);
58 void SetModel(AppListModel
* model
);
60 // Updates UI with model.
63 // Schedules an Update() call using |update_factory_|. Does nothing if there
65 void ScheduleUpdate();
67 // Overridden from SearchBoxViewDelegate:
68 virtual void QueryChanged(SearchBoxView
* sender
) OVERRIDE
;
70 // Overridden from AppListViewDelegateObserver:
71 virtual void OnProfilesChanged() OVERRIDE
;
73 // Overridden from ui::ListModelObserver:
74 virtual void ListItemsAdded(size_t start
, size_t count
) OVERRIDE
;
75 virtual void ListItemsRemoved(size_t start
, size_t count
) OVERRIDE
;
76 virtual void ListItemMoved(size_t index
, size_t target_index
) OVERRIDE
;
77 virtual void ListItemsChanged(size_t start
, size_t count
) OVERRIDE
;
79 // The parent view of ContentsView which is the parent of this view.
80 AppListMainView
* app_list_main_view_
;
82 AppListModel::SearchResults
*
83 search_results_model_
; // Owned by AppListSyncableService.
85 AppListViewDelegate
* view_delegate_
; // Owned by AppListView.
87 SearchBoxView
* search_box_view_
; // Owned by views hierarchy.
88 SearchResultListView
* results_view_
; // Owned by views hierarchy.
89 views::View
* instant_container_
; // Owned by views hierarchy.
90 views::View
* tiles_container_
; // Owned by views hierarchy.
92 std::vector
<TileItemView
*> tile_views_
;
94 ShowState show_state_
;
96 // ScheduleUpdate() generates a single weak pointer; if one exists then an
97 // update is pending. Further calls to ScheduleUpdate() will have no effect.
98 // Once the Update() completes, the weak pointer is invalidated.
99 base::WeakPtrFactory
<StartPageView
> update_factory_
;
101 DISALLOW_COPY_AND_ASSIGN(StartPageView
);
104 } // namespace app_list
106 #endif // UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_