Commit cd8989eb authored by manuk's avatar manuk Committed by Commit Bot

[omnibox]: Dedupe keyword provider classification.

This is the 12th refactoring CL aimed at reducing duplication and
inconsistency for classifying omnibox results.

Keyword classification is trivial; i.e. the entirety of the contents and
description are styled uniformly. Descriptions are styled DIM. Contents
are styled 1) DIM (when the user input includes only the keyword), 2)
NONE (when the user input contains text following the keyword), or 3)
MATCH (when the user input contains only the keyword and the keyword has
no replacement text).

This CL changes contents classification in case (3) to use
`emplace_back` instead of `ClassifyLocationInString`. This is both
consistent with how the other cases are handled and inline with our goal
to deprecate `ClassifyLocationInString` and other duplicated
classification helpers.

Bug: 366623
Change-Id: I205a7bea19391d6343bc071574797f9a0f61c324
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1579763Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Commit-Queue: manuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#653410}
parent 157ac591
...@@ -505,16 +505,14 @@ void KeywordProvider::FillInURLAndContents( ...@@ -505,16 +505,14 @@ void KeywordProvider::FillInURLAndContents(
// No query input; return a generic, no-destination placeholder. // No query input; return a generic, no-destination placeholder.
match->contents.assign( match->contents.assign(
l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)); l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE));
match->contents_class.push_back( match->contents_class.emplace_back(0, ACMatchClassification::DIM);
ACMatchClassification(0, ACMatchClassification::DIM));
} else { } else {
// Keyword or extension that has no replacement text (aka a shorthand for // Keyword or extension that has no replacement text (aka a shorthand for
// a URL). // a URL).
match->destination_url = GURL(element->url()); match->destination_url = GURL(element->url());
match->contents.assign(element->short_name()); match->contents.assign(element->short_name());
AutocompleteMatch::ClassifyLocationInString(0, match->contents.length(), if (!element->short_name().empty())
match->contents.length(), ACMatchClassification::NONE, match->contents_class.emplace_back(0, ACMatchClassification::MATCH);
&match->contents_class);
} }
} else { } else {
// Create destination URL by escaping user input and substituting into // Create destination URL by escaping user input and substituting into
...@@ -529,8 +527,7 @@ void KeywordProvider::FillInURLAndContents( ...@@ -529,8 +527,7 @@ void KeywordProvider::FillInURLAndContents(
match->destination_url = GURL(element_ref.ReplaceSearchTerms( match->destination_url = GURL(element_ref.ReplaceSearchTerms(
search_terms_args, GetTemplateURLService()->search_terms_data())); search_terms_args, GetTemplateURLService()->search_terms_data()));
match->contents = remaining_input; match->contents = remaining_input;
match->contents_class.push_back( match->contents_class.emplace_back(0, ACMatchClassification::NONE);
ACMatchClassification(0, ACMatchClassification::NONE));
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment