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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_data_source.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_DATA_SOURC E_H_ 5 #ifndef IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_DATA_SOURC E_H_
6 #define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_DATA_SOURC E_H_ 6 #define IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_DATA_SOURC E_H_
7 7
8 #import <UIKit/UIKit.h>
9
10 @class CollectionViewItem;
8 @class ContentSuggestion; 11 @class ContentSuggestion;
9 @class ContentSuggestionIdentifier; 12 @class ContentSuggestionIdentifier;
10 @class ContentSuggestionsSectionInformation; 13 @class ContentSuggestionsSectionInformation;
11 @class FaviconAttributes; 14 @class FaviconAttributes;
12 @protocol ContentSuggestionsDataSink; 15 @protocol ContentSuggestionsDataSink;
13 @protocol ContentSuggestionsImageFetcher; 16 @protocol ContentSuggestionsImageFetcher;
14 class GURL; 17 @protocol SuggestedContent;
15 18
16 // Typedef for a block taking the fetched suggestions as parameter. 19 // Typedef for a block taking the fetched suggestions as parameter.
17 typedef void (^MoreSuggestionsFetched)(NSArray<ContentSuggestion*>* _Nonnull); 20 typedef void (^MoreSuggestionsFetched)(
21 NSArray<CollectionViewItem<SuggestedContent>*>* _Nullable);
18 22
19 // DataSource for the content suggestions. Provides the suggestions data in a 23 // DataSource for the content suggestions. Provides the suggestions data in a
20 // format compatible with Objective-C. 24 // format compatible with Objective-C.
21 @protocol ContentSuggestionsDataSource 25 @protocol ContentSuggestionsDataSource
22 26
23 // The data sink that will be notified when the data change. 27 // The data sink that will be notified when the data change.
24 @property(nonatomic, nullable, weak) id<ContentSuggestionsDataSink> dataSink; 28 @property(nonatomic, nullable, weak) id<ContentSuggestionsDataSink> dataSink;
25 29
26 // Returns all the data currently available. 30 // Returns all the sections information in the order they should be displayed.
27 - (nonnull NSArray<ContentSuggestion*>*)allSuggestions; 31 - (nonnull NSArray<ContentSuggestionsSectionInformation*>*)sectionsInfo;
28 32
29 // Returns the data currently available for the section identified by 33 // Returns the items associated with the |sectionInfo|.
30 // |sectionInfo|. 34 - (nonnull NSArray<CollectionViewItem<SuggestedContent>*>*)itemsForSectionInfo:
31 - (nonnull NSArray<ContentSuggestion*>*)suggestionsForSection:
32 (nonnull ContentSuggestionsSectionInformation*)sectionInfo; 35 (nonnull ContentSuggestionsSectionInformation*)sectionInfo;
33 36
34 // Returns an image updater for the suggestions provided by this data source. 37 // Returns an image updater for the suggestions provided by this data source.
35 - (nullable id<ContentSuggestionsImageFetcher>)imageFetcher; 38 - (nullable id<ContentSuggestionsImageFetcher>)imageFetcher;
36 39
37 // Fetches favicon attributes and calls the completion block. 40 // Fetches favicon attributes associated with the |item| and calls the
38 - (void)fetchFaviconAttributesForURL:(const GURL&)URL 41 // |completion| block.
39 completion: 42 - (void)fetchFaviconAttributesForItem:
40 (void (^_Nonnull)(FaviconAttributes* _Nonnull)) 43 (nonnull CollectionViewItem<SuggestedContent>*)item
41 completion; 44 completion:
45 (void (^_Nonnull)(FaviconAttributes* _Nonnull))
46 completion;
42 47
43 // Fetches favicon image associated with this |suggestion| in history. If it is 48 // Fetches the favicon image associated with the |item|. If there is no image
44 // not present in the history, tries to download it. Calls the completion block 49 // cached locally and the provider allows it, it tries to download it. The
45 // if an image has been found. 50 // |completion| block is only called if an image is found.
46 // This can only be used for public URL.
47 - (void) 51 - (void)
48 fetchFaviconImageForSuggestion:(nonnull ContentSuggestionIdentifier*)suggestion 52 fetchFaviconImageForItem:(nonnull CollectionViewItem<SuggestedContent>*)item
49 completion:(void (^_Nonnull)(UIImage* _Nonnull))completion; 53 completion:(void (^_Nonnull)(UIImage* _Nonnull))completion;
50 54
51 // Fetches additional content. All the |knownSuggestions| must come from the 55 // Fetches additional content. All the |knownSuggestions| must come from the
52 // same |sectionInfo|. If the fetch was completed, the given |callback| is 56 // same |sectionInfo|. If the fetch was completed, the given |callback| is
53 // called with the new content. 57 // called with the new content.
54 - (void)fetchMoreSuggestionsKnowing: 58 - (void)fetchMoreSuggestionsKnowing:
55 (nullable NSArray<ContentSuggestionIdentifier*>*)knownSuggestions 59 (nullable NSArray<ContentSuggestionIdentifier*>*)knownSuggestions
56 fromSectionInfo: 60 fromSectionInfo:
57 (nonnull ContentSuggestionsSectionInformation*) 61 (nonnull ContentSuggestionsSectionInformation*)
58 sectionInfo 62 sectionInfo
59 callback:(nullable MoreSuggestionsFetched)callback; 63 callback:(nonnull MoreSuggestionsFetched)callback;
60 64
61 @end 65 @end
62 66
63 #endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_DATA_SO URCE_H_ 67 #endif // IOS_CHROME_BROWSER_UI_CONTENT_SUGGESTIONS_CONTENT_SUGGESTIONS_DATA_SO URCE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698