Commit 085fd942 authored by calamity@chromium.org's avatar calamity@chromium.org

Slight refactor of search result handling in ContentsView.

This CL is a small refactor of ContentsView::ShowSearchResults()
which avoids resetting the start page before showing the search results
in the experimental app list.

BUG=349727

Review URL: https://codereview.chromium.org/331413003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278024 0039d316-1c4b-4281-b951-d872f2087c98
parent e4488fd4
...@@ -82,8 +82,7 @@ void ContentsView::SetActivePage(int page_index) { ...@@ -82,8 +82,7 @@ void ContentsView::SetActivePage(int page_index) {
if (active_page_ == page_index) if (active_page_ == page_index)
return; return;
active_page_ = page_index; SetActivePageInternal(page_index, false);
ActivePageChanged();
} }
bool ContentsView::IsNamedPageActive(NamedPage named_page) const { bool ContentsView::IsNamedPageActive(NamedPage named_page) const {
...@@ -104,7 +103,13 @@ int ContentsView::GetPageIndexForNamedPage(NamedPage named_page) const { ...@@ -104,7 +103,13 @@ int ContentsView::GetPageIndexForNamedPage(NamedPage named_page) const {
return it->second; return it->second;
} }
void ContentsView::ActivePageChanged() { void ContentsView::SetActivePageInternal(int page_index,
bool show_search_results) {
active_page_ = page_index;
ActivePageChanged(show_search_results);
}
void ContentsView::ActivePageChanged(bool show_search_results) {
// TODO(xiyuan): Highlight default match instead of the first. // TODO(xiyuan): Highlight default match instead of the first.
if (IsNamedPageActive(NAMED_PAGE_SEARCH_RESULTS) && if (IsNamedPageActive(NAMED_PAGE_SEARCH_RESULTS) &&
search_results_view_->visible()) { search_results_view_->visible()) {
...@@ -113,8 +118,12 @@ void ContentsView::ActivePageChanged() { ...@@ -113,8 +118,12 @@ void ContentsView::ActivePageChanged() {
if (search_results_view_) if (search_results_view_)
search_results_view_->UpdateAutoLaunchState(); search_results_view_->UpdateAutoLaunchState();
if (IsNamedPageActive(NAMED_PAGE_START)) if (IsNamedPageActive(NAMED_PAGE_START)) {
start_page_view_->Reset(); if (show_search_results)
start_page_view_->ShowSearchResults();
else
start_page_view_->Reset();
}
// Notify parent AppListMainView of the page change. // Notify parent AppListMainView of the page change.
app_list_main_view_->UpdateSearchBoxVisibility(); app_list_main_view_->UpdateSearchBoxVisibility();
...@@ -127,15 +136,7 @@ void ContentsView::ShowSearchResults(bool show) { ...@@ -127,15 +136,7 @@ void ContentsView::ShowSearchResults(bool show) {
if (app_list::switches::IsExperimentalAppListEnabled()) if (app_list::switches::IsExperimentalAppListEnabled())
new_named_page = NAMED_PAGE_START; new_named_page = NAMED_PAGE_START;
SetActivePage(GetPageIndexForNamedPage(new_named_page)); SetActivePageInternal(GetPageIndexForNamedPage(new_named_page), show);
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 { bool ContentsView::IsShowingSearchResults() const {
......
...@@ -88,8 +88,12 @@ class APP_LIST_EXPORT ContentsView : public views::View { ...@@ -88,8 +88,12 @@ class APP_LIST_EXPORT ContentsView : public views::View {
virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE; virtual bool OnMouseWheel(const ui::MouseWheelEvent& event) OVERRIDE;
private: private:
// Sets the active launcher page, accounting for whether the change is for
// search results.
void SetActivePageInternal(int page_index, bool show_search_results);
// Invoked when active view is changed. // Invoked when active view is changed.
void ActivePageChanged(); void ActivePageChanged(bool show_search_results);
void CalculateIdealBounds(); void CalculateIdealBounds();
void AnimateToIdealBounds(); void AnimateToIdealBounds();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment