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

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

Issue 377783006: Make app list return to previous page after search. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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') | no next file » | 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 01dccd9dccd4102a202596e605c9b2880d87e56f..9057abc8524f7ac4f61f83e91a398fd17a2fc8d2 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -40,7 +40,8 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view)
start_page_view_(NULL),
app_list_main_view_(app_list_main_view),
contents_switcher_view_(NULL),
- view_model_(new views::ViewModel) {
+ view_model_(new views::ViewModel),
+ page_before_search_(0) {
pagination_model_.AddObserver(this);
}
@@ -77,6 +78,7 @@ void ContentsView::InitNamedPages(AppListModel* model,
if (app_list::switches::IsExperimentalAppListEnabled())
initial_page_index = GetPageIndexForNamedPage(NAMED_PAGE_START);
+ page_before_search_ = initial_page_index;
pagination_model_.SelectPage(initial_page_index, false);
// Needed to update the main search box visibility.
@@ -143,6 +145,8 @@ int ContentsView::NumLauncherPages() const {
void ContentsView::SetActivePageInternal(int page_index,
bool show_search_results) {
+ if (!show_search_results)
+ page_before_search_ = page_index;
// Start animating to the new page.
pagination_model_.SelectPage(page_index, true);
ActivePageChanged(show_search_results);
@@ -169,11 +173,12 @@ void ContentsView::ActivePageChanged(bool show_search_results) {
}
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;
+ int search_page = GetPageIndexForNamedPage(
+ app_list::switches::IsExperimentalAppListEnabled()
+ ? NAMED_PAGE_START
+ : NAMED_PAGE_SEARCH_RESULTS);
- SetActivePageInternal(GetPageIndexForNamedPage(new_named_page), show);
+ SetActivePageInternal(show ? search_page : page_before_search_, show);
}
bool ContentsView::IsShowingSearchResults() const {
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698