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

Unified Diff: chrome/browser/omnibox/omnibox_field_trial.cc

Issue 55413002: Don't demote top match for certain match types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Peter's comments Created 7 years, 1 month 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
Index: chrome/browser/omnibox/omnibox_field_trial.cc
diff --git a/chrome/browser/omnibox/omnibox_field_trial.cc b/chrome/browser/omnibox/omnibox_field_trial.cc
index e2c7144101483c2a6f0528524ec7d2854d086458..6b9510b623d526f1e7907b4750832b896f2eb825 100644
--- a/chrome/browser/omnibox/omnibox_field_trial.cc
+++ b/chrome/browser/omnibox/omnibox_field_trial.cc
@@ -254,7 +254,7 @@ void OmniboxFieldTrial::GetDemotionsByType(
for (base::StringPairs::const_iterator it = kv_pairs.begin();
it != kv_pairs.end(); ++it) {
// This is a best-effort conversion; we trust the hand-crafted parameters
- // downloaded from the server to be perfect. There's no need for handle
+ // downloaded from the server to be perfect. There's no need to handle
// errors smartly.
int k, v;
base::StringToInt(it->first, &k);
@@ -265,6 +265,32 @@ void OmniboxFieldTrial::GetDemotionsByType(
}
}
+OmniboxFieldTrial::UndemotableTopMatchTypes
+OmniboxFieldTrial::GetUndemotableTopTypes(
+ AutocompleteInput::PageClassification current_page_classification) {
+ UndemotableTopMatchTypes undemotable_types;
+ const std::string types_rule =
+ OmniboxFieldTrial::GetValueForRuleInContext(
+ kUndemotableTopTypeRule,
+ current_page_classification);
+ // The value of the UndemotableTopTypes rule is a comma-separated list of
+ // AutocompleteMatchType::Type enums represented as an integer. The
+ // DemoteByType rule does not apply to the top match if the type of the top
+ // match is in this list.
+ std::vector<std::string> types;
+ base::SplitString(types_rule, ',', &types);
+ for (std::vector<std::string>::const_iterator it = types.begin();
+ it != types.end(); ++it) {
+ // 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.
+ int t;
+ base::StringToInt(*it, &t);
+ undemotable_types.insert(static_cast<AutocompleteMatchType::Type>(t));
+ }
+ return undemotable_types;
+}
+
bool OmniboxFieldTrial::ReorderForLegalDefaultMatch(
AutocompleteInput::PageClassification current_page_classification) {
return OmniboxFieldTrial::GetValueForRuleInContext(
@@ -278,6 +304,7 @@ const char OmniboxFieldTrial::kShortcutsScoringMaxRelevanceRule[] =
"ShortcutsScoringMaxRelevance";
const char OmniboxFieldTrial::kSearchHistoryRule[] = "SearchHistory";
const char OmniboxFieldTrial::kDemoteByTypeRule[] = "DemoteByType";
+const char OmniboxFieldTrial::kUndemotableTopTypeRule[] = "UndemotableTopTypes";
const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRule[] =
"ReorderForLegalDefaultMatch";
const char OmniboxFieldTrial::kReorderForLegalDefaultMatchRuleEnabled[] =
« no previous file with comments | « chrome/browser/omnibox/omnibox_field_trial.h ('k') | chrome/browser/omnibox/omnibox_field_trial_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698