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

Unified Diff: ui/app_list/views/start_page_view.cc

Issue 2605463003: Fix the Crash in the launcher's start page on Chrome OS. (Closed)
Patch Set: Address xiyuan@'s comments. Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/views/start_page_view.cc
diff --git a/ui/app_list/views/start_page_view.cc b/ui/app_list/views/start_page_view.cc
index 0bac15b7b2ab6f8edd0963a7683af447347acb52..b0d2c5dfbad8e29af73eb6ff846c1dcbb52e188b 100644
--- a/ui/app_list/views/start_page_view.cc
+++ b/ui/app_list/views/start_page_view.cc
@@ -172,25 +172,28 @@ TileItemView* StartPageView::StartPageTilesContainer::GetTileItemView(
}
int StartPageView::StartPageTilesContainer::Update() {
+ std::vector<SearchResult*> display_results =
+ AppListModel::FilterSearchResultsByDisplayType(
+ results(), SearchResult::DISPLAY_RECOMMENDATION, kNumStartPageTiles);
+
// Ignore updates and disable buttons when transitioning to a different
// state.
if (contents_view_->GetActiveState() != AppListModel::STATE_START) {
for (auto* view : search_result_tile_views_)
view->SetEnabled(false);
- return num_results();
+ // We still need to update the number: add 1 to the results size to account
+ // for the all apps button.
+ return display_results.size() + 1;
xiyuan 2017/01/03 17:05:13 Not sure whether this is the right thing to do. We
xdai1 2017/01/03 19:15:41 Emmm... In this case the approach in the first pat
}
- std::vector<SearchResult*> display_results =
- AppListModel::FilterSearchResultsByDisplayType(
- results(), SearchResult::DISPLAY_RECOMMENDATION, kNumStartPageTiles);
if (display_results.size() != search_result_tile_views_.size()) {
// We should recreate the grid layout in this case.
for (size_t i = 0; i < search_result_tile_views_.size(); ++i)
delete search_result_tile_views_[i];
search_result_tile_views_.clear();
RemoveChildView(all_apps_button_);
- CreateAppsGrid(std::min(kNumStartPageTiles, display_results.size()));
xiyuan 2017/01/03 17:05:14 Would this change have side effect that we might d
xdai1 2017/01/03 19:15:41 The maximum number of |display_results| is kNumSta
+ CreateAppsGrid(display_results.size());
}
// Update the tile item results.
@@ -211,10 +214,10 @@ int StartPageView::StartPageTilesContainer::Update() {
void StartPageView::StartPageTilesContainer::UpdateSelectedIndex(
int old_selected,
int new_selected) {
- if (old_selected >= 0)
+ if (old_selected >= 0 && old_selected < num_results())
GetTileItemView(old_selected)->SetSelected(false);
- if (new_selected >= 0)
+ if (new_selected >= 0 && new_selected < num_results())
GetTileItemView(new_selected)->SetSelected(true);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698