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 21 matching lines...) Expand all Loading... |
32 namespace app_list { | 32 namespace app_list { |
33 | 33 |
34 namespace { | 34 namespace { |
35 | 35 |
36 // Inner padding space in pixels of bubble contents. | 36 // Inner padding space in pixels of bubble contents. |
37 const int kInnerPadding = 1; | 37 const int kInnerPadding = 1; |
38 | 38 |
39 // The maximum allowed time to wait for icon loading in milliseconds. | 39 // The maximum allowed time to wait for icon loading in milliseconds. |
40 const int kMaxIconLoadingWaitTimeInMs = 50; | 40 const int kMaxIconLoadingWaitTimeInMs = 50; |
41 | 41 |
42 const int kContentsViewIndex = 1; | |
43 | |
44 } // namespace | 42 } // namespace |
45 | 43 |
46 //////////////////////////////////////////////////////////////////////////////// | 44 //////////////////////////////////////////////////////////////////////////////// |
47 // AppListMainView::IconLoader | 45 // AppListMainView::IconLoader |
48 | 46 |
49 class AppListMainView::IconLoader : public AppListItemObserver { | 47 class AppListMainView::IconLoader : public AppListItemObserver { |
50 public: | 48 public: |
51 IconLoader(AppListMainView* owner, | 49 IconLoader(AppListMainView* owner, |
52 AppListItem* item, | 50 AppListItem* item, |
53 float scale) | 51 float scale) |
(...skipping 29 matching lines...) Expand all Loading... |
83 //////////////////////////////////////////////////////////////////////////////// | 81 //////////////////////////////////////////////////////////////////////////////// |
84 // AppListMainView: | 82 // AppListMainView: |
85 | 83 |
86 AppListMainView::AppListMainView(AppListViewDelegate* delegate, | 84 AppListMainView::AppListMainView(AppListViewDelegate* delegate, |
87 int initial_apps_page, | 85 int initial_apps_page, |
88 gfx::NativeView parent) | 86 gfx::NativeView parent) |
89 : delegate_(delegate), | 87 : delegate_(delegate), |
90 model_(delegate->GetModel()), | 88 model_(delegate->GetModel()), |
91 search_box_view_(NULL), | 89 search_box_view_(NULL), |
92 contents_view_(NULL), | 90 contents_view_(NULL), |
| 91 contents_switcher_view_(NULL), |
93 weak_ptr_factory_(this) { | 92 weak_ptr_factory_(this) { |
94 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 93 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
95 kInnerPadding, | 94 kInnerPadding, |
96 kInnerPadding, | 95 kInnerPadding, |
97 kInnerPadding)); | 96 kInnerPadding)); |
98 | 97 |
99 search_box_view_ = new SearchBoxView(this, delegate); | 98 search_box_view_ = new SearchBoxView(this, delegate); |
100 AddChildView(search_box_view_); | 99 AddChildView(search_box_view_); |
101 AddContentsView(); | 100 AddContentsViews(); |
102 if (app_list::switches::IsExperimentalAppListEnabled()) | |
103 AddChildView(new ContentsSwitcherView(contents_view_)); | |
104 | 101 |
105 // Switch the apps grid view to the specified page. | 102 // Switch the apps grid view to the specified page. |
106 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); | 103 app_list::PaginationModel* pagination_model = GetAppsPaginationModel(); |
107 if (pagination_model->is_valid_page(initial_apps_page)) | 104 if (pagination_model->is_valid_page(initial_apps_page)) |
108 pagination_model->SelectPage(initial_apps_page, false); | 105 pagination_model->SelectPage(initial_apps_page, false); |
109 | 106 |
110 // Starts icon loading early. | 107 // Starts icon loading early. |
111 PreloadIcons(parent); | 108 PreloadIcons(parent); |
112 } | 109 } |
113 | 110 |
114 void AppListMainView::AddContentsView() { | 111 void AppListMainView::AddContentsViews() { |
115 contents_view_ = new ContentsView(this, model_, delegate_); | 112 contents_view_ = new ContentsView(this, model_, delegate_); |
116 AddChildViewAt(contents_view_, kContentsViewIndex); | 113 AddChildView(contents_view_); |
| 114 if (app_list::switches::IsExperimentalAppListEnabled()) { |
| 115 contents_switcher_view_ = new ContentsSwitcherView(contents_view_); |
| 116 AddChildView(contents_switcher_view_); |
| 117 } |
117 | 118 |
118 search_box_view_->set_contents_view(contents_view_); | 119 search_box_view_->set_contents_view(contents_view_); |
119 | 120 |
120 contents_view_->SetPaintToLayer(true); | 121 contents_view_->SetPaintToLayer(true); |
121 contents_view_->SetFillsBoundsOpaquely(false); | 122 contents_view_->SetFillsBoundsOpaquely(false); |
122 contents_view_->layer()->SetMasksToBounds(true); | 123 contents_view_->layer()->SetMasksToBounds(true); |
123 } | 124 } |
124 | 125 |
125 AppListMainView::~AppListMainView() { | 126 AppListMainView::~AppListMainView() { |
126 pending_icon_loaders_.clear(); | 127 pending_icon_loaders_.clear(); |
(...skipping 30 matching lines...) Expand all Loading... |
157 void AppListMainView::Prerender() { | 158 void AppListMainView::Prerender() { |
158 contents_view_->Prerender(); | 159 contents_view_->Prerender(); |
159 } | 160 } |
160 | 161 |
161 void AppListMainView::ModelChanged() { | 162 void AppListMainView::ModelChanged() { |
162 pending_icon_loaders_.clear(); | 163 pending_icon_loaders_.clear(); |
163 model_ = delegate_->GetModel(); | 164 model_ = delegate_->GetModel(); |
164 search_box_view_->ModelChanged(); | 165 search_box_view_->ModelChanged(); |
165 delete contents_view_; | 166 delete contents_view_; |
166 contents_view_ = NULL; | 167 contents_view_ = NULL; |
167 AddContentsView(); | 168 if (contents_switcher_view_) { |
| 169 delete contents_switcher_view_; |
| 170 contents_switcher_view_ = NULL; |
| 171 } |
| 172 AddContentsViews(); |
168 Layout(); | 173 Layout(); |
169 } | 174 } |
170 | 175 |
171 void AppListMainView::UpdateSearchBoxVisibility() { | 176 void AppListMainView::UpdateSearchBoxVisibility() { |
172 search_box_view_->SetVisible( | 177 search_box_view_->SetVisible( |
173 !contents_view_->IsNamedPageActive(ContentsView::NAMED_PAGE_START) || | 178 !contents_view_->IsNamedPageActive(ContentsView::NAMED_PAGE_START) || |
174 contents_view_->IsShowingSearchResults()); | 179 contents_view_->IsShowingSearchResults()); |
175 } | 180 } |
176 | 181 |
177 void AppListMainView::OnStartPageSearchButtonPressed() { | 182 void AppListMainView::OnStartPageSearchButtonPressed() { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 // Resubmit the query via a posted task so that all observers for the | 290 // Resubmit the query via a posted task so that all observers for the |
286 // uninstall notification are notified. | 291 // uninstall notification are notified. |
287 base::MessageLoop::current()->PostTask( | 292 base::MessageLoop::current()->PostTask( |
288 FROM_HERE, | 293 FROM_HERE, |
289 base::Bind(&AppListMainView::QueryChanged, | 294 base::Bind(&AppListMainView::QueryChanged, |
290 weak_ptr_factory_.GetWeakPtr(), | 295 weak_ptr_factory_.GetWeakPtr(), |
291 search_box_view_)); | 296 search_box_view_)); |
292 } | 297 } |
293 | 298 |
294 } // namespace app_list | 299 } // namespace app_list |
OLD | NEW |