summaryrefslogtreecommitdiffstats
path: root/ui/app_list
diff options
context:
space:
mode:
authorcalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 15:51:53 +0000
committercalamity@chromium.org <calamity@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-07-16 15:51:53 +0000
commit89a7a78de73f177430b37fc57ed9824fa50538d7 (patch)
tree598b2feffd8238f32211231587fcfb270dd8ba3e /ui/app_list
parente2cda32510d246b372face0cc3c6e370b9774932 (diff)
downloadchromium_src-89a7a78de73f177430b37fc57ed9824fa50538d7.zip
chromium_src-89a7a78de73f177430b37fc57ed9824fa50538d7.tar.gz
chromium_src-89a7a78de73f177430b37fc57ed9824fa50538d7.tar.bz2
Make app list return to previous page after search.
This CL makes the app list return to the previously displayed page when the search box query is cleared. BUG=349727 Review URL: https://codereview.chromium.org/377783006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283403 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/app_list')
-rw-r--r--ui/app_list/views/app_list_view_unittest.cc20
-rw-r--r--ui/app_list/views/contents_view.cc15
-rw-r--r--ui/app_list/views/contents_view.h9
3 files changed, 26 insertions, 18 deletions
diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc
index f507ca9..c2d3079 100644
--- a/ui/app_list/views/app_list_view_unittest.cc
+++ b/ui/app_list/views/app_list_view_unittest.cc
@@ -443,7 +443,6 @@ void AppListViewTestContext::RunSearchResultsTest() {
ContentsView* contents_view = main_view->contents_view();
ShowContentsViewPageAndVerify(
contents_view->GetPageIndexForNamedPage(ContentsView::NAMED_PAGE_APPS));
- EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
EXPECT_TRUE(main_view->search_box_view()->visible());
// Show the search results.
@@ -466,19 +465,16 @@ void AppListViewTestContext::RunSearchResultsTest() {
contents_view->ShowSearchResults(false);
contents_view->Layout();
EXPECT_FALSE(contents_view->IsShowingSearchResults());
- if (test_type_ == EXPERIMENTAL) {
- EXPECT_TRUE(
- contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_START));
- EXPECT_TRUE(IsViewAtOrigin(contents_view->start_page_view()));
- EXPECT_FALSE(main_view->search_box_view()->visible());
- } else {
- EXPECT_TRUE(
- contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_APPS));
- EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
- EXPECT_TRUE(main_view->search_box_view()->visible());
- }
+
+ // Check that we return to the page that we were on before the search.
+ EXPECT_TRUE(contents_view->IsNamedPageActive(ContentsView::NAMED_PAGE_APPS));
+ EXPECT_TRUE(IsViewAtOrigin(contents_view->apps_container_view()));
+ EXPECT_TRUE(main_view->search_box_view()->visible());
if (test_type_ == EXPERIMENTAL) {
+ ShowContentsViewPageAndVerify(contents_view->GetPageIndexForNamedPage(
+ ContentsView::NAMED_PAGE_START));
+
// Check that typing into the dummy search box triggers the search page.
base::string16 search_text = base::UTF8ToUTF16("test");
SearchBoxView* dummy_search_box =
diff --git a/ui/app_list/views/contents_view.cc b/ui/app_list/views/contents_view.cc
index 01dccd9..9057abc 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 {
diff --git a/ui/app_list/views/contents_view.h b/ui/app_list/views/contents_view.h
index e57a0d2..b828490 100644
--- a/ui/app_list/views/contents_view.h
+++ b/ui/app_list/views/contents_view.h
@@ -67,10 +67,14 @@ class APP_LIST_EXPORT ContentsView : public views::View,
void SetContentsSwitcherView(ContentsSwitcherView* contents_switcher_view);
+ // Shows/hides the search results. Hiding the search results will cause the
+ // app list to return to the page that was displayed before
+ // ShowSearchResults(true) was invoked.
void ShowSearchResults(bool show);
- void ShowFolderContent(AppListFolderItem* folder);
bool IsShowingSearchResults() const;
+ void ShowFolderContent(AppListFolderItem* folder);
+
// Sets the active launcher page and animates the pages into place.
void SetActivePage(int page_index);
@@ -156,6 +160,9 @@ class APP_LIST_EXPORT ContentsView : public views::View,
// Maps NamedPage onto |view_model_| indices.
std::map<NamedPage, int> named_page_to_view_;
+ // The page that was showing before ShowSearchResults(true) was invoked.
+ int page_before_search_;
+
// Manages the pagination for the launcher pages.
PaginationModel pagination_model_;