[go: nahoru, domu]

[iOS][Omnibox] Fix most visited tiles description class

New autocomplete match are created when extracting most visited tiles in
omnibox popup mediator. Currently, the created match is not valid, since
there is a description but no description_class associated to it.

This CL adds the description_class associated to the description and
add the Validate() method to ensure a valid match. Validate() is only defined when DCHECK is on.

Bug: None
Change-Id: I4a5b68e7b74f8ee9809ab044f782cd61869d7029
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4935475
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Stepan Khapugin <stkhapugin@chromium.org>
Auto-Submit: Christian Xu <christianxu@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1209408}
diff --git a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm
index 7c1bb12..cfb2300 100644
--- a/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm
+++ b/ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.mm
@@ -18,6 +18,7 @@
 #import "components/omnibox/browser/autocomplete_controller.h"
 #import "components/omnibox/browser/autocomplete_input.h"
 #import "components/omnibox/browser/autocomplete_match.h"
+#import "components/omnibox/browser/autocomplete_match_classification.h"
 #import "components/omnibox/browser/autocomplete_result.h"
 #import "components/omnibox/browser/remote_suggestions_service.h"
 #import "components/omnibox/common/omnibox_features.h"
@@ -483,6 +484,11 @@
         tileMatch.destination_url = tile.url;
         tileMatch.fill_into_edit = base::UTF8ToUTF16(tile.url.spec());
         tileMatch.description = tile.title;
+        tileMatch.description_class = ClassifyTermMatches(
+            {}, tileMatch.description.length(), 0, ACMatchClassification::NONE);
+#if DCHECK_IS_ON()
+        tileMatch.Validate();
+#endif  // DCHECK_IS_ON()
         AutocompleteMatchFormatter* formatter =
             [self wrapMatch:tileMatch fromResult:autocompleteResult];
         [wrappedMatches addObject:formatter];