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

Side by Side 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: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "chrome/browser/ui/app_list/search/app_search_provider.h" 5 #include "chrome/browser/ui/app_list/search/app_search_provider.h"
6 6
7 #include <string> 7 #include <string>
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"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 id_to_app_list_index[top_level_item_list_->item_at(i)->id()] = i; 105 id_to_app_list_index[top_level_item_list_->item_at(i)->id()] = i;
106 } 106 }
107 107
108 for (const App* app : apps_) { 108 for (const App* app : apps_) {
109 scoped_ptr<AppResult> result( 109 scoped_ptr<AppResult> result(
110 new AppResult(profile_, app->app_id(), list_controller_, true)); 110 new AppResult(profile_, app->app_id(), list_controller_, true));
111 result->set_title(app->indexed_name().text()); 111 result->set_title(app->indexed_name().text());
112 112
113 // Use the app list order to tiebreak apps that have never been launched. 113 // Use the app list order to tiebreak apps that have never been launched.
114 if (app->last_launch_time().is_null()) { 114 if (app->last_launch_time().is_null()) {
115 auto it = id_to_app_list_index.find(app->app_id());
116 size_t app_list_index =
Matt Giuca 2015/02/27 06:03:53 // If it's in a folder, it won't be in |id_to_app_
calamity 2015/03/02 00:50:52 Done.
117 it == id_to_app_list_index.end() ? apps_.size() : (*it).second;
118 if (app_list_index > apps_.size())
119 app_list_index = apps_.size();
120
115 result->set_relevance( 121 result->set_relevance(
116 kUnlaunchedAppRelevanceStepSize * 122 kUnlaunchedAppRelevanceStepSize *
117 (apps_.size() - id_to_app_list_index[app->app_id()])); 123 (apps_.size() - app_list_index));
118 } else { 124 } else {
119 result->UpdateFromLastLaunched(clock_->Now(), app->last_launch_time()); 125 result->UpdateFromLastLaunched(clock_->Now(), app->last_launch_time());
120 } 126 }
121 Add(result.Pass()); 127 Add(result.Pass());
122 } 128 }
123 } else { 129 } else {
124 for (const App* app : apps_) { 130 for (const App* app : apps_) {
125 scoped_ptr<AppResult> result( 131 scoped_ptr<AppResult> result(
126 new AppResult(profile_, app->app_id(), list_controller_, false)); 132 new AppResult(profile_, app->app_id(), list_controller_, false));
127 TokenizedStringMatch match; 133 TokenizedStringMatch match;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 RefreshApps(); 186 RefreshApps();
181 if (!update_results_factory_.HasWeakPtrs()) { 187 if (!update_results_factory_.HasWeakPtrs()) {
182 base::MessageLoop::current()->PostTask( 188 base::MessageLoop::current()->PostTask(
183 FROM_HERE, 189 FROM_HERE,
184 base::Bind(&AppSearchProvider::UpdateResults, 190 base::Bind(&AppSearchProvider::UpdateResults,
185 update_results_factory_.GetWeakPtr())); 191 update_results_factory_.GetWeakPtr()));
186 } 192 }
187 } 193 }
188 194
189 } // namespace app_list 195 } // namespace app_list
OLDNEW
« 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