| Index: ui/app_list/search/mixer.cc
|
| diff --git a/ui/app_list/search/mixer.cc b/ui/app_list/search/mixer.cc
|
| index f873780b29a19287ddf1934d4d78b93e48f6a2dd..eeb66ccb351644440d8fce4c0c210bac8e8a69b2 100644
|
| --- a/ui/app_list/search/mixer.cc
|
| +++ b/ui/app_list/search/mixer.cc
|
| @@ -19,10 +19,6 @@ namespace {
|
|
|
| // Maximum number of results to show.
|
| const size_t kMaxResults = 6;
|
| -const size_t kMaxMainGroupResults = 4;
|
| -const size_t kMaxWebstoreResults = 2;
|
| -const size_t kMaxPeopleResults = 2;
|
| -const size_t kMaxSuggestionsResults = 6;
|
|
|
| // A value to indicate no max number of results limit.
|
| const size_t kNoMaxResultsLimit = 0;
|
| @@ -37,6 +33,8 @@ void UpdateResult(const SearchResult& source, SearchResult* target) {
|
|
|
| } // namespace
|
|
|
| +const size_t Mixer::OMNIBOX_GROUP = 1;
|
| +
|
| Mixer::SortData::SortData() : result(NULL), score(0.0) {
|
| }
|
|
|
| @@ -125,16 +123,13 @@ Mixer::Mixer(AppListModel::SearchResults* ui_results)
|
| Mixer::~Mixer() {
|
| }
|
|
|
| -void Mixer::Init() {
|
| - groups_[MAIN_GROUP].reset(new Group(kMaxMainGroupResults, 3.0));
|
| - groups_[OMNIBOX_GROUP].reset(new Group(kNoMaxResultsLimit, 2.0));
|
| - groups_[WEBSTORE_GROUP].reset(new Group(kMaxWebstoreResults, 1.0));
|
| - groups_[PEOPLE_GROUP].reset(new Group(kMaxPeopleResults, 0.0));
|
| - groups_[SUGGESTIONS_GROUP].reset(new Group(kMaxSuggestionsResults, 3.0));
|
| +size_t Mixer::AddGroup(size_t max_results, double boost) {
|
| + groups_.push_back(new Group(max_results, boost));
|
| + return groups_.size() - 1;
|
| }
|
|
|
| -void Mixer::AddProviderToGroup(GroupId group, SearchProvider* provider) {
|
| - groups_[group]->AddProvider(provider);
|
| +void Mixer::AddProviderToGroup(size_t group_id, SearchProvider* provider) {
|
| + groups_[group_id]->AddProvider(provider);
|
| }
|
|
|
| void Mixer::MixAndPublish(bool is_voice_query,
|
| @@ -144,21 +139,14 @@ void Mixer::MixAndPublish(bool is_voice_query,
|
| SortedResults results;
|
| results.reserve(kMaxResults);
|
|
|
| - const Group& main_group = *groups_[MAIN_GROUP];
|
| - const Group& omnibox_group = *groups_[OMNIBOX_GROUP];
|
| - const Group& webstore_group = *groups_[WEBSTORE_GROUP];
|
| - const Group& people_group = *groups_[PEOPLE_GROUP];
|
| - const Group& suggestions_group = *groups_[SUGGESTIONS_GROUP];
|
| -
|
| - // Adds main group and web store results first.
|
| - results.insert(results.end(), main_group.results().begin(),
|
| - main_group.results().end());
|
| - results.insert(results.end(), webstore_group.results().begin(),
|
| - webstore_group.results().end());
|
| - results.insert(results.end(), people_group.results().begin(),
|
| - people_group.results().end());
|
| - results.insert(results.end(), suggestions_group.results().begin(),
|
| - suggestions_group.results().end());
|
| + // Add results from non-omnibox groups first.
|
| + for (size_t i = 0; i < groups_.size(); ++i) {
|
| + if (i != OMNIBOX_GROUP) {
|
| + const Group& group = *groups_[i];
|
| + results.insert(results.end(), group.results().begin(),
|
| + group.results().end());
|
| + }
|
| + }
|
|
|
| // Collapse duplicate apps from local and web store.
|
| RemoveDuplicates(&results);
|
| @@ -166,6 +154,8 @@ void Mixer::MixAndPublish(bool is_voice_query,
|
| // Fill the remaining slots with omnibox results. Always add at least one
|
| // omnibox result (even if there are no more slots; if we over-fill the
|
| // vector, the web store and people results will be removed in a later step).
|
| + CHECK_LT(OMNIBOX_GROUP, groups_.size());
|
| + const Group& omnibox_group = *groups_[OMNIBOX_GROUP];
|
| const size_t omnibox_results =
|
| std::min(omnibox_group.results().size(),
|
| results.size() < kMaxResults ? kMaxResults - results.size() : 1);
|
| @@ -249,8 +239,8 @@ void Mixer::RemoveDuplicates(SortedResults* results) {
|
|
|
| void Mixer::FetchResults(bool is_voice_query,
|
| const KnownResults& known_results) {
|
| - for (const auto& item : groups_)
|
| - item.second->FetchResults(is_voice_query, known_results);
|
| + for (auto* group : groups_)
|
| + group->FetchResults(is_voice_query, known_results);
|
| }
|
|
|
| } // namespace app_list
|
|
|