| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont
roller.h" | 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_view_cont
roller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" | 8 #import "ios/chrome/browser/ui/collection_view/cells/MDCCollectionViewCell+Chrom
e.h" |
| 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" | 9 #import "ios/chrome/browser/ui/collection_view/cells/collection_view_item.h" |
| 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" | 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 #pragma mark - UICollectionViewDelegate | 66 #pragma mark - UICollectionViewDelegate |
| 67 | 67 |
| 68 - (void)collectionView:(UICollectionView*)collectionView | 68 - (void)collectionView:(UICollectionView*)collectionView |
| 69 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { | 69 didSelectItemAtIndexPath:(NSIndexPath*)indexPath { |
| 70 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; | 70 [super collectionView:collectionView didSelectItemAtIndexPath:indexPath]; |
| 71 | 71 |
| 72 CollectionViewItem* item = | 72 CollectionViewItem* item = |
| 73 [self.collectionViewModel itemAtIndexPath:indexPath]; | 73 [self.collectionViewModel itemAtIndexPath:indexPath]; |
| 74 switch (item.type) { | 74 switch ([self.collectionUpdater contentSuggestionTypeForItem:item]) { |
| 75 case ItemTypeStack: | 75 case ContentSuggestionTypeArticle: |
| 76 [self.suggestionCommandHandler openReadingList]; | |
| 77 break; | |
| 78 case ItemTypeArticle: | |
| 79 [self openArticle:item]; | 76 [self openArticle:item]; |
| 80 break; | 77 break; |
| 81 default: | |
| 82 break; | |
| 83 } | 78 } |
| 84 } | 79 } |
| 85 | 80 |
| 86 #pragma mark - ContentSuggestionsExpandableCellDelegate | 81 #pragma mark - ContentSuggestionsExpandableCellDelegate |
| 87 | 82 |
| 88 - (void)collapseCell:(UICollectionViewCell*)cell { | 83 - (void)collapseCell:(UICollectionViewCell*)cell { |
| 89 [self expand:NO cell:cell]; | 84 [self expand:NO cell:cell]; |
| 90 } | 85 } |
| 91 | 86 |
| 92 - (void)expandCell:(UICollectionViewCell*)cell { | 87 - (void)expandCell:(UICollectionViewCell*)cell { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 } | 174 } |
| 180 } | 175 } |
| 181 | 176 |
| 182 - (void)openArticle:(CollectionViewItem*)item { | 177 - (void)openArticle:(CollectionViewItem*)item { |
| 183 ContentSuggestionsArticleItem* article = | 178 ContentSuggestionsArticleItem* article = |
| 184 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(item); | 179 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(item); |
| 185 [self.suggestionCommandHandler openURL:article.articleURL]; | 180 [self.suggestionCommandHandler openURL:article.articleURL]; |
| 186 } | 181 } |
| 187 | 182 |
| 188 @end | 183 @end |
| OLD | NEW |