Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "ui/app_list/app_list_model_observer.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "ui/app_list/app_list_model.h" | |
| 10 #include "ui/app_list/app_list_view_delegate_observer.h" | 11 #include "ui/app_list/app_list_view_delegate_observer.h" |
| 11 #include "ui/app_list/views/search_box_view_delegate.h" | 12 #include "ui/app_list/views/search_box_view_delegate.h" |
| 13 #include "ui/base/models/list_model_observer.h" | |
| 12 #include "ui/views/view.h" | 14 #include "ui/views/view.h" |
| 13 | 15 |
| 14 namespace app_list { | 16 namespace app_list { |
| 15 | 17 |
| 16 class AppListMainView; | 18 class AppListMainView; |
| 17 class AppListModel; | |
| 18 class AppListViewDelegate; | 19 class AppListViewDelegate; |
| 19 class SearchResultListView; | 20 class SearchResultListView; |
| 20 class TileItemView; | 21 class TileItemView; |
| 21 | 22 |
| 22 // The start page for the experimental app list. | 23 // The start page for the experimental app list. |
| 23 class StartPageView : public views::View, | 24 class StartPageView : public views::View, |
| 25 public ui::ListModelObserver, | |
| 24 public SearchBoxViewDelegate, | 26 public SearchBoxViewDelegate, |
| 25 public AppListViewDelegateObserver, | 27 public AppListViewDelegateObserver { |
| 26 public AppListModelObserver { | |
| 27 public: | 28 public: |
| 28 StartPageView(AppListMainView* app_list_main_view, | 29 StartPageView(AppListMainView* app_list_main_view, |
| 29 AppListViewDelegate* view_delegate); | 30 AppListViewDelegate* view_delegate); |
| 30 virtual ~StartPageView(); | 31 virtual ~StartPageView(); |
| 31 | 32 |
| 32 void Reset(); | 33 void Reset(); |
| 33 void ShowSearchResults(); | 34 void ShowSearchResults(); |
| 34 | 35 |
| 35 bool IsShowingSearchResults() const; | 36 bool IsShowingSearchResults() const; |
| 36 | 37 |
| 37 const std::vector<TileItemView*>& tile_views() const { return tile_views_; } | 38 const std::vector<TileItemView*>& tile_views() const { return tile_views_; } |
| 38 SearchBoxView* dummy_search_box_view() { return search_box_view_; } | 39 SearchBoxView* dummy_search_box_view() { return search_box_view_; } |
| 39 | 40 |
| 40 // Overridden from views::View: | 41 // Overridden from views::View: |
| 41 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 42 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
| 42 virtual void Layout() OVERRIDE; | 43 virtual void Layout() OVERRIDE; |
| 43 | 44 |
| 44 private: | 45 private: |
| 45 enum ShowState { | 46 enum ShowState { |
| 46 SHOW_START_PAGE, | 47 SHOW_START_PAGE, |
| 47 SHOW_SEARCH_RESULTS, | 48 SHOW_SEARCH_RESULTS, |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 void InitInstantContainer(); | 51 void InitInstantContainer(); |
| 51 void InitTilesContainer(); | 52 void InitTilesContainer(); |
| 52 | 53 |
| 53 void SetShowState(ShowState show_state); | 54 void SetShowState(ShowState show_state); |
| 54 void SetModel(AppListModel* model); | 55 void SetModel(AppListModel* model); |
| 55 | 56 |
| 57 // Updates UI with model. | |
| 58 void Update(); | |
| 59 | |
| 60 // Schedules an Update() call using |update_factory_|. Does nothing if there | |
| 61 // is a pending call. | |
| 62 void ScheduleUpdate(); | |
| 63 | |
| 56 // Overridden from SearchBoxViewDelegate: | 64 // Overridden from SearchBoxViewDelegate: |
| 57 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE; | 65 virtual void QueryChanged(SearchBoxView* sender) OVERRIDE; |
| 58 | 66 |
| 59 // Overridden from AppListViewDelegateObserver: | 67 // Overridden from AppListViewDelegateObserver: |
| 60 virtual void OnProfilesChanged() OVERRIDE; | 68 virtual void OnProfilesChanged() OVERRIDE; |
| 61 | 69 |
| 62 // Overridden from AppListModelObserver: | 70 // Overriden from ui::ListModelObserver: |
|
Matt Giuca
2014/08/06 08:54:53
nit: Overridden (you specifically introduced a spe
calamity
2014/08/12 05:03:37
Done.
| |
| 63 virtual void OnAppListModelStatusChanged() OVERRIDE; | 71 virtual void ListItemsAdded(size_t start, size_t count) OVERRIDE; |
| 64 virtual void OnAppListItemAdded(AppListItem* item) OVERRIDE; | 72 virtual void ListItemsRemoved(size_t start, size_t count) OVERRIDE; |
| 65 virtual void OnAppListItemDeleted() OVERRIDE; | 73 virtual void ListItemMoved(size_t index, size_t target_index) OVERRIDE; |
| 66 virtual void OnAppListItemUpdated(AppListItem* item) OVERRIDE; | 74 virtual void ListItemsChanged(size_t start, size_t count) OVERRIDE; |
| 67 | 75 |
| 68 // The parent view of ContentsView which is the parent of this view. | 76 // The parent view of ContentsView which is the parent of this view. |
| 69 AppListMainView* app_list_main_view_; | 77 AppListMainView* app_list_main_view_; |
| 70 | 78 |
| 71 AppListModel* model_; // Owned by AppListSyncableService. | 79 AppListModel::SearchResults* |
| 80 search_results_model_; // Owned by AppListSyncableService. | |
| 72 | 81 |
| 73 AppListViewDelegate* view_delegate_; // Owned by AppListView. | 82 AppListViewDelegate* view_delegate_; // Owned by AppListView. |
| 74 | 83 |
| 75 SearchBoxView* search_box_view_; // Owned by views hierarchy. | 84 SearchBoxView* search_box_view_; // Owned by views hierarchy. |
| 76 SearchResultListView* results_view_; // Owned by views hierarchy. | 85 SearchResultListView* results_view_; // Owned by views hierarchy. |
| 77 views::View* instant_container_; // Owned by views hierarchy. | 86 views::View* instant_container_; // Owned by views hierarchy. |
| 78 views::View* tiles_container_; // Owned by views hierarchy. | 87 views::View* tiles_container_; // Owned by views hierarchy. |
| 79 | 88 |
| 80 std::vector<TileItemView*> tile_views_; | 89 std::vector<TileItemView*> tile_views_; |
| 81 | 90 |
| 82 ShowState show_state_; | 91 ShowState show_state_; |
| 83 | 92 |
| 93 // The factory that consolidates multiple Update() calls into one. | |
| 94 base::WeakPtrFactory<StartPageView> update_factory_; | |
|
Matt Giuca
2014/08/06 08:54:53
// ScheduleUpdate() generates a single weak pointe
calamity
2014/08/12 05:03:37
Done.
| |
| 95 | |
| 84 DISALLOW_COPY_AND_ASSIGN(StartPageView); | 96 DISALLOW_COPY_AND_ASSIGN(StartPageView); |
| 85 }; | 97 }; |
| 86 | 98 |
| 87 } // namespace app_list | 99 } // namespace app_list |
| 88 | 100 |
| 89 #endif // UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ | 101 #endif // UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_ |
| OLD | NEW |