Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.h

Issue 2877513003: ContentSuggestionsDataSource returns CollectionViewItem (Closed)
Patch Set: Address comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #ifndef IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECTION _UPDATER_H_ 5 #ifndef IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECTION _UPDATER_H_
6 #define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECTION _UPDATER_H_ 6 #define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECTION _UPDATER_H_
7 7
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" 10 @class CollectionViewItem;
11 @class ContentSuggestionsSectionInformation;
12 @class ContentSuggestionsViewController;
13 @protocol ContentSuggestionsDataSource;
14 @protocol SuggestedContent;
11 15
12 @class CollectionViewItem; 16 // Enum defining the type of a ContentSuggestions.
13 @protocol ContentSuggestionsDataSource; 17 typedef NS_ENUM(NSInteger, ContentSuggestionType) {
14 @class ContentSuggestionsViewController; 18 // Use this type to pass information about an empty section. Suggestion of
19 // this type are empty and should not be displayed. The informations to be
20 // displayed are contained in the SectionInfo.
21 ContentSuggestionTypeEmpty,
22 ContentSuggestionTypeArticle,
23 ContentSuggestionTypeReadingList,
24 ContentSuggestionTypeMostVisited,
25 };
15 26
16 // Updater for a CollectionViewController populating it with some items and 27 // Updater for a CollectionViewController populating it with some items and
17 // handling the items addition. 28 // handling the items addition.
18 @interface ContentSuggestionsCollectionUpdater : NSObject 29 @interface ContentSuggestionsCollectionUpdater : NSObject
19 30
20 // Initialize with the |dataSource| used to get the data. 31 // Initialize with the |dataSource| used to get the data.
21 - (instancetype)initWithDataSource:(id<ContentSuggestionsDataSource>)dataSource 32 - (instancetype)initWithDataSource:(id<ContentSuggestionsDataSource>)dataSource
22 NS_DESIGNATED_INITIALIZER; 33 NS_DESIGNATED_INITIALIZER;
23 34
24 - (instancetype)init NS_UNAVAILABLE; 35 - (instancetype)init NS_UNAVAILABLE;
25 36
26 // |collectionViewController| this Updater will update. Needs to be set before 37 // |collectionViewController| this Updater will update. Needs to be set before
27 // adding items. 38 // adding items.
28 @property(nonatomic, assign) 39 @property(nonatomic, weak)
29 ContentSuggestionsViewController* collectionViewController; 40 ContentSuggestionsViewController* collectionViewController;
30 41
31 // Returns whether the section should use the default, non-card style. 42 // Returns whether the section should use the default, non-card style.
32 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section; 43 - (BOOL)shouldUseCustomStyleForSection:(NSInteger)section;
33 44
34 // Returns the ContentSuggestionType associated with this item. 45 // Returns the ContentSuggestionType associated with this item.
35 - (ContentSuggestionType)contentSuggestionTypeForItem:(CollectionViewItem*)item; 46 - (ContentSuggestionType)contentSuggestionTypeForItem:(CollectionViewItem*)item;
36 47
37 // Adds the sections for the |suggestions| to the model and returns their 48 // Adds the sections for the |suggestions| to the model and returns their
38 // indices. 49 // indices.
39 - (NSIndexSet*)addSectionsForSuggestionsToModel: 50 - (NSIndexSet*)addSectionsForSectionInfoToModel:
40 (NSArray<ContentSuggestion*>*)suggestions; 51 (NSArray<ContentSuggestionsSectionInformation*>*)sectionsInfo;
41 52
42 // Adds the |suggestions| to the model and returns their index paths. 53 // Adds the |suggestions| to the model in the section corresponding to
43 // The caller must ensure the corresponding sections have been added to the 54 // |sectionInfo| and returns their index paths. The caller must ensure the
44 // model. 55 // corresponding section has been added to the model.
45 - (NSArray<NSIndexPath*>*)addSuggestionsToModel: 56 - (NSArray<NSIndexPath*>*)
46 (NSArray<ContentSuggestion*>*)suggestions; 57 addSuggestionsToModel:
58 (NSArray<CollectionViewItem<SuggestedContent>*>*)suggestions
59 withSectionInfo:(ContentSuggestionsSectionInformation*)sectionInfo;
47 60
48 // Adds the empty item to this |section| and returns its index path. The updater 61 // Adds an empty item to this |section| and returns its index path. The updater
49 // does not do any check about the number of elements in the section. 62 // does not do any check about the number of elements in the section.
50 - (NSIndexPath*)addEmptyItemForSection:(NSInteger)section; 63 - (NSIndexPath*)addEmptyItemForSection:(NSInteger)section;
51 64
52 @end 65 @end
53 66
54 #endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECT ION_UPDATER_H_ 67 #endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_COLLECT ION_UPDATER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698