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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 void AppListMainView::GetShortcutPathForApp( | 246 void AppListMainView::GetShortcutPathForApp( |
247 const std::string& app_id, | 247 const std::string& app_id, |
248 const base::Callback<void(const base::FilePath&)>& callback) { | 248 const base::Callback<void(const base::FilePath&)>& callback) { |
249 delegate_->GetShortcutPathForApp(app_id, callback); | 249 delegate_->GetShortcutPathForApp(app_id, callback); |
250 } | 250 } |
251 | 251 |
252 void AppListMainView::QueryChanged(SearchBoxView* sender) { | 252 void AppListMainView::QueryChanged(SearchBoxView* sender) { |
253 base::string16 query; | 253 base::string16 query; |
254 base::TrimWhitespace(model_->search_box()->text(), base::TRIM_ALL, &query); | 254 base::TrimWhitespace(model_->search_box()->text(), base::TRIM_ALL, &query); |
255 bool should_show_search = !query.empty(); | 255 bool should_show_search = !query.empty(); |
256 contents_view_->ShowSearchResults(should_show_search); | 256 |
| 257 ContentsView::ShowState show_state = ContentsView::SHOW_SEARCH_RESULTS; |
| 258 if (!should_show_search) { |
| 259 show_state = app_list::switches::IsExperimentalAppListEnabled() |
| 260 ? ContentsView::SHOW_START_PAGE |
| 261 : ContentsView::SHOW_APPS; |
| 262 } |
| 263 contents_view_->SetShowState(show_state); |
257 | 264 |
258 if (should_show_search) | 265 if (should_show_search) |
259 delegate_->StartSearch(); | 266 delegate_->StartSearch(); |
260 else | 267 else |
261 delegate_->StopSearch(); | 268 delegate_->StopSearch(); |
262 } | 269 } |
263 | 270 |
264 void AppListMainView::OnResultInstalled(SearchResult* result) { | 271 void AppListMainView::OnResultInstalled(SearchResult* result) { |
265 // Clears the search to show the apps grid. The last installed app | 272 // Clears the search to show the apps grid. The last installed app |
266 // should be highlighted and made visible already. | 273 // should be highlighted and made visible already. |
267 search_box_view_->ClearSearch(); | 274 search_box_view_->ClearSearch(); |
268 } | 275 } |
269 | 276 |
270 void AppListMainView::OnResultUninstalled(SearchResult* result) { | 277 void AppListMainView::OnResultUninstalled(SearchResult* result) { |
271 // Resubmit the query via a posted task so that all observers for the | 278 // Resubmit the query via a posted task so that all observers for the |
272 // uninstall notification are notified. | 279 // uninstall notification are notified. |
273 base::MessageLoop::current()->PostTask( | 280 base::MessageLoop::current()->PostTask( |
274 FROM_HERE, | 281 FROM_HERE, |
275 base::Bind(&AppListMainView::QueryChanged, | 282 base::Bind(&AppListMainView::QueryChanged, |
276 weak_ptr_factory_.GetWeakPtr(), | 283 weak_ptr_factory_.GetWeakPtr(), |
277 search_box_view_)); | 284 search_box_view_)); |
278 } | 285 } |
279 | 286 |
280 } // namespace app_list | 287 } // namespace app_list |
OLD | NEW |