[omnibox]: Dedupe clipboard provider classification.

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

Clipboard classification is trivial; i.e. the entirety of the contents
and descriptions are styled uniformly. Descriptions are classified as
NONE. Contents are classified either as URL when the clipboard contains
a URL, as NONE for text, or left empty for images.

This CL changes clipboard classification to use `push_back` instead of
`ClassifyLocationInString`. This is both consistent with other providers
and inline with our goal to deprecate `ClassifyLocationInString` and
other duplicated classification helpers.

Bug: 366623
Change-Id: Ib26c0f079b97817c7b0dbae2f9c2af3ed9ff9ae0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1585965
Commit-Queue: manuk hovanesian <[email protected]>
Reviewed-by: Tommy Li <[email protected]>
Cr-Commit-Position: refs/heads/master@{#655599}
diff --git a/components/omnibox/browser/clipboard_provider.cc b/components/omnibox/browser/clipboard_provider.cc
index 82958e394..bf78f09 100644
--- a/components/omnibox/browser/clipboard_provider.cc
+++ b/components/omnibox/browser/clipboard_provider.cc
@@ -124,7 +124,7 @@
   UMA_HISTOGRAM_LONG_TIMES_100("Omnibox.ClipboardSuggestionShownAge",
                                clipboard_contents_age);
 
-  matches_.emplace_back(match);
+  matches_.push_back(match);
 }
 
 base::Optional<AutocompleteMatch> ClipboardProvider::CreateURLMatch(
@@ -153,14 +153,12 @@
   auto format_types = AutocompleteMatch::GetFormatTypes(false, true);
   match.contents.assign(url_formatter::FormatUrl(
       url, format_types, net::UnescapeRule::SPACES, nullptr, nullptr, nullptr));
-  AutocompleteMatch::ClassifyLocationInString(
-      base::string16::npos, 0, match.contents.length(),
-      ACMatchClassification::URL, &match.contents_class);
+  if (!match.contents.empty())
+    match.contents_class.push_back({0, ACMatchClassification::URL});
 
   match.description.assign(l10n_util::GetStringUTF16(IDS_LINK_FROM_CLIPBOARD));
-  AutocompleteMatch::ClassifyLocationInString(
-      base::string16::npos, 0, match.description.length(),
-      ACMatchClassification::NONE, &match.description_class);
+  if (!match.description.empty())
+    match.description_class.push_back({0, ACMatchClassification::NONE});
 
   return match;
 }
@@ -204,14 +202,12 @@
   match.destination_url = result;
   match.contents.assign(l10n_util::GetStringFUTF16(
       IDS_COPIED_TEXT_FROM_CLIPBOARD, AutocompleteMatch::SanitizeString(text)));
-  AutocompleteMatch::ClassifyLocationInString(
-      base::string16::npos, 0, match.contents.length(),
-      ACMatchClassification::NONE, &match.contents_class);
+  if (!match.contents.empty())
+    match.contents_class.push_back({0, ACMatchClassification::NONE});
 
   match.description.assign(l10n_util::GetStringUTF16(IDS_TEXT_FROM_CLIPBOARD));
-  AutocompleteMatch::ClassifyLocationInString(
-      base::string16::npos, 0, match.description.length(),
-      ACMatchClassification::NONE, &match.description_class);
+  if (!match.description.empty())
+    match.description_class.push_back({0, ACMatchClassification::NONE});
 
   match.keyword = default_url->keyword();
   match.transition = ui::PAGE_TRANSITION_GENERATED;
@@ -285,9 +281,8 @@
                           AutocompleteMatchType::CLIPBOARD_IMAGE);
 
   match.description.assign(l10n_util::GetStringUTF16(IDS_IMAGE_FROM_CLIPBOARD));
-  AutocompleteMatch::ClassifyLocationInString(
-      base::string16::npos, 0, match.description.length(),
-      ACMatchClassification::NONE, &match.description_class);
+  if (!match.description.empty())
+    match.description_class.push_back({0, ACMatchClassification::NONE});
 
   TemplateURLRef::SearchTermsArgs search_args(base::ASCIIToUTF16(""));
   search_args.image_thumbnail_content.assign(image_bytes->front_as<char>(),