Chromium Code Reviews| 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..7a2cccae3571d57964c26e6911b4cb8fbe0af25f 100644 |
| --- a/components/suggestions/suggestions_service_impl.cc |
| +++ b/components/suggestions/suggestions_service_impl.cc |
| @@ -22,10 +22,12 @@ |
| #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" |
| #include "components/variations/net/variations_http_headers.h" |
| +#include "components/variations/variations_associated_data.h" |
| #include "google_apis/gaia/gaia_constants.h" |
| #include "google_apis/gaia/oauth2_token_service.h" |
| #include "net/base/escape.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 variations::GetVariationParamByFeatureAsInt( |
|
Marc Treib
2017/05/10 12:32:24
This is deprecated, you should use base::GetFieldT
fhorschig
2017/05/10 12:45:34
Used 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 |