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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 } | 107 } |
108 | 108 |
109 void AppListMainView::AddContentsViews() { | 109 void AppListMainView::AddContentsViews() { |
110 DCHECK(search_box_view_); | 110 DCHECK(search_box_view_); |
111 | 111 |
112 contents_view_ = new ContentsView(this); | 112 contents_view_ = new ContentsView(this); |
113 if (app_list::switches::IsExperimentalAppListEnabled()) { | 113 if (app_list::switches::IsExperimentalAppListEnabled()) { |
114 contents_switcher_view_ = new ContentsSwitcherView(contents_view_); | 114 contents_switcher_view_ = new ContentsSwitcherView(contents_view_); |
115 contents_view_->SetContentsSwitcherView(contents_switcher_view_); | 115 contents_view_->SetContentsSwitcherView(contents_switcher_view_); |
116 } | 116 } |
117 contents_view_->InitNamedPages(model_, delegate_); | 117 contents_view_->Init(model_, delegate_); |
118 AddChildView(contents_view_); | 118 AddChildView(contents_view_); |
119 if (contents_switcher_view_) | 119 if (contents_switcher_view_) |
120 AddChildView(contents_switcher_view_); | 120 AddChildView(contents_switcher_view_); |
121 | 121 |
122 search_box_view_->set_contents_view(contents_view_); | 122 search_box_view_->set_contents_view(contents_view_); |
123 UpdateSearchBoxVisibility(); | 123 UpdateSearchBoxVisibility(); |
124 | 124 |
125 contents_view_->SetPaintToLayer(true); | 125 contents_view_->SetPaintToLayer(true); |
126 contents_view_->SetFillsBoundsOpaquely(false); | 126 contents_view_->SetFillsBoundsOpaquely(false); |
127 contents_view_->layer()->SetMasksToBounds(true); | 127 contents_view_->layer()->SetMasksToBounds(true); |
(...skipping 12 matching lines...) Expand all Loading... |
140 return; | 140 return; |
141 | 141 |
142 icon_loading_wait_timer_.Start( | 142 icon_loading_wait_timer_.Start( |
143 FROM_HERE, | 143 FROM_HERE, |
144 base::TimeDelta::FromMilliseconds(kMaxIconLoadingWaitTimeInMs), | 144 base::TimeDelta::FromMilliseconds(kMaxIconLoadingWaitTimeInMs), |
145 this, &AppListMainView::OnIconLoadingWaitTimer); | 145 this, &AppListMainView::OnIconLoadingWaitTimer); |
146 } | 146 } |
147 | 147 |
148 void AppListMainView::ResetForShow() { | 148 void AppListMainView::ResetForShow() { |
149 if (switches::IsExperimentalAppListEnabled()) { | 149 if (switches::IsExperimentalAppListEnabled()) { |
150 contents_view_->SetActivePage(contents_view_->GetPageIndexForNamedPage( | 150 contents_view_->SetActivePage( |
151 ContentsView::NAMED_PAGE_START)); | 151 contents_view_->GetPageIndexForState(AppListModel::STATE_START)); |
152 } | 152 } |
153 contents_view_->apps_container_view()->ResetForShowApps(); | 153 contents_view_->apps_container_view()->ResetForShowApps(); |
154 // We clear the search when hiding so when app list appears it is not showing | 154 // We clear the search when hiding so when app list appears it is not showing |
155 // search results. | 155 // search results. |
156 search_box_view_->ClearSearch(); | 156 search_box_view_->ClearSearch(); |
157 } | 157 } |
158 | 158 |
159 void AppListMainView::Close() { | 159 void AppListMainView::Close() { |
160 icon_loading_wait_timer_.Stop(); | 160 icon_loading_wait_timer_.Stop(); |
161 contents_view_->CancelDrag(); | 161 contents_view_->CancelDrag(); |
(...skipping 11 matching lines...) Expand all Loading... |
173 contents_view_ = NULL; | 173 contents_view_ = NULL; |
174 if (contents_switcher_view_) { | 174 if (contents_switcher_view_) { |
175 delete contents_switcher_view_; | 175 delete contents_switcher_view_; |
176 contents_switcher_view_ = NULL; | 176 contents_switcher_view_ = NULL; |
177 } | 177 } |
178 AddContentsViews(); | 178 AddContentsViews(); |
179 Layout(); | 179 Layout(); |
180 } | 180 } |
181 | 181 |
182 void AppListMainView::UpdateSearchBoxVisibility() { | 182 void AppListMainView::UpdateSearchBoxVisibility() { |
183 bool visible = | 183 bool visible = !contents_view_->IsStateActive(AppListModel::STATE_START) || |
184 !contents_view_->IsNamedPageActive(ContentsView::NAMED_PAGE_START) || | 184 contents_view_->IsShowingSearchResults(); |
185 contents_view_->IsShowingSearchResults(); | |
186 search_box_view_->SetVisible(visible); | 185 search_box_view_->SetVisible(visible); |
187 if (visible && GetWidget() && GetWidget()->IsVisible()) | 186 if (visible && GetWidget() && GetWidget()->IsVisible()) |
188 search_box_view_->search_box()->RequestFocus(); | 187 search_box_view_->search_box()->RequestFocus(); |
189 } | 188 } |
190 | 189 |
191 void AppListMainView::OnStartPageSearchTextfieldChanged( | 190 void AppListMainView::OnStartPageSearchTextfieldChanged( |
192 const base::string16& new_contents) { | 191 const base::string16& new_contents) { |
193 search_box_view_->SetVisible(true); | 192 search_box_view_->SetVisible(true); |
194 search_box_view_->search_box()->SetText(new_contents); | 193 search_box_view_->search_box()->SetText(new_contents); |
195 search_box_view_->search_box()->RequestFocus(); | 194 search_box_view_->search_box()->RequestFocus(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Resubmit the query via a posted task so that all observers for the | 304 // Resubmit the query via a posted task so that all observers for the |
306 // uninstall notification are notified. | 305 // uninstall notification are notified. |
307 base::MessageLoop::current()->PostTask( | 306 base::MessageLoop::current()->PostTask( |
308 FROM_HERE, | 307 FROM_HERE, |
309 base::Bind(&AppListMainView::QueryChanged, | 308 base::Bind(&AppListMainView::QueryChanged, |
310 weak_ptr_factory_.GetWeakPtr(), | 309 weak_ptr_factory_.GetWeakPtr(), |
311 search_box_view_)); | 310 search_box_view_)); |
312 } | 311 } |
313 | 312 |
314 } // namespace app_list | 313 } // namespace app_list |
OLD | NEW |