OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 |
| 10 #import "ios/chrome/browser/ui/collection_view/collection_view_model.h" |
| 11 |
| 12 namespace base { |
| 13 class Time; |
| 14 } |
| 15 @class CollectionViewModel; |
| 16 @class HistoryEntryInserter; |
| 17 @class HistoryEntryItem; |
| 18 |
| 19 // Delegate for HistoryEntryInserter. Provides callbacks for completion of item |
| 20 // and section insertion and deletion. |
| 21 @protocol HistoryEntryInserterDelegate<NSObject> |
| 22 // Invoked when the inserter has finished inserting an item. |
| 23 - (void)historyEntryInserter:(HistoryEntryInserter*)inserter |
| 24 didInsertItemAtIndexPath:(NSIndexPath*)indexPath; |
| 25 // Invoked when the inserter has finished inserting a section. |
| 26 - (void)historyEntryInserter:(HistoryEntryInserter*)inserter |
| 27 didInsertSectionAtIndex:(NSInteger)sectionIndex; |
| 28 // Invoked when the inserter has finished removing a section. |
| 29 - (void)historyEntryInserter:(HistoryEntryInserter*)inserter |
| 30 didRemoveSectionAtIndex:(NSInteger)sectionIndex; |
| 31 @end |
| 32 |
| 33 // Object for ensuring history entry items are kept in order as they are added |
| 34 // to the CollectionViewModel. |
| 35 @interface HistoryEntryInserter : NSObject |
| 36 |
| 37 // Delegate for the HistoryEntryInserter. Receives callbacks upon item and |
| 38 // section insertion and removal. |
| 39 @property(nonatomic, assign) id<HistoryEntryInserterDelegate> delegate; |
| 40 |
| 41 // Designated initializer for HistoryEntryInserter. collectionViewModel is the |
| 42 // model into which entries are inserted. Sections for history entries are |
| 43 // appended to the model. Sections already in the model at initialization |
| 44 // of the inserter should not be removed, and sections should not be added |
| 45 // except by the inserter. Duplicate entries are not inserted. |
| 46 - (instancetype)initWithModel:(CollectionViewModel*)collectionViewModel |
| 47 NS_DESIGNATED_INITIALIZER; |
| 48 - (instancetype)init NS_UNAVAILABLE; |
| 49 |
| 50 // Inserts a history entry into the model at the correct sorted index path. |
| 51 // History entries in the model are sorted from most to least recent, and |
| 52 // grouped into section by date. Duplicate entries are not inserted. Invokes |
| 53 // delegate callback when insertion is complete. |
| 54 - (void)insertHistoryEntryItem:(HistoryEntryItem*)item; |
| 55 |
| 56 // Returns section identifier for provided timestamp. Adds section for date if |
| 57 // not found, and invokes delegate callback. |
| 58 - (NSUInteger)sectionIdentifierForTimestamp:(base::Time)timestamp; |
| 59 |
| 60 // Removes section at |sectionIndex|, and invokes delegate callback when removal |
| 61 // is complete. |
| 62 - (void)removeSection:(NSInteger)sectionIndex; |
| 63 |
| 64 @end |
| 65 |
| 66 #endif // IOS_CHROME_BROWSER_UI_HISTORY_HISTORY_ENTRY_INSERTER_H_ |
OLD | NEW |