Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: ui/app_list/views/search_result_list_view.cc

Issue 439703002: Allow app list tiles to show search results in the experimental app list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix merge Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/app_list/views/app_list_view_unittest.cc ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/search_result_list_view.h" 5 #include "ui/app_list/views/search_result_list_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/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "third_party/skia/include/core/SkColor.h" 12 #include "third_party/skia/include/core/SkColor.h"
13 #include "ui/app_list/app_list_switches.h" 13 #include "ui/app_list/app_list_switches.h"
14 #include "ui/app_list/app_list_view_delegate.h" 14 #include "ui/app_list/app_list_view_delegate.h"
15 #include "ui/app_list/search_result.h"
15 #include "ui/app_list/views/search_result_list_view_delegate.h" 16 #include "ui/app_list/views/search_result_list_view_delegate.h"
16 #include "ui/app_list/views/search_result_view.h" 17 #include "ui/app_list/views/search_result_view.h"
17 #include "ui/events/event.h" 18 #include "ui/events/event.h"
18 #include "ui/gfx/animation/linear_animation.h" 19 #include "ui/gfx/animation/linear_animation.h"
19 #include "ui/views/background.h" 20 #include "ui/views/background.h"
20 #include "ui/views/layout/box_layout.h" 21 #include "ui/views/layout/box_layout.h"
21 22
22 namespace { 23 namespace {
23 24
24 const int kMaxResults = 6; 25 const int kMaxResults = 6;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 SetAutoLaunchTimeout(base::TimeDelta()); 157 SetAutoLaunchTimeout(base::TimeDelta());
157 view_delegate_->AutoLaunchCanceled(); 158 view_delegate_->AutoLaunchCanceled();
158 } 159 }
159 160
160 SearchResultView* SearchResultListView::GetResultViewAt(int index) { 161 SearchResultView* SearchResultListView::GetResultViewAt(int index) {
161 DCHECK(index >= 0 && index < results_container_->child_count()); 162 DCHECK(index >= 0 && index < results_container_->child_count());
162 return static_cast<SearchResultView*>(results_container_->child_at(index)); 163 return static_cast<SearchResultView*>(results_container_->child_at(index));
163 } 164 }
164 165
165 void SearchResultListView::Update() { 166 void SearchResultListView::Update() {
166 last_visible_index_ = 0; 167 std::vector<SearchResult*> display_results =
168 AppListModel::FilterSearchResultsByDisplayType(
169 results_,
170 SearchResult::DISPLAY_LIST,
171 results_container_->child_count());
172 last_visible_index_ = display_results.size() - 1;
173
167 for (size_t i = 0; i < static_cast<size_t>(results_container_->child_count()); 174 for (size_t i = 0; i < static_cast<size_t>(results_container_->child_count());
168 ++i) { 175 ++i) {
169 SearchResultView* result_view = GetResultViewAt(i); 176 SearchResultView* result_view = GetResultViewAt(i);
170 if (i < results_->item_count()) { 177 if (i < display_results.size()) {
171 result_view->SetResult(results_->GetItemAt(i)); 178 result_view->SetResult(display_results[i]);
172 result_view->SetVisible(true); 179 result_view->SetVisible(true);
173 last_visible_index_ = i;
174 } else { 180 } else {
175 result_view->SetResult(NULL); 181 result_view->SetResult(NULL);
176 result_view->SetVisible(false); 182 result_view->SetVisible(false);
177 } 183 }
178 } 184 }
179 if (selected_index_ > last_visible_index_) 185 if (selected_index_ > last_visible_index_)
180 SetSelectedIndex(last_visible_index_); 186 SetSelectedIndex(last_visible_index_);
181 187
182 Layout(); 188 Layout();
183 update_factory_.InvalidateWeakPtrs(); 189 update_factory_.InvalidateWeakPtrs();
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 if (delegate_ && view->result()) 289 if (delegate_ && view->result())
284 delegate_->OnResultInstalled(view->result()); 290 delegate_->OnResultInstalled(view->result());
285 } 291 }
286 292
287 void SearchResultListView::OnSearchResultUninstalled(SearchResultView* view) { 293 void SearchResultListView::OnSearchResultUninstalled(SearchResultView* view) {
288 if (delegate_ && view->result()) 294 if (delegate_ && view->result())
289 delegate_->OnResultUninstalled(view->result()); 295 delegate_->OnResultUninstalled(view->result());
290 } 296 }
291 297
292 } // namespace app_list 298 } // namespace app_list
OLDNEW
« no previous file with comments | « ui/app_list/views/app_list_view_unittest.cc ('k') | ui/app_list/views/start_page_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698