Chromium Code Reviews| Index: components/omnibox/browser/omnibox_field_trial.cc |
| diff --git a/components/omnibox/browser/omnibox_field_trial.cc b/components/omnibox/browser/omnibox_field_trial.cc |
| index 378027ff0bc2748b7e25fac1086ed2b30034d053..b17929f111fdc7159e5fd28140e21ae2c18a209c 100644 |
| --- a/components/omnibox/browser/omnibox_field_trial.cc |
| +++ b/components/omnibox/browser/omnibox_field_trial.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/feature_list.h" |
| #include "base/metrics/field_trial.h" |
| #include "base/metrics/field_trial_params.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "base/strings/string_number_conversions.h" |
| #include "base/strings/string_split.h" |
| #include "base/strings/string_util.h" |
| @@ -797,3 +798,61 @@ std::string OmniboxFieldTrial::GetValueForRuleInContext( |
| it = params.find(rule + ":*:*"); |
| return (it != params.end()) ? it->second : std::string(); |
| } |
| + |
| +namespace { |
| + |
| +static const char* kContextualZeroSuggests[] = {"" /*type is not set*/, |
| + "cooccurrence_pages", |
|
Mark P
2017/03/14 20:17:49
If we keep the human-readable names (and maybe if
gcomanici
2017/03/14 20:42:55
Can you CC somebody that can do this? Or, should I
Mark P
2017/03/14 21:04:09
I can help do this once we have a concrete proposa
gcomanici
2017/03/15 01:35:56
SG
|
| + "hivemind_urls", |
| + "local_store-maps", |
| + "local_store-webpage", |
| + "local_store-reservation", |
| + "movie_reviews-review", |
| + "movie_reviews-showtimes", |
| + "on_the_news", |
| + "popular_domains", |
| + "similar_pages", |
| + "top_entity_info", |
| + "other"}; |
| +} |
| + |
| +// static |
| +std::string OmniboxFieldTrial::ContextualZeroSuggest::ToString( |
| + const Type& type) { |
| + static_assert( |
| + arraysize(kContextualZeroSuggests) == ContextualZeroSuggest::NUM_TYPES, |
| + "kContextualZeroSuggests array must have NUM_TYPES elements"); |
| + return kContextualZeroSuggests[type]; |
| +} |
| + |
| +// static |
| +OmniboxFieldTrial::ContextualZeroSuggest::Type |
| +OmniboxFieldTrial::ContextualZeroSuggest::FromString(const std::string& type) { |
| + if (type.empty()) |
| + return NOT_SET; |
| + for (int i = 0; i < NUM_TYPES; ++i) { |
| + if (kContextualZeroSuggests[i] == type) { |
| + return (Type)i; |
| + } |
| + } |
| + return OTHER; |
| +} |
| + |
| +// static |
| +void OmniboxFieldTrial::ContextualZeroSuggest::RecordTypeAsProvided( |
| + const std::string& type_as_string) { |
| + const auto type = FromString(type_as_string); |
| + if (type != NOT_SET) |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "ZeroSuggest.ContextualSuggestType.SuggestionProvided", type, |
| + NUM_TYPES); |
| +} |
| + |
| +// static |
| +void OmniboxFieldTrial::ContextualZeroSuggest::RecordTypeAsUsed( |
| + const std::string& type_as_string) { |
| + const auto type = FromString(type_as_string); |
| + if (type != NOT_SET) |
| + UMA_HISTOGRAM_ENUMERATION( |
| + "ZeroSuggest.ContextualSuggestType.SuggestionUsed", type, NUM_TYPES); |
| +} |