Chromium Code Reviews| 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 a310d8d436f443841dbb21307a26053d1fdb965d..89ab61ba3e397b2cd843758acf7f2a78da88b8ed 100644 |
| --- a/ui/app_list/views/contents_view.cc |
| +++ b/ui/app_list/views/contents_view.cc |
| @@ -17,57 +17,24 @@ |
| #include "ui/app_list/views/apps_grid_view.h" |
| #include "ui/app_list/views/custom_launcher_page_view.h" |
| #include "ui/app_list/views/search_box_view.h" |
| +#include "ui/app_list/views/search_result_answer_card_view.h" |
| #include "ui/app_list/views/search_result_list_view.h" |
| #include "ui/app_list/views/search_result_page_view.h" |
| #include "ui/app_list/views/search_result_tile_item_list_view.h" |
| #include "ui/app_list/views/start_page_view.h" |
| #include "ui/events/event.h" |
| #include "ui/resources/grit/ui_resources.h" |
| -#include "ui/views/layout/box_layout.h" |
| #include "ui/views/view_model.h" |
| #include "ui/views/widget/widget.h" |
| namespace app_list { |
| -namespace { |
| - |
| -// Container of the search answer view. |
| -class SearchAnswerContainerView : public views::View { |
| - public: |
| - explicit SearchAnswerContainerView(views::View* search_results_page_view) |
| - : search_results_page_view_(search_results_page_view) { |
| - views::BoxLayout* answer_container_layout = |
| - new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); |
| - answer_container_layout->set_main_axis_alignment( |
| - views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
| - SetLayoutManager(answer_container_layout); |
| - } |
| - |
| - // views::View overrides: |
| - void ChildPreferredSizeChanged(View* child) override { |
| - if (visible()) |
| - search_results_page_view_->Layout(); |
| - } |
| - |
| - const char* GetClassName() const override { |
| - return "SearchAnswerContainerView"; |
| - } |
| - |
| - private: |
| - views::View* const search_results_page_view_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(SearchAnswerContainerView); |
| -}; |
| - |
| -} // namespace |
| - |
| ContentsView::ContentsView(AppListMainView* app_list_main_view) |
| : model_(nullptr), |
| apps_container_view_(nullptr), |
| search_results_page_view_(nullptr), |
| start_page_view_(nullptr), |
| custom_page_view_(nullptr), |
| - search_answer_container_view_(nullptr), |
| app_list_main_view_(app_list_main_view), |
| page_before_search_(0) { |
| pagination_model_.SetTransitionDurations(kPageTransitionDurationInMs, |
| @@ -77,8 +44,6 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view) |
| ContentsView::~ContentsView() { |
| pagination_model_.RemoveObserver(this); |
| - if (model_) |
| - model_->RemoveObserver(this); |
| } |
| void ContentsView::Init(AppListModel* model) { |
| @@ -105,14 +70,14 @@ void ContentsView::Init(AppListModel* model) { |
| // Search results UI. |
| search_results_page_view_ = new SearchResultPageView(); |
| - // Search answer container UI. |
| - search_answer_container_view_ = |
| - new SearchAnswerContainerView(search_results_page_view_); |
| - search_answer_container_view_->SetVisible(false); |
| - views::View* search_answer_view = view_delegate->GetSearchAnswerWebView(); |
| - if (search_answer_view) |
| - search_answer_container_view_->AddChildView(search_answer_view); |
| - search_results_page_view_->AddChildView(search_answer_container_view_); |
| + // Search result containers. |
| + views::View* const search_answer_view = |
| + view_delegate->GetSearchAnswerWebView(); |
| + if (search_answer_view) { |
| + search_results_page_view_->AddSearchResultContainerView( |
| + nullptr, new SearchResultAnswerCardView( |
|
xiyuan
2017/05/25 16:42:53
nullptr looks strange. Can we following the existi
vadimt
2017/05/25 20:15:16
This is more readable, as this container doesn't u
|
| + model_, search_results_page_view_, search_answer_view)); |
| + } |
| AppListModel::SearchResults* results = view_delegate->GetModel()->results(); |
| search_results_page_view_->AddSearchResultContainerView( |
| @@ -143,8 +108,6 @@ void ContentsView::Init(AppListModel* model) { |
| pagination_model_.SelectPage(initial_page_index, false); |
| ActivePageChanged(); |
| - |
| - model_->AddObserver(this); |
| } |
| void ContentsView::CancelDrag() { |
| @@ -525,12 +488,4 @@ void ContentsView::TransitionChanged() { |
| UpdatePageBounds(); |
| } |
| -void ContentsView::OnSearchAnswerAvailableChanged(bool has_answer) { |
| - if (has_answer == search_answer_container_view_->visible()) |
| - return; |
| - |
| - search_answer_container_view_->SetVisible(has_answer); |
| - search_results_page_view_->Layout(); |
| -} |
| - |
| } // namespace app_list |