Index: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm |
diff --git a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm |
index c0f4c134adbfdf8296b77b5930e89e14a1c12ca7..d7204595f08fce6a632e2edfe45f59b3e1866a7f 100644 |
--- a/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm |
+++ b/ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.mm |
@@ -129,6 +129,36 @@ SectionIdentifier SectionIdentifierForInfo( |
[self reloadData]; |
} |
+- (void)clearSuggestion:(ContentSuggestionIdentifier*)suggestionIdentifier { |
+ SectionIdentifier sectionIdentifier = |
+ SectionIdentifierForInfo(suggestionIdentifier.sectionInfo); |
+ if (![self.collectionViewController.collectionViewModel |
+ hasSectionForSectionIdentifier:sectionIdentifier]) { |
+ return; |
+ } |
+ |
+ NSArray<CollectionViewItem<ContentSuggestionIdentification>*>* |
+ itemsInSection = [self.collectionViewController.collectionViewModel |
+ itemsInSectionWithIdentifier:sectionIdentifier]; |
+ |
+ CollectionViewItem<ContentSuggestionIdentification>* correspondingItem = nil; |
+ for (CollectionViewItem<ContentSuggestionIdentification>* item in |
+ itemsInSection) { |
+ if (item.suggestionIdentifier == suggestionIdentifier) { |
+ correspondingItem = item; |
+ break; |
+ } |
+ } |
+ |
+ if (!correspondingItem) |
+ return; |
+ |
+ NSIndexPath* indexPath = [self.collectionViewController.collectionViewModel |
+ indexPathForItem:correspondingItem |
+ inSectionWithIdentifier:sectionIdentifier]; |
+ [self.collectionViewController dismissEntryAtIndexPath:indexPath]; |
+} |
+ |
#pragma mark - Public methods |
- (BOOL)shouldUseCustomStyleForSection:(NSInteger)section { |