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

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

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 | « no previous file | ui/app_list/search/mixer.h » ('j') | ui/app_list/search/mixer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/search/search_controller_factory.cc
diff --git a/chrome/browser/ui/app_list/search/search_controller_factory.cc b/chrome/browser/ui/app_list/search/search_controller_factory.cc
index d1a5a2c4caab4d04b2a1d8ea4f4fc6163c0eba60..6bdfdd8bb57e4845fcbd45eeef42c55bf548abf1 100644
--- a/chrome/browser/ui/app_list/search/search_controller_factory.cc
+++ b/chrome/browser/ui/app_list/search/search_controller_factory.cc
@@ -23,6 +23,13 @@ namespace app_list {
namespace {
+// Maximum number of results to show in each mixer group.
+const size_t kMaxAppsGroupResults = 4;
+const size_t kMaxOmniboxResults = 0; // Unlimited.
+const size_t kMaxWebstoreResults = 2;
+const size_t kMaxPeopleResults = 2;
+const size_t kMaxSuggestionsResults = 6;
+
// Constants related to the SuggestionsService in AppList field trial.
const char kSuggestionsProviderFieldTrialName[] = "SuggestionsAppListProvider";
const char kSuggestionsProviderFieldTrialEnabledPrefix[] = "Enabled";
@@ -45,22 +52,37 @@ scoped_ptr<SearchController> CreateSearchController(
scoped_ptr<SearchController> controller(new SearchController(
search_box, results, HistoryFactory::GetForBrowserContext(profile)));
- controller->AddProvider(Mixer::MAIN_GROUP,
+ // Add mixer groups. There are four main groups: apps, people, webstore and
+ // omnibox. The apps, people and webstore groups each have a fixed maximum
+ // number of results. The omnibox group fills the remaining slots (with a
+ // minimum of one result).
+ size_t apps_group_id = controller->AddGroup(kMaxAppsGroupResults, 3.0);
+ size_t omnibox_group_id = controller->AddGroup(kMaxOmniboxResults, 2.0);
+ size_t webstore_group_id = controller->AddGroup(kMaxWebstoreResults, 1.0);
+ size_t people_group_id = controller->AddGroup(kMaxPeopleResults, 0.0);
+ // The omnibox group is treated specially by the Mixer and must have the
+ // correct ID.
+ DCHECK_EQ(omnibox_group_id, Mixer::OMNIBOX_GROUP);
+
+ // Add search providers.
+ controller->AddProvider(apps_group_id,
scoped_ptr<SearchProvider>(new AppSearchProvider(
profile, list_controller,
make_scoped_ptr(new base::DefaultClock()))));
- controller->AddProvider(Mixer::OMNIBOX_GROUP,
+ controller->AddProvider(omnibox_group_id,
scoped_ptr<SearchProvider>(
new OmniboxProvider(profile, list_controller)));
- controller->AddProvider(Mixer::WEBSTORE_GROUP,
+ controller->AddProvider(webstore_group_id,
scoped_ptr<SearchProvider>(
new WebstoreProvider(profile, list_controller)));
controller->AddProvider(
- Mixer::PEOPLE_GROUP,
+ people_group_id,
scoped_ptr<SearchProvider>(new PeopleProvider(profile, list_controller)));
if (IsSuggestionsSearchProviderEnabled()) {
+ size_t suggestions_group_id =
+ controller->AddGroup(kMaxSuggestionsResults, 3.0);
controller->AddProvider(
- Mixer::SUGGESTIONS_GROUP,
+ suggestions_group_id,
scoped_ptr<SearchProvider>(
new SuggestionsSearchProvider(profile, list_controller)));
}
« no previous file with comments | « no previous file | ui/app_list/search/mixer.h » ('j') | ui/app_list/search/mixer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698