| 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 cbcf6f6c652608ac671e6122705442e1a3457401..a848adff70b458b2043c8c3f64cd4d863d05df80 100644
|
| --- a/components/omnibox/browser/omnibox_field_trial.cc
|
| +++ b/components/omnibox/browser/omnibox_field_trial.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include "components/omnibox/browser/omnibox_field_trial.h"
|
|
|
| +#include <algorithm>
|
| #include <cmath>
|
| #include <string>
|
|
|
| @@ -443,6 +444,28 @@ float OmniboxFieldTrial::HQPTypedValue() {
|
| return typed_value;
|
| }
|
|
|
| +OmniboxFieldTrial::NumMatchesScores OmniboxFieldTrial::HQPNumMatchesScores() {
|
| + std::string str = variations::GetVariationParamValue(
|
| + kBundledExperimentFieldTrialName, kHQPNumMatchesScoresRule);
|
| + // The parameter is a comma-separated list of (number, value) pairs, e.g.
|
| + // "1:3,2:2.5,3:2,4:1.5".
|
| + // This is a best-effort conversion; we trust the hand-crafted parameters
|
| + // downloaded from the server to be perfect. There's no need to handle
|
| + // errors smartly.
|
| + base::StringPairs kv_pairs;
|
| + if (!base::SplitStringIntoKeyValuePairs(str, ':', ',', &kv_pairs))
|
| + return NumMatchesScores{};
|
| + NumMatchesScores num_matches_scores(kv_pairs.size());
|
| + for (size_t i = 0; i < kv_pairs.size(); ++i) {
|
| + base::StringToSizeT(kv_pairs[i].first, &num_matches_scores[i].first);
|
| + // The input must be sorted by number of matches.
|
| + DCHECK((i == 0) ||
|
| + (num_matches_scores[i].first > num_matches_scores[i - 1].first));
|
| + base::StringToDouble(kv_pairs[i].second, &num_matches_scores[i].second);
|
| + }
|
| + return num_matches_scores;
|
| +}
|
| +
|
| size_t OmniboxFieldTrial::HQPNumTitleWordsToAllow() {
|
| // The value of the rule is a string that encodes an integer (actually
|
| // size_t) containing the number of words.
|
| @@ -548,6 +571,8 @@ const char OmniboxFieldTrial::kHQPFixFewVisitsBugRule[] = "HQPFixFewVisitsBug";
|
| const char OmniboxFieldTrial::kHQPFreqencyUsesSumRule[] = "HQPFreqencyUsesSum";
|
| const char OmniboxFieldTrial::kHQPMaxVisitsToScoreRule[] =
|
| "HQPMaxVisitsToScoreRule";
|
| +const char OmniboxFieldTrial::kHQPNumMatchesScoresRule[] =
|
| + "HQPNumMatchesScores";
|
| const char OmniboxFieldTrial::kHQPNumTitleWordsRule[] = "HQPNumTitleWords";
|
| const char OmniboxFieldTrial::kHQPAlsoDoHUPLikeScoringRule[] =
|
| "HQPAlsoDoHUPLikeScoring";
|
|
|