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

Unified Diff: components/suggestions/suggestions_service_impl.cc

Issue 2872573002: Use |min| param to query a variable number of suggestions (Closed)
Patch Set: Rebase (blackboxing unittest) Created 3 years, 7 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 | components/suggestions/suggestions_service_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/suggestions/suggestions_service_impl.cc
diff --git a/components/suggestions/suggestions_service_impl.cc b/components/suggestions/suggestions_service_impl.cc
index 407ad4564cff67adc2b0a4960920c1b372b88cfd..aacd400d7b56f7e3188e77bf14ee9cbbaa82b493 100644
--- a/components/suggestions/suggestions_service_impl.cc
+++ b/components/suggestions/suggestions_service_impl.cc
@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
+#include "base/metrics/field_trial_params.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/strings/string_number_conversions.h"
@@ -22,6 +23,7 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/signin/core/browser/signin_manager_base.h"
#include "components/suggestions/blacklist_store.h"
+#include "components/suggestions/features.h"
#include "components/suggestions/image_manager.h"
#include "components/suggestions/suggestions_store.h"
#include "components/sync/driver/sync_service.h"
@@ -82,13 +84,18 @@ GURL GetGoogleBaseURL() {
// Format strings for the various suggestions URLs. They all have two string
// params: The Google base URL and the device type.
// TODO(mathp): Put this in TemplateURL.
-const char kSuggestionsURLFormat[] = "%schromesuggestions?t=%s";
+const char kSuggestionsURLFormat[] = "%schromesuggestions?%s";
const char kSuggestionsBlacklistURLPrefixFormat[] =
"%schromesuggestions/blacklist?t=%s&url=";
const char kSuggestionsBlacklistClearURLFormat[] =
"%schromesuggestions/blacklist/clear?t=%s";
const char kSuggestionsBlacklistURLParam[] = "url";
+const char kSuggestionsDeviceParam[] = "t=%s";
+const char kSuggestionsMinParam[] = "min=%i";
+
+const char kSuggestionsMinVariationName[] = "min_suggestions";
+const int kSuggestionsMinVariationDefault = 0;
#if defined(OS_ANDROID) || defined(OS_IOS)
const char kDeviceType[] = "2";
@@ -105,6 +112,12 @@ const char kFaviconURL[] =
// The default expiry timeout is 168 hours.
const int64_t kDefaultExpiryUsec = 168 * base::Time::kMicrosecondsPerHour;
+int GetMinimumSuggestionsCount() {
+ return base::GetFieldTrialParamByFeatureAsInt(
+ kUseSuggestionsEvenIfFewFeature, kSuggestionsMinVariationName,
+ kSuggestionsMinVariationDefault);
+}
+
} // namespace
SuggestionsServiceImpl::SuggestionsServiceImpl(
@@ -256,8 +269,16 @@ void SuggestionsServiceImpl::RegisterProfilePrefs(
// static
GURL SuggestionsServiceImpl::BuildSuggestionsURL() {
+ std::string device = base::StringPrintf(kSuggestionsDeviceParam, kDeviceType);
+ std::string query = device;
+ if (base::FeatureList::IsEnabled(kUseSuggestionsEvenIfFewFeature)) {
+ std::string min_suggestions =
+ base::StringPrintf(kSuggestionsMinParam, GetMinimumSuggestionsCount());
+ query =
+ base::StringPrintf("%s&%s", device.c_str(), min_suggestions.c_str());
+ }
return GURL(base::StringPrintf(
- kSuggestionsURLFormat, GetGoogleBaseURL().spec().c_str(), kDeviceType));
+ kSuggestionsURLFormat, GetGoogleBaseURL().spec().c_str(), query.c_str()));
}
// static
« no previous file with comments | « no previous file | components/suggestions/suggestions_service_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698