Chromium Code Reviews| Index: ios/chrome/browser/ui/collection_view/collection_view_model.mm |
| diff --git a/ios/chrome/browser/ui/collection_view/collection_view_model.mm b/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
| index 0866b37bdafde7636ef71ab9c88f608417224f14..460091ffc9a7435bbbc74e89834abac1689c72fa 100644 |
| --- a/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
| +++ b/ios/chrome/browser/ui/collection_view/collection_view_model.mm |
| @@ -267,6 +267,25 @@ typedef NSMutableArray<CollectionViewItem*> SectionItems; |
| return [NSIndexPath indexPathForItem:itemIndex inSection:section]; |
| } |
| +- (BOOL)hasItem:(CollectionViewItem*)item { |
| + for (SectionItems* sectionItems in _sections) { |
| + if ([sectionItems indexOfObject:item] != NSNotFound) |
| + return YES; |
| + } |
| + return NO; |
| +} |
| + |
| +- (NSIndexPath*)indexPathForItem:(CollectionViewItem*)item { |
| + for (NSUInteger section = 0; section < [_sections count]; section++) { |
| + NSInteger itemIndex = [_sections[section] indexOfObject:item]; |
| + if (itemIndex != NSNotFound) { |
| + return [NSIndexPath indexPathForItem:itemIndex inSection:section]; |
| + } |
| + } |
| + DCHECK(NO); |
|
lpromero
2017/03/22 14:04:22
Use NOTREACHED.
|
| + return nil; |
| +} |
| + |
| #pragma mark UICollectionView data sourcing |
| - (NSInteger)numberOfSections { |