summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity <calamity@chromium.org>2014-11-18 00:10:54 -0800
committerCommit bot <commit-bot@chromium.org>2014-11-18 08:11:20 +0000
commit88089f28923c24dbaaac22f6de8cfaa501e3ab0f (patch)
tree6559b24ddf6c59a8ba0e5f255f02afa5fa78d995
parenta3a60d0d590d1dbdcc1f2dbaa11eedaa9a2cf06f (diff)
downloadchromium_src-88089f28923c24dbaaac22f6de8cfaa501e3ab0f.zip
chromium_src-88089f28923c24dbaaac22f6de8cfaa501e3ab0f.tar.gz
chromium_src-88089f28923c24dbaaac22f6de8cfaa501e3ab0f.tar.bz2
Have SearchResultPageView store SearchResultContainerViews.
This CL makes SearchResultPageView store a vector of SearchResultContainerViews rather than managing each type of child view explicitly. This is in preparation of sorting the search views by score. BUG=416756 Review URL: https://codereview.chromium.org/730433002 Cr-Commit-Position: refs/heads/master@{#304576}
-rw-r--r--ui/app_list/views/search_result_page_view.cc33
-rw-r--r--ui/app_list/views/search_result_page_view.h13
2 files changed, 26 insertions, 20 deletions
diff --git a/ui/app_list/views/search_result_page_view.cc b/ui/app_list/views/search_result_page_view.cc
index eea3058..200061e 100644
--- a/ui/app_list/views/search_result_page_view.cc
+++ b/ui/app_list/views/search_result_page_view.cc
@@ -45,36 +45,39 @@ class SearchCardView : public views::View {
} // namespace
SearchResultPageView::SearchResultPageView(AppListMainView* app_list_main_view,
- AppListViewDelegate* view_delegate)
- : results_view_(
- new SearchResultListView(app_list_main_view, view_delegate)),
- tiles_view_(new SearchResultTileItemListView()) {
+ AppListViewDelegate* view_delegate) {
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
kExperimentalWindowPadding, kTopPadding,
kGroupSpacing));
- // The view containing the search results.
- AddChildView(new SearchCardView(results_view_));
-
- // The view containing the start page tiles.
- AddChildView(new SearchCardView(tiles_view_));
-
- AppListModel::SearchResults* model = view_delegate->GetModel()->results();
- results_view_->SetResults(model);
- tiles_view_->SetResults(model);
+ AppListModel::SearchResults* results = view_delegate->GetModel()->results();
+ AddSearchResultContainerView(
+ results, new SearchResultListView(app_list_main_view, view_delegate));
+ AddSearchResultContainerView(results, new SearchResultTileItemListView());
}
SearchResultPageView::~SearchResultPageView() {
}
bool SearchResultPageView::OnKeyPressed(const ui::KeyEvent& event) {
+ DCHECK(!result_container_views_.empty());
// Capture the Tab key to prevent defocusing of the search box.
- return results_view_->OnKeyPressed(event) || event.key_code() == ui::VKEY_TAB;
+ return result_container_views_[0]->OnKeyPressed(event) ||
+ event.key_code() == ui::VKEY_TAB;
}
void SearchResultPageView::ChildPreferredSizeChanged(views::View* child) {
+ DCHECK(!result_container_views_.empty());
Layout();
- results_view_->OnContainerSelected(false);
+ result_container_views_[0]->OnContainerSelected(false);
+}
+
+void SearchResultPageView::AddSearchResultContainerView(
+ AppListModel::SearchResults* results_model,
+ SearchResultContainerView* result_container) {
+ AddChildView(new SearchCardView(result_container));
+ result_container_views_.push_back(result_container);
+ result_container->SetResults(results_model);
}
} // namespace app_list
diff --git a/ui/app_list/views/search_result_page_view.h b/ui/app_list/views/search_result_page_view.h
index 4ea115b..2ca444d 100644
--- a/ui/app_list/views/search_result_page_view.h
+++ b/ui/app_list/views/search_result_page_view.h
@@ -9,15 +9,13 @@
#include "base/memory/weak_ptr.h"
#include "ui/app_list/app_list_export.h"
#include "ui/app_list/app_list_model.h"
-#include "ui/app_list/views/search_result_container_view.h"
#include "ui/views/view.h"
namespace app_list {
class AppListMainView;
class AppListViewDelegate;
-class SearchResultListView;
-class SearchResultTileItemListView;
+class SearchResultContainerView;
// The start page for the experimental app list.
class APP_LIST_EXPORT SearchResultPageView : public views::View {
@@ -31,8 +29,13 @@ class APP_LIST_EXPORT SearchResultPageView : public views::View {
void ChildPreferredSizeChanged(views::View* child) override;
private:
- SearchResultListView* results_view_; // Owned by views hierarchy.
- SearchResultTileItemListView* tiles_view_; // Owned by views hierarchy.
+ void AddSearchResultContainerView(
+ AppListModel::SearchResults* result_model,
+ SearchResultContainerView* result_container);
+
+ // The SearchResultContainerViews that compose the search page. All owned by
+ // the views hierarchy.
+ std::vector<SearchResultContainerView*> result_container_views_;
DISALLOW_COPY_AND_ASSIGN(SearchResultPageView);
};