[omnibox]: Dedupe zeroSuggest provider classification.
This is the 11th refactoring CL aimed at reducing duplication and
inconsistency for classifying omnibox results.
ZeroSuggest suggestions to not match user text or bold their texts.
Their contents are styled URL; their descriptions are styled NONE.
Previously, `ClassifyLocationInString` was invoked with trivial
parameters in order to create these length 1 (or length 0 for empty
text) classifications.
With this CL, we instead use the recent `ClassifyTermMatches` method.
This doesn't reduce complexity but helps moves towards using the same
methods for all providers' classifications.
Bug: 366623
Change-Id: Ie91c6b595776c5d46bb4f6700a938216dea2bbd4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1573811
Reviewed-by: Tommy Li <[email protected]>
Commit-Queue: manuk hovanesian <[email protected]>
Cr-Commit-Position: refs/heads/master@{#652532}
diff --git a/components/omnibox/browser/zero_suggest_provider.cc b/components/omnibox/browser/zero_suggest_provider.cc
index ca1f05e..9fa7588 100644
--- a/components/omnibox/browser/zero_suggest_provider.cc
+++ b/components/omnibox/browser/zero_suggest_provider.cc
@@ -27,6 +27,7 @@
#include "components/omnibox/browser/autocomplete_classifier.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_match.h"
+#include "components/omnibox/browser/autocomplete_match_classification.h"
#include "components/omnibox/browser/autocomplete_provider_listener.h"
#include "components/omnibox/browser/contextual_suggestions_service.h"
#include "components/omnibox/browser/history_url_provider.h"
@@ -382,25 +383,24 @@
navigation.type());
match.destination_url = navigation.url();
- // Zero suggest results should always omit protocols and never appear bold.
- auto format_types = AutocompleteMatch::GetFormatTypes(false, false);
- match.contents = url_formatter::FormatUrl(navigation.url(), format_types,
- net::UnescapeRule::SPACES, nullptr,
- nullptr, nullptr);
match.fill_into_edit +=
AutocompleteInput::FormattedStringWithEquivalentMeaning(
navigation.url(), url_formatter::FormatUrl(navigation.url()),
client()->GetSchemeClassifier(), nullptr);
- AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
- match.contents.length(), ACMatchClassification::URL,
- &match.contents_class);
+ // Zero suggest results should always omit protocols and never appear bold.
+ auto format_types = AutocompleteMatch::GetFormatTypes(false, false);
+ match.contents = url_formatter::FormatUrl(navigation.url(), format_types,
+ net::UnescapeRule::SPACES, nullptr,
+ nullptr, nullptr);
+ match.contents_class = ClassifyTermMatches({}, match.contents.length(), 0,
+ ACMatchClassification::URL);
match.description =
AutocompleteMatch::SanitizeString(navigation.description());
- AutocompleteMatch::ClassifyLocationInString(base::string16::npos, 0,
- match.description.length(), ACMatchClassification::NONE,
- &match.description_class);
+ match.description_class = ClassifyTermMatches({}, match.description.length(),
+ 0, ACMatchClassification::NONE);
+
match.subtype_identifier = navigation.subtype_identifier();
return match;
}