Index: ui/app_list/views/contents_view.cc |
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc |
index 0121cf6d8da06d12f653693a06fd59dd3310a50a..0d31db505d5d7c38736ed297b296aed9d1c10e54 100644 |
--- a/ui/app_list/views/contents_view.cc |
+++ b/ui/app_list/views/contents_view.cc |
@@ -14,7 +14,9 @@ |
#include "ui/app_list/views/app_list_main_view.h" |
#include "ui/app_list/views/apps_container_view.h" |
#include "ui/app_list/views/apps_grid_view.h" |
+#include "ui/app_list/views/search_box_view.h" |
#include "ui/app_list/views/search_result_list_view.h" |
+#include "ui/app_list/views/start_page_view.h" |
#include "ui/events/event.h" |
#include "ui/views/animation/bounds_animator.h" |
#include "ui/views/view_model.h" |
@@ -27,6 +29,7 @@ namespace { |
// Indexes of interesting views in ViewModel of ContentsView. |
const int kIndexAppsContainer = 0; |
const int kIndexSearchResults = 1; |
+const int kIndexStartPage = 2; |
const int kMinMouseWheelToSwitchPage = 20; |
const int kMinScrollToSwitchPage = 20; |
@@ -43,6 +46,10 @@ SearchResultListView* GetSearchResultListView(views::ViewModel* model) { |
model->view_at(kIndexSearchResults)); |
} |
+SearchResultListView* GetStartPageView(views::ViewModel* model) { |
+ return static_cast<SearchResultListView*>(model->view_at(kIndexStartPage)); |
+} |
+ |
} // namespace |
ContentsView::ContentsView(AppListMainView* app_list_main_view, |
@@ -70,6 +77,13 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, |
AddChildView(search_results_view); |
view_model_->Add(search_results_view, kIndexSearchResults); |
+ if (app_list::switches::IsExperimentalAppListEnabled()) { |
+ StartPageView* start_page_view = |
+ new StartPageView(app_list_main_view, start_page_contents); |
+ AddChildView(start_page_view); |
+ view_model_->Add(start_page_view, kIndexStartPage); |
+ } |
+ |
GetSearchResultListView(view_model_.get())->SetResults(model->results()); |
} |
@@ -94,6 +108,10 @@ void ContentsView::SetShowState(ShowState show_state) { |
ShowStateChanged(); |
} |
+AppListMainView* ContentsView::GetMainView() { |
+ return static_cast<AppListMainView*>(parent()); |
+} |
+ |
void ContentsView::ShowStateChanged() { |
SearchResultListView* results_view = |
GetSearchResultListView(view_model_.get()); |
@@ -102,6 +120,10 @@ void ContentsView::ShowStateChanged() { |
results_view->SetSelectedIndex(0); |
results_view->UpdateAutoLaunchState(); |
+ // Don't show the search box for the start page. |
+ app_list_main_view_->search_box_view()->SetVisible(show_state_ != |
+ SHOW_START_PAGE); |
+ |
AnimateToIdealBounds(); |
} |
@@ -119,6 +141,9 @@ void ContentsView::CalculateIdealBounds() { |
case SHOW_SEARCH_RESULTS: |
incoming_view_index = kIndexSearchResults; |
break; |
+ case SHOW_START_PAGE: |
+ incoming_view_index = kIndexStartPage; |
+ break; |
default: |
NOTREACHED(); |
} |
@@ -201,6 +226,8 @@ bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { |
return GetAppsContainerView(view_model_.get())->OnKeyPressed(event); |
case SHOW_SEARCH_RESULTS: |
return GetSearchResultListView(view_model_.get())->OnKeyPressed(event); |
+ case SHOW_START_PAGE: |
+ return GetStartPageView(view_model_.get())->OnKeyPressed(event); |
default: |
NOTREACHED() << "Unknown show state " << show_state_; |
} |