| 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) |  | 
|   49     : delegate_(delegate), |   48     : delegate_(delegate), | 
|   50       model_(delegate->GetModel()), |   49       model_(delegate->GetModel()), | 
|   51       search_box_view_(nullptr), |   50       search_box_view_(nullptr), | 
|   52       contents_view_(nullptr), |   51       contents_view_(nullptr) { | 
|   53       app_list_view_(app_list_view) { |  | 
|   54   SetLayoutManager( |   52   SetLayoutManager( | 
|   55       features::IsAnswerCardEnabled() |   53       features::IsAnswerCardEnabled() | 
|   56           ? static_cast<views::LayoutManager*>(new views::FillLayout) |   54           ? static_cast<views::LayoutManager*>(new views::FillLayout) | 
|   57           : static_cast<views::LayoutManager*>(new views::BoxLayout( |   55           : static_cast<views::LayoutManager*>(new views::BoxLayout( | 
|   58                 views::BoxLayout::kVertical, gfx::Insets(), 0))); |   56                 views::BoxLayout::kVertical, gfx::Insets(), 0))); | 
|   59   model_->AddObserver(this); |   57   model_->AddObserver(this); | 
|   60 } |   58 } | 
|   61  |   59  | 
|   62 AppListMainView::~AppListMainView() { |   60 AppListMainView::~AppListMainView() { | 
|   63   model_->RemoveObserver(this); |   61   model_->RemoveObserver(this); | 
|   64 } |   62 } | 
|   65  |   63  | 
|   66 void AppListMainView::Init(gfx::NativeView parent, |   64 void AppListMainView::Init(gfx::NativeView parent, | 
|   67                            int initial_apps_page, |   65                            int initial_apps_page, | 
|   68                            SearchBoxView* search_box_view) { |   66                            SearchBoxView* search_box_view) { | 
|   69   search_box_view_ = search_box_view; |   67   search_box_view_ = search_box_view; | 
|   70   AddContentsViews(); |   68   AddContentsViews(); | 
|   71  |   69  | 
|   72   // Switch the apps grid view to the specified page. |   70   // Switch the apps grid view to the specified page. | 
|   73   app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); |   71   app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); | 
|   74   if (pagination_model->is_valid_page(initial_apps_page)) |   72   if (pagination_model->is_valid_page(initial_apps_page)) | 
|   75     pagination_model->SelectPage(initial_apps_page, false); |   73     pagination_model->SelectPage(initial_apps_page, false); | 
|   76  |   74  | 
|   77   OnSearchEngineIsGoogleChanged(model_->search_engine_is_google()); |   75   OnSearchEngineIsGoogleChanged(model_->search_engine_is_google()); | 
|   78 } |   76 } | 
|   79  |   77  | 
|   80 void AppListMainView::AddContentsViews() { |   78 void AppListMainView::AddContentsViews() { | 
|   81   DCHECK(search_box_view_); |   79   DCHECK(search_box_view_); | 
|   82   contents_view_ = new ContentsView(this, app_list_view_); |   80  | 
 |   81   contents_view_ = new ContentsView(this); | 
|   83   contents_view_->Init(model_); |   82   contents_view_->Init(model_); | 
|   84   AddChildView(contents_view_); |   83   AddChildView(contents_view_); | 
|   85  |   84  | 
|   86   search_box_view_->set_contents_view(contents_view_); |   85   search_box_view_->set_contents_view(contents_view_); | 
|   87  |   86  | 
|   88   contents_view_->SetPaintToLayer(); |   87   contents_view_->SetPaintToLayer(); | 
|   89   contents_view_->layer()->SetFillsBoundsOpaquely(false); |   88   contents_view_->layer()->SetFillsBoundsOpaquely(false); | 
|   90   contents_view_->layer()->SetMasksToBounds(true); |   89   contents_view_->layer()->SetMasksToBounds(true); | 
|   91  |   90  | 
|   92   // Clear the old query and start search. |   91   // Clear the old query and start search. | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  215     contents_view_->search_results_page_view()->SetSelection(select); |  214     contents_view_->search_results_page_view()->SetSelection(select); | 
|  216 } |  215 } | 
|  217  |  216  | 
|  218 void AppListMainView::OnResultInstalled(SearchResult* result) { |  217 void AppListMainView::OnResultInstalled(SearchResult* result) { | 
|  219   // Clears the search to show the apps grid. The last installed app |  218   // Clears the search to show the apps grid. The last installed app | 
|  220   // should be highlighted and made visible already. |  219   // should be highlighted and made visible already. | 
|  221   search_box_view_->ClearSearch(); |  220   search_box_view_->ClearSearch(); | 
|  222 } |  221 } | 
|  223  |  222  | 
|  224 }  // namespace app_list |  223 }  // namespace app_list | 
| OLD | NEW |