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

Unified Diff: ui/app_list/search/mixer.h

Issue 882463004: app_list: Refactor mixer groups to avoid hard-coded groups in Mixer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@applist-mixer-clamp
Patch Set: Rewrite comments. 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 | « chrome/browser/ui/app_list/search/search_controller_factory.cc ('k') | ui/app_list/search/mixer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/app_list/search/mixer.h
diff --git a/ui/app_list/search/mixer.h b/ui/app_list/search/mixer.h
index 611db2be66be7c250d7093ee54276627707bf580..9380b1164627bc79f046cd71659c492fdfee8c58 100644
--- a/ui/app_list/search/mixer.h
+++ b/ui/app_list/search/mixer.h
@@ -5,12 +5,11 @@
#ifndef UI_APP_LIST_SEARCH_MIXER_H_
#define UI_APP_LIST_SEARCH_MIXER_H_
-#include <map>
#include <vector>
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
-#include "base/memory/linked_ptr.h"
+#include "base/memory/scoped_vector.h"
#include "ui/app_list/app_list_export.h"
#include "ui/app_list/app_list_model.h"
#include "ui/app_list/search/history_types.h"
@@ -26,29 +25,29 @@ class SearchResult;
// Mixer collects results from providers, sorts them and publishes them to the
// SearchResults UI model. The targeted results have 6 slots to hold the
-// result. These slots could be viewed as having three groups: main group
-// (local apps and contacts), omnibox group and web store group. The
-// main group takes no more than 4 slots. The web store takes no more than 2
-// slots. The omnibox group takes all the remaining slots.
+// result. The search controller can specify any number of groups, each with a
+// different number of results and priority boost. The special group with ID
+// OMNIBOX_GROUP is expected to contain omnibox results, and will be treated
+// specially.
class APP_LIST_EXPORT Mixer {
public:
- // The enum represents mixer groups. Each must have a Group added in Init().
- enum GroupId {
- MAIN_GROUP = 0,
- OMNIBOX_GROUP = 1,
- WEBSTORE_GROUP = 2,
- PEOPLE_GROUP = 3,
- SUGGESTIONS_GROUP = 4,
- };
+ // The ID of the omnibox group. The group with this ID will be treated
+ // specially by the Mixer (it will be truncated such that it fills the
+ // remaining slots without overflowing, but with at least one result).
+ // TODO(mgiuca): Omnibox group should not be treated specially.
+ static const size_t OMNIBOX_GROUP;
calamity 2015/04/10 03:34:18 Can we make an omnibox_group_ field that gets set
Matt Giuca 2015/04/10 03:49:19 Done.
explicit Mixer(AppListModel::SearchResults* ui_results);
~Mixer();
- // Creates mixer groups.
- void Init();
+ // Adds a new mixer group. A maximum of |max_results| results will be
+ // displayed from this group (if 0, will allow unlimited results from this
+ // group). Each result in the group will have its score boosted by |boost|.
+ // Returns the group's group_id.
+ size_t AddGroup(size_t max_results, double boost);
// Associates a provider with a mixer group.
- void AddProviderToGroup(GroupId group, SearchProvider* provider);
+ void AddProviderToGroup(size_t group_id, SearchProvider* provider);
// Collects the results, sorts and publishes them.
void MixAndPublish(bool is_voice_query, const KnownResults& known_results);
@@ -69,7 +68,7 @@ class APP_LIST_EXPORT Mixer {
typedef std::vector<Mixer::SortData> SortedResults;
class Group;
- typedef std::map<GroupId, linked_ptr<Group>> Groups;
+ typedef ScopedVector<Group> Groups;
// Publishes the given |new_results| to |ui_results|, deleting any existing
// results that are not in |new_results|. Results that already exist in
« no previous file with comments | « chrome/browser/ui/app_list/search/search_controller_factory.cc ('k') | ui/app_list/search/mixer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698