Chromium Code Reviews| 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 60968c39aa9f287f250cd14271494df446cadbd9..83ebfcf3595ef4fb7aff2d36f6b6b42d0229ab25 100644 |
| --- a/ui/app_list/views/contents_view.cc |
| +++ b/ui/app_list/views/contents_view.cc |
| @@ -15,7 +15,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" |
|
xiyuan
2014/05/08 16:17:48
nit: do we still need this?
calamity
2014/05/09 07:09:39
Done.
|
| #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" |
| @@ -28,6 +30,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; |
| @@ -44,6 +47,10 @@ SearchResultListView* GetSearchResultListView(views::ViewModel* model) { |
| model->view_at(kIndexSearchResults)); |
| } |
| +StartPageView* GetStartPageView(views::ViewModel* model) { |
| + return static_cast<StartPageView*>(model->view_at(kIndexStartPage)); |
| +} |
| + |
| } // namespace |
| ContentsView::ContentsView(AppListMainView* app_list_main_view, |
| @@ -53,7 +60,8 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, |
| : show_state_(SHOW_APPS), |
| pagination_model_(pagination_model), |
| view_model_(new views::ViewModel), |
| - bounds_animator_(new views::BoundsAnimator(this)) { |
| + bounds_animator_(new views::BoundsAnimator(this)), |
| + app_list_main_view_(app_list_main_view) { |
| DCHECK(model); |
| pagination_model_->SetTransitionDurations( |
| kPageTransitionDurationInMs, |
| @@ -69,6 +77,15 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, |
| AddChildView(search_results_view); |
| view_model_->Add(search_results_view, kIndexSearchResults); |
| + if (app_list::switches::IsExperimentalAppListEnabled()) { |
| + content::WebContents* start_page_contents = |
| + view_delegate->GetStartPageContents(); |
| + 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()); |
| } |
| @@ -107,6 +124,12 @@ void ContentsView::ShowStateChanged() { |
| results_view->SetSelectedIndex(0); |
| results_view->UpdateAutoLaunchState(); |
| + // Don't show the search box for the start page. |
|
xiyuan
2014/05/08 16:17:48
nit: update comment. It's more like "Notify parent
calamity
2014/05/09 07:09:39
Done.
|
| + app_list_main_view_->OnContentsViewShowStateChanged(show_state_); |
|
xiyuan
2014/05/08 16:17:48
nit: Slightly prefer to add a show_state() accesso
calamity
2014/05/09 07:09:39
Done.
|
| + |
| + if (show_state_ == SHOW_START_PAGE) |
| + GetStartPageView(view_model_.get())->Reset(); |
| + |
| AnimateToIdealBounds(); |
| } |
| @@ -124,6 +147,9 @@ void ContentsView::CalculateIdealBounds() { |
| case SHOW_SEARCH_RESULTS: |
| incoming_view_index = kIndexSearchResults; |
| break; |
| + case SHOW_START_PAGE: |
| + incoming_view_index = kIndexStartPage; |
| + break; |
| default: |
| NOTREACHED(); |
| } |
| @@ -206,6 +232,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_; |
| } |