| OLD | NEW | 
|    1 // Copyright 2013 The Chromium Authors. All rights reserved. |    1 // Copyright 2013 The Chromium Authors. All rights reserved. | 
|    2 // Use of this source code is governed by a BSD-style license that can be |    2 // Use of this source code is governed by a BSD-style license that can be | 
|    3 // found in the LICENSE file. |    3 // found in the LICENSE file. | 
|    4  |    4  | 
|    5 #include "ui/app_list/views/app_list_main_view.h" |    5 #include "ui/app_list/views/app_list_main_view.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8  |    8  | 
|    9 #include "base/bind.h" |    9 #include "base/bind.h" | 
|   10 #include "base/callback.h" |   10 #include "base/callback.h" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
|   37 #include "ui/views/controls/textfield/textfield.h" |   37 #include "ui/views/controls/textfield/textfield.h" | 
|   38 #include "ui/views/layout/box_layout.h" |   38 #include "ui/views/layout/box_layout.h" | 
|   39 #include "ui/views/layout/fill_layout.h" |   39 #include "ui/views/layout/fill_layout.h" | 
|   40 #include "ui/views/widget/widget.h" |   40 #include "ui/views/widget/widget.h" | 
|   41  |   41  | 
|   42 namespace app_list { |   42 namespace app_list { | 
|   43  |   43  | 
|   44 //////////////////////////////////////////////////////////////////////////////// |   44 //////////////////////////////////////////////////////////////////////////////// | 
|   45 // AppListMainView: |   45 // AppListMainView: | 
|   46  |   46  | 
|   47 AppListMainView::AppListMainView(AppListViewDelegate* delegate) |   47 AppListMainView::AppListMainView(AppListViewDelegate* delegate, | 
 |   48                                  AppListView* app_list_view) | 
|   48     : delegate_(delegate), |   49     : delegate_(delegate), | 
|   49       model_(delegate->GetModel()), |   50       model_(delegate->GetModel()), | 
|   50       search_box_view_(nullptr), |   51       search_box_view_(nullptr), | 
|   51       contents_view_(nullptr) { |   52       contents_view_(nullptr), | 
 |   53       app_list_view_(app_list_view) { | 
|   52   SetLayoutManager( |   54   SetLayoutManager( | 
|   53       features::IsAnswerCardEnabled() |   55       features::IsAnswerCardEnabled() | 
|   54           ? static_cast<views::LayoutManager*>(new views::FillLayout) |   56           ? static_cast<views::LayoutManager*>(new views::FillLayout) | 
|   55           : static_cast<views::LayoutManager*>(new views::BoxLayout( |   57           : static_cast<views::LayoutManager*>(new views::BoxLayout( | 
|   56                 views::BoxLayout::kVertical, gfx::Insets(), 0))); |   58                 views::BoxLayout::kVertical, gfx::Insets(), 0))); | 
|   57   model_->AddObserver(this); |   59   model_->AddObserver(this); | 
|   58 } |   60 } | 
|   59  |   61  | 
|   60 AppListMainView::~AppListMainView() { |   62 AppListMainView::~AppListMainView() { | 
|   61   model_->RemoveObserver(this); |   63   model_->RemoveObserver(this); | 
|   62 } |   64 } | 
|   63  |   65  | 
|   64 void AppListMainView::Init(gfx::NativeView parent, |   66 void AppListMainView::Init(gfx::NativeView parent, | 
|   65                            int initial_apps_page, |   67                            int initial_apps_page, | 
|   66                            SearchBoxView* search_box_view) { |   68                            SearchBoxView* search_box_view) { | 
|   67   search_box_view_ = search_box_view; |   69   search_box_view_ = search_box_view; | 
|   68   AddContentsViews(); |   70   AddContentsViews(); | 
|   69  |   71  | 
|   70   // Switch the apps grid view to the specified page. |   72   // Switch the apps grid view to the specified page. | 
|   71   app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); |   73   app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); | 
|   72   if (pagination_model->is_valid_page(initial_apps_page)) |   74   if (pagination_model->is_valid_page(initial_apps_page)) | 
|   73     pagination_model->SelectPage(initial_apps_page, false); |   75     pagination_model->SelectPage(initial_apps_page, false); | 
|   74  |   76  | 
|   75   OnSearchEngineIsGoogleChanged(model_->search_engine_is_google()); |   77   OnSearchEngineIsGoogleChanged(model_->search_engine_is_google()); | 
|   76 } |   78 } | 
|   77  |   79  | 
|   78 void AppListMainView::AddContentsViews() { |   80 void AppListMainView::AddContentsViews() { | 
|   79   DCHECK(search_box_view_); |   81   DCHECK(search_box_view_); | 
|   80  |   82   contents_view_ = new ContentsView(this, app_list_view_); | 
|   81   contents_view_ = new ContentsView(this); |  | 
|   82   contents_view_->Init(model_); |   83   contents_view_->Init(model_); | 
|   83   AddChildView(contents_view_); |   84   AddChildView(contents_view_); | 
|   84  |   85  | 
|   85   search_box_view_->set_contents_view(contents_view_); |   86   search_box_view_->set_contents_view(contents_view_); | 
|   86  |   87  | 
|   87   contents_view_->SetPaintToLayer(); |   88   contents_view_->SetPaintToLayer(); | 
|   88   contents_view_->layer()->SetFillsBoundsOpaquely(false); |   89   contents_view_->layer()->SetFillsBoundsOpaquely(false); | 
|   89   contents_view_->layer()->SetMasksToBounds(true); |   90   contents_view_->layer()->SetMasksToBounds(true); | 
|   90  |   91  | 
|   91   // Clear the old query and start search. |   92   // Clear the old query and start search. | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  214     contents_view_->search_results_page_view()->SetSelection(select); |  215     contents_view_->search_results_page_view()->SetSelection(select); | 
|  215 } |  216 } | 
|  216  |  217  | 
|  217 void AppListMainView::OnResultInstalled(SearchResult* result) { |  218 void AppListMainView::OnResultInstalled(SearchResult* result) { | 
|  218   // Clears the search to show the apps grid. The last installed app |  219   // Clears the search to show the apps grid. The last installed app | 
|  219   // should be highlighted and made visible already. |  220   // should be highlighted and made visible already. | 
|  220   search_box_view_->ClearSearch(); |  221   search_box_view_->ClearSearch(); | 
|  221 } |  222 } | 
|  222  |  223  | 
|  223 }  // namespace app_list |  224 }  // namespace app_list | 
| OLD | NEW |