Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: ui/app_list/views/contents_view.cc

Issue 307333002: Add search results to experimental app list start page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments, fix for breaking a test Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a6fd2c41428b3a1d2e0e7090eeb3d6a6147d2687..188926076b313d92e5dc8440bac2a86997721e88 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -37,25 +37,26 @@ const double kFinishTransitionThreshold = 0.33;
ContentsView::ContentsView(AppListMainView* app_list_main_view,
AppListModel* model,
AppListViewDelegate* view_delegate)
- : start_page_view_(NULL),
+ : search_results_view_(NULL),
+ start_page_view_(NULL),
app_list_main_view_(app_list_main_view),
view_model_(new views::ViewModel),
bounds_animator_(new views::BoundsAnimator(this)) {
DCHECK(model);
- search_results_view_ =
- new SearchResultListView(app_list_main_view, view_delegate);
- AddLauncherPage(search_results_view_, NAMED_PAGE_SEARCH_RESULTS);
-
if (app_list::switches::IsExperimentalAppListEnabled()) {
start_page_view_ = new StartPageView(app_list_main_view, view_delegate);
AddLauncherPage(start_page_view_, NAMED_PAGE_START);
+ } else {
+ search_results_view_ =
+ new SearchResultListView(app_list_main_view, view_delegate);
+ AddLauncherPage(search_results_view_, NAMED_PAGE_SEARCH_RESULTS);
+ search_results_view_->SetResults(model->results());
}
apps_container_view_ = new AppsContainerView(app_list_main_view, model);
active_page_ = AddLauncherPage(apps_container_view_, NAMED_PAGE_APPS);
- search_results_view_->SetResults(model->results());
}
ContentsView::~ContentsView() {
@@ -109,17 +110,41 @@ void ContentsView::ActivePageChanged() {
search_results_view_->visible()) {
search_results_view_->SetSelectedIndex(0);
}
- search_results_view_->UpdateAutoLaunchState();
-
- // Notify parent AppListMainView of the page change.
- app_list_main_view_->OnContentsViewActivePageChanged();
+ if (search_results_view_)
+ search_results_view_->UpdateAutoLaunchState();
if (IsNamedPageActive(NAMED_PAGE_START))
start_page_view_->Reset();
+ // Notify parent AppListMainView of the page change.
+ app_list_main_view_->UpdateSearchBoxVisibility();
+
AnimateToIdealBounds();
}
+void ContentsView::ShowSearchResults(bool show) {
+ NamedPage new_named_page = show ? NAMED_PAGE_SEARCH_RESULTS : NAMED_PAGE_APPS;
+ if (app_list::switches::IsExperimentalAppListEnabled())
+ new_named_page = NAMED_PAGE_START;
+
+ SetActivePage(GetPageIndexForNamedPage(new_named_page));
+
+ if (app_list::switches::IsExperimentalAppListEnabled()) {
+ if (show)
+ start_page_view_->ShowSearchResults();
+ else
+ start_page_view_->Reset();
+ app_list_main_view_->UpdateSearchBoxVisibility();
+ }
+}
+
+bool ContentsView::IsShowingSearchResults() const {
+ return app_list::switches::IsExperimentalAppListEnabled()
+ ? IsNamedPageActive(NAMED_PAGE_START) &&
+ start_page_view_->IsShowingSearchResults()
+ : IsNamedPageActive(NAMED_PAGE_SEARCH_RESULTS);
+}
+
void ContentsView::CalculateIdealBounds() {
gfx::Rect rect(GetContentsBounds());
if (rect.IsEmpty())
@@ -169,11 +194,6 @@ PaginationModel* ContentsView::GetAppsPaginationModel() {
return apps_container_view_->apps_grid_view()->pagination_model();
}
-void ContentsView::ShowSearchResults(bool show) {
- NamedPage new_named_page = show ? NAMED_PAGE_SEARCH_RESULTS : NAMED_PAGE_APPS;
- SetActivePage(GetPageIndexForNamedPage(new_named_page));
-}
-
void ContentsView::ShowFolderContent(AppListFolderItem* item) {
apps_container_view_->ShowActiveFolder(item);
}
@@ -200,7 +220,9 @@ int ContentsView::AddLauncherPage(views::View* view, NamedPage named_page) {
gfx::Size ContentsView::GetPreferredSize() const {
const gfx::Size container_size =
apps_container_view_->apps_grid_view()->GetPreferredSize();
- const gfx::Size results_size = search_results_view_->GetPreferredSize();
+ const gfx::Size results_size = search_results_view_
+ ? search_results_view_->GetPreferredSize()
+ : gfx::Size();
int width = std::max(container_size.width(), results_size.width());
int height = std::max(container_size.height(), results_size.height());
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698