| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 void AppListMainView::ModelChanged() { | 161 void AppListMainView::ModelChanged() { |
| 162 pending_icon_loaders_.clear(); | 162 pending_icon_loaders_.clear(); |
| 163 model_ = delegate_->GetModel(); | 163 model_ = delegate_->GetModel(); |
| 164 search_box_view_->ModelChanged(); | 164 search_box_view_->ModelChanged(); |
| 165 delete contents_view_; | 165 delete contents_view_; |
| 166 contents_view_ = NULL; | 166 contents_view_ = NULL; |
| 167 AddContentsView(); | 167 AddContentsView(); |
| 168 Layout(); | 168 Layout(); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void AppListMainView::OnContentsViewActivePageChanged() { | 171 void AppListMainView::UpdateSearchBoxVisibility() { |
| 172 search_box_view_->SetVisible( | 172 search_box_view_->SetVisible( |
| 173 !contents_view_->IsNamedPageActive(ContentsView::NAMED_PAGE_START)); | 173 !contents_view_->IsNamedPageActive(ContentsView::NAMED_PAGE_START) || |
| 174 contents_view_->IsShowingSearchResults()); |
| 174 } | 175 } |
| 175 | 176 |
| 176 void AppListMainView::OnStartPageSearchButtonPressed() { | 177 void AppListMainView::OnStartPageSearchButtonPressed() { |
| 177 search_box_view_->SetVisible(true); | 178 search_box_view_->SetVisible(true); |
| 178 search_box_view_->search_box()->SetText(base::string16()); | 179 search_box_view_->search_box()->SetText(base::string16()); |
| 179 search_box_view_->RequestFocus(); | 180 search_box_view_->RequestFocus(); |
| 180 } | 181 } |
| 181 | 182 |
| 182 void AppListMainView::SetDragAndDropHostOfCurrentAppList( | 183 void AppListMainView::SetDragAndDropHostOfCurrentAppList( |
| 183 ApplicationDragAndDropHost* drag_and_drop_host) { | 184 ApplicationDragAndDropHost* drag_and_drop_host) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 const std::string& app_id, | 260 const std::string& app_id, |
| 260 const base::Callback<void(const base::FilePath&)>& callback) { | 261 const base::Callback<void(const base::FilePath&)>& callback) { |
| 261 delegate_->GetShortcutPathForApp(app_id, callback); | 262 delegate_->GetShortcutPathForApp(app_id, callback); |
| 262 } | 263 } |
| 263 | 264 |
| 264 void AppListMainView::QueryChanged(SearchBoxView* sender) { | 265 void AppListMainView::QueryChanged(SearchBoxView* sender) { |
| 265 base::string16 query; | 266 base::string16 query; |
| 266 base::TrimWhitespace(model_->search_box()->text(), base::TRIM_ALL, &query); | 267 base::TrimWhitespace(model_->search_box()->text(), base::TRIM_ALL, &query); |
| 267 bool should_show_search = !query.empty(); | 268 bool should_show_search = !query.empty(); |
| 268 contents_view_->ShowSearchResults(should_show_search); | 269 contents_view_->ShowSearchResults(should_show_search); |
| 270 UpdateSearchBoxVisibility(); |
| 269 | 271 |
| 270 if (should_show_search) | 272 if (should_show_search) |
| 271 delegate_->StartSearch(); | 273 delegate_->StartSearch(); |
| 272 else | 274 else |
| 273 delegate_->StopSearch(); | 275 delegate_->StopSearch(); |
| 274 } | 276 } |
| 275 | 277 |
| 276 void AppListMainView::OnResultInstalled(SearchResult* result) { | 278 void AppListMainView::OnResultInstalled(SearchResult* result) { |
| 277 // Clears the search to show the apps grid. The last installed app | 279 // Clears the search to show the apps grid. The last installed app |
| 278 // should be highlighted and made visible already. | 280 // should be highlighted and made visible already. |
| 279 search_box_view_->ClearSearch(); | 281 search_box_view_->ClearSearch(); |
| 280 } | 282 } |
| 281 | 283 |
| 282 void AppListMainView::OnResultUninstalled(SearchResult* result) { | 284 void AppListMainView::OnResultUninstalled(SearchResult* result) { |
| 283 // Resubmit the query via a posted task so that all observers for the | 285 // Resubmit the query via a posted task so that all observers for the |
| 284 // uninstall notification are notified. | 286 // uninstall notification are notified. |
| 285 base::MessageLoop::current()->PostTask( | 287 base::MessageLoop::current()->PostTask( |
| 286 FROM_HERE, | 288 FROM_HERE, |
| 287 base::Bind(&AppListMainView::QueryChanged, | 289 base::Bind(&AppListMainView::QueryChanged, |
| 288 weak_ptr_factory_.GetWeakPtr(), | 290 weak_ptr_factory_.GetWeakPtr(), |
| 289 search_box_view_)); | 291 search_box_view_)); |
| 290 } | 292 } |
| 291 | 293 |
| 292 } // namespace app_list | 294 } // namespace app_list |
| OLD | NEW |