| 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 a1489168ca873bae768e17c7828c5141e2453aba..cc7a8113ac083a193b388689a02712c752252d67 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
|
| @@ -14,6 +14,8 @@
|
| #import "ios/chrome/browser/ui/collection_view/collection_view_model.h"
|
| #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_article_item.h"
|
| #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_footer_item.h"
|
| +#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited.h"
|
| +#import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_most_visited_item.h"
|
| #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_reading_list_item.h"
|
| #import "ios/chrome/browser/ui/content_suggestions/cells/content_suggestions_text_item.h"
|
| #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h"
|
| @@ -236,16 +238,19 @@ SectionIdentifier SectionIdentifierForInfo(
|
| return [NSArray array];
|
| }
|
|
|
| + NSMutableArray<ContentSuggestionsMostVisited*>* mostVisitedToAdd =
|
| + [NSMutableArray array];
|
| +
|
| + CSCollectionViewModel* model =
|
| + self.collectionViewController.collectionViewModel;
|
| NSMutableArray<NSIndexPath*>* indexPaths = [NSMutableArray array];
|
| for (ContentSuggestion* suggestion in suggestions) {
|
| ContentSuggestionsSectionInformation* sectionInfo =
|
| suggestion.suggestionIdentifier.sectionInfo;
|
| NSInteger sectionIdentifier = SectionIdentifierForInfo(sectionInfo);
|
| - CSCollectionViewModel* model =
|
| - self.collectionViewController.collectionViewModel;
|
|
|
| if (![model hasSectionForSectionIdentifier:sectionIdentifier])
|
| - return [NSArray array];
|
| + continue;
|
|
|
| NSInteger section = [model sectionForSectionIdentifier:sectionIdentifier];
|
| NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:section];
|
| @@ -288,12 +293,37 @@ SectionIdentifier SectionIdentifierForInfo(
|
| break;
|
| }
|
| case ContentSuggestionTypeMostVisited: {
|
| - // TODO(crbug.com/707754): Add the most visited item.
|
| + NSInteger section =
|
| + [model sectionForSectionIdentifier:SectionIdentifierMostVisited];
|
| + NSIndexPath* indexPath =
|
| + [NSIndexPath indexPathForItem:0 inSection:section];
|
| +
|
| + if ([model numberOfItemsInSection:section] == 0) {
|
| + [model addItem:[[ContentSuggestionsMostVisitedItem alloc]
|
| + initWithType:ItemTypeMostVisited]
|
| + toSectionWithIdentifier:SectionIdentifierMostVisited];
|
| + [indexPaths addObject:indexPath];
|
| + }
|
| +
|
| + ContentSuggestionsMostVisited* mostVisited =
|
| + [ContentSuggestionsMostVisited mostVisitedWithTitle:suggestion.title
|
| + attributes:nil];
|
| + [mostVisitedToAdd addObject:mostVisited];
|
| break;
|
| }
|
| }
|
| }
|
|
|
| + if ([model hasSectionForSectionIdentifier:SectionIdentifierMostVisited]) {
|
| + NSInteger section =
|
| + [model sectionForSectionIdentifier:SectionIdentifierMostVisited];
|
| + NSIndexPath* indexPath = [NSIndexPath indexPathForItem:0 inSection:section];
|
| + ContentSuggestionsMostVisitedItem* item =
|
| + base::mac::ObjCCast<ContentSuggestionsMostVisitedItem>(
|
| + [model itemAtIndexPath:indexPath]);
|
| + item.suggestions = mostVisitedToAdd;
|
| + }
|
| +
|
| return indexPaths;
|
| }
|
|
|
|
|