OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CONTENTS_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" |
15 #include "ui/app_list/app_list_model.h" | 15 #include "ui/app_list/app_list_model.h" |
| 16 #include "ui/app_list/app_list_model_observer.h" |
16 #include "ui/app_list/pagination_model.h" | 17 #include "ui/app_list/pagination_model.h" |
17 #include "ui/app_list/pagination_model_observer.h" | 18 #include "ui/app_list/pagination_model_observer.h" |
18 #include "ui/views/view.h" | 19 #include "ui/views/view.h" |
19 #include "ui/views/view_model.h" | 20 #include "ui/views/view_model.h" |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 class Rect; | 23 class Rect; |
23 } | 24 } |
24 | 25 |
25 namespace app_list { | 26 namespace app_list { |
26 | 27 |
27 class AppsGridView; | 28 class AppsGridView; |
28 class AppListPage; | 29 class AppListPage; |
29 class ApplicationDragAndDropHost; | 30 class ApplicationDragAndDropHost; |
30 class AppListFolderItem; | 31 class AppListFolderItem; |
31 class AppListMainView; | 32 class AppListMainView; |
32 class AppsContainerView; | 33 class AppsContainerView; |
33 class CustomLauncherPageView; | 34 class CustomLauncherPageView; |
34 class PaginationModel; | 35 class PaginationModel; |
35 class SearchBoxView; | 36 class SearchBoxView; |
36 class SearchResultPageView; | 37 class SearchResultPageView; |
37 class StartPageView; | 38 class StartPageView; |
38 | 39 |
39 // A view to manage launcher pages within the Launcher (eg. start page, apps | 40 // A view to manage launcher pages within the Launcher (eg. start page, apps |
40 // grid view, search results). There can be any number of launcher pages, only | 41 // grid view, search results). There can be any number of launcher pages, only |
41 // one of which can be active at a given time. ContentsView provides the user | 42 // one of which can be active at a given time. ContentsView provides the user |
42 // interface for switching between launcher pages, and animates the transition | 43 // interface for switching between launcher pages, and animates the transition |
43 // between them. | 44 // between them. |
44 class APP_LIST_EXPORT ContentsView : public views::View, | 45 class APP_LIST_EXPORT ContentsView : public views::View, |
45 public PaginationModelObserver { | 46 public PaginationModelObserver, |
| 47 public AppListModelObserver { |
46 public: | 48 public: |
47 explicit ContentsView(AppListMainView* app_list_main_view); | 49 explicit ContentsView(AppListMainView* app_list_main_view); |
48 ~ContentsView() override; | 50 ~ContentsView() override; |
49 | 51 |
50 // Initialize the pages of the launcher. Should be called after | 52 // Initialize the pages of the launcher. Should be called after |
51 // set_contents_switcher_view(). | 53 // set_contents_switcher_view(). |
52 void Init(AppListModel* model); | 54 void Init(AppListModel* model); |
53 | 55 |
54 // The app list gets closed and drag and drop operations need to be cancelled. | 56 // The app list gets closed and drag and drop operations need to be cancelled. |
55 void CancelDrag(); | 57 void CancelDrag(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 void Layout() override; | 129 void Layout() override; |
128 bool OnKeyPressed(const ui::KeyEvent& event) override; | 130 bool OnKeyPressed(const ui::KeyEvent& event) override; |
129 const char* GetClassName() const override; | 131 const char* GetClassName() const override; |
130 | 132 |
131 // Overridden from PaginationModelObserver: | 133 // Overridden from PaginationModelObserver: |
132 void TotalPagesChanged() override; | 134 void TotalPagesChanged() override; |
133 void SelectedPageChanged(int old_selected, int new_selected) override; | 135 void SelectedPageChanged(int old_selected, int new_selected) override; |
134 void TransitionStarted() override; | 136 void TransitionStarted() override; |
135 void TransitionChanged() override; | 137 void TransitionChanged() override; |
136 | 138 |
| 139 // Overridden from AppListModelObserver: |
| 140 void OnSearchAnswerAvailableChanged(bool has_answer) override; |
| 141 |
137 private: | 142 private: |
138 // Sets the active launcher page, accounting for whether the change is for | 143 // Sets the active launcher page, accounting for whether the change is for |
139 // search results. | 144 // search results. |
140 void SetActiveStateInternal(int page_index, | 145 void SetActiveStateInternal(int page_index, |
141 bool show_search_results, | 146 bool show_search_results, |
142 bool animate); | 147 bool animate); |
143 | 148 |
144 // Invoked when active view is changed. | 149 // Invoked when active view is changed. |
145 void ActivePageChanged(); | 150 void ActivePageChanged(); |
146 | 151 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 183 |
179 // Unowned pointer to application list model. | 184 // Unowned pointer to application list model. |
180 AppListModel* model_; | 185 AppListModel* model_; |
181 | 186 |
182 // Sub-views of the ContentsView. All owned by the views hierarchy. | 187 // Sub-views of the ContentsView. All owned by the views hierarchy. |
183 AppsContainerView* apps_container_view_; | 188 AppsContainerView* apps_container_view_; |
184 SearchResultPageView* search_results_page_view_; | 189 SearchResultPageView* search_results_page_view_; |
185 StartPageView* start_page_view_; | 190 StartPageView* start_page_view_; |
186 CustomLauncherPageView* custom_page_view_; | 191 CustomLauncherPageView* custom_page_view_; |
187 | 192 |
| 193 // Unowned pointer to the container of the search answer web view. This |
| 194 // container view is a sub-view of search_results_page_view_. |
| 195 View* search_answer_container_view_; |
| 196 |
188 // The child page views. Owned by the views hierarchy. | 197 // The child page views. Owned by the views hierarchy. |
189 std::vector<AppListPage*> app_list_pages_; | 198 std::vector<AppListPage*> app_list_pages_; |
190 | 199 |
191 // Parent view. Owned by the views hierarchy. | 200 // Parent view. Owned by the views hierarchy. |
192 AppListMainView* app_list_main_view_; | 201 AppListMainView* app_list_main_view_; |
193 | 202 |
194 // Maps State onto |view_model_| indices. | 203 // Maps State onto |view_model_| indices. |
195 std::map<AppListModel::State, int> state_to_view_; | 204 std::map<AppListModel::State, int> state_to_view_; |
196 | 205 |
197 // Maps |view_model_| indices onto State. | 206 // Maps |view_model_| indices onto State. |
198 std::map<int, AppListModel::State> view_to_state_; | 207 std::map<int, AppListModel::State> view_to_state_; |
199 | 208 |
200 // The page that was showing before ShowSearchResults(true) was invoked. | 209 // The page that was showing before ShowSearchResults(true) was invoked. |
201 int page_before_search_; | 210 int page_before_search_; |
202 | 211 |
203 // Manages the pagination for the launcher pages. | 212 // Manages the pagination for the launcher pages. |
204 PaginationModel pagination_model_; | 213 PaginationModel pagination_model_; |
205 | 214 |
206 DISALLOW_COPY_AND_ASSIGN(ContentsView); | 215 DISALLOW_COPY_AND_ASSIGN(ContentsView); |
207 }; | 216 }; |
208 | 217 |
209 } // namespace app_list | 218 } // namespace app_list |
210 | 219 |
211 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ | 220 #endif // UI_APP_LIST_VIEWS_CONTENTS_VIEW_H_ |
OLD | NEW |