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

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

Issue 2905523004: Making answer card to behave like other results. (Closed)
Patch Set: Fixing build breakage. Created 3 years, 7 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') | ui/app_list/views/search_result_answer_card_view.h » ('j') | 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 aad11258e7689f7a86aed7a4545fb07ffe878bc6..bb8218bac9fae36adb5582ce4ed57db2839ca9d4 100644
--- a/ui/app_list/views/contents_view.cc
+++ b/ui/app_list/views/contents_view.cc
@@ -17,56 +17,23 @@
#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/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,
@@ -76,8 +43,6 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view)
ContentsView::~ContentsView() {
pagination_model_.RemoveObserver(this);
- if (model_)
- model_->RemoveObserver(this);
}
void ContentsView::Init(AppListModel* model) {
@@ -104,14 +69,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(
+ model_, search_results_page_view_, search_answer_view));
+ }
AppListModel::SearchResults* results = view_delegate->GetModel()->results();
search_results_page_view_->AddSearchResultContainerView(
@@ -142,8 +107,6 @@ void ContentsView::Init(AppListModel* model) {
pagination_model_.SelectPage(initial_page_index, false);
ActivePageChanged();
-
- model_->AddObserver(this);
}
void ContentsView::CancelDrag() {
@@ -524,12 +487,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
« no previous file with comments | « ui/app_list/views/contents_view.h ('k') | ui/app_list/views/search_result_answer_card_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698