| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return; | 59 return; |
| 60 } | 60 } |
| 61 | 61 |
| 62 [self.collectionView performBatchUpdates:^{ | 62 [self.collectionView performBatchUpdates:^{ |
| 63 [self collectionView:self.collectionView | 63 [self collectionView:self.collectionView |
| 64 willDeleteItemsAtIndexPaths:@[ indexPath ]]; | 64 willDeleteItemsAtIndexPaths:@[ indexPath ]]; |
| 65 | 65 |
| 66 [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; | 66 [self.collectionView deleteItemsAtIndexPaths:@[ indexPath ]]; |
| 67 } | 67 } |
| 68 completion:^(BOOL) { | 68 completion:^(BOOL) { |
| 69 // The context menu could be displayed for the delete entry. | 69 // The context menu could be displayed for the deleted entry. |
| 70 [self.suggestionCommandHandler dismissContextMenu]; | 70 [self.suggestionCommandHandler dismissContextMenu]; |
| 71 }]; | 71 }]; |
| 72 } | 72 } |
| 73 |
| 74 - (void)dismissSection:(NSInteger)section { |
| 75 if (section >= [self numberOfSectionsInCollectionView:self.collectionView]) { |
| 76 return; |
| 77 } |
| 78 |
| 79 NSInteger sectionIdentifier = |
| 80 [self.collectionViewModel sectionIdentifierForSection:section]; |
| 81 |
| 82 [self.collectionView performBatchUpdates:^{ |
| 83 [self.collectionViewModel removeSectionWithIdentifier:sectionIdentifier]; |
| 84 [self.collectionView deleteSections:[NSIndexSet indexSetWithIndex:section]]; |
| 85 } |
| 86 completion:^(BOOL) { |
| 87 // The context menu could be displayed for the deleted entries. |
| 88 [self.suggestionCommandHandler dismissContextMenu]; |
| 89 }]; |
| 90 } |
| 73 | 91 |
| 74 #pragma mark - UIViewController | 92 #pragma mark - UIViewController |
| 75 | 93 |
| 76 - (void)viewDidLoad { | 94 - (void)viewDidLoad { |
| 77 [super viewDidLoad]; | 95 [super viewDidLoad]; |
| 78 | 96 |
| 79 _collectionUpdater.collectionViewController = self; | 97 _collectionUpdater.collectionViewController = self; |
| 80 | 98 |
| 81 self.collectionView.delegate = self; | 99 self.collectionView.delegate = self; |
| 82 self.styler.cellStyle = MDCCollectionViewCellStyleCard; | 100 self.styler.cellStyle = MDCCollectionViewCellStyleCard; |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 ContentSuggestionsArticleItem* articleItem = | 235 ContentSuggestionsArticleItem* articleItem = |
| 218 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem); | 236 base::mac::ObjCCastStrict<ContentSuggestionsArticleItem>(touchedItem); |
| 219 | 237 |
| 220 [self.suggestionCommandHandler | 238 [self.suggestionCommandHandler |
| 221 displayContextMenuForArticle:articleItem | 239 displayContextMenuForArticle:articleItem |
| 222 atPoint:touchLocation | 240 atPoint:touchLocation |
| 223 atIndexPath:touchedItemIndexPath]; | 241 atIndexPath:touchedItemIndexPath]; |
| 224 } | 242 } |
| 225 | 243 |
| 226 @end | 244 @end |
| OLD | NEW |