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

Unified Diff: chrome/browser/ui/app_list/search/app_search_provider.cc

Issue 954363002: Fix sort order of unlaunched apps on app list start page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_start_page_context_and_logs
Patch Set: address comment Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/app_search_provider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/search/app_search_provider.cc
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index b81afa693e3c73a6c31565274c3f14b41eee3799..5009b3aaad9aaff9d2cb7af5a3bf7561dde5f12c 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -112,9 +112,16 @@ void AppSearchProvider::UpdateResults() {
// Use the app list order to tiebreak apps that have never been launched.
if (app->last_launch_time().is_null()) {
- result->set_relevance(
- kUnlaunchedAppRelevanceStepSize *
- (apps_.size() - id_to_app_list_index[app->app_id()]));
+ auto it = id_to_app_list_index.find(app->app_id());
+ // If it's in a folder, it won't be in |id_to_app_list_index|. Rank
+ // those as if they are at the end of the list.
+ size_t app_list_index =
+ it == id_to_app_list_index.end() ? apps_.size() : (*it).second;
+ if (app_list_index > apps_.size())
+ app_list_index = apps_.size();
+
+ result->set_relevance(kUnlaunchedAppRelevanceStepSize *
+ (apps_.size() - app_list_index));
} else {
result->UpdateFromLastLaunched(clock_->Now(), app->last_launch_time());
}
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/search/app_search_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698