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

Side by Side Diff: ios/chrome/browser/content_suggestions/mediator_util.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_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_ 5 #ifndef IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_
6 #define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_ 6 #define IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/optional.h" 9 #include "base/optional.h"
10 #include "components/ntp_snippets/category_info.h" 10 #include "components/ntp_snippets/category_info.h"
11 #include "components/ntp_snippets/content_suggestion.h" 11 #include "components/ntp_snippets/content_suggestion.h"
12 #include "components/ntp_snippets/status.h" 12 #include "components/ntp_snippets/status.h"
13 #include "components/ntp_tiles/ntp_tile.h" 13 #include "components/ntp_tiles/ntp_tile.h"
14 #import "ios/chrome/browser/ui/content_suggestions/content_suggestion.h" 14 #import "ios/chrome/browser/ui/content_suggestions/cells/suggested_content.h"
15 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion s_section_information.h" 15 #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion s_section_information.h"
16 16
17 namespace ntp_snippets { 17 namespace ntp_snippets {
18 class ContentSuggestion;
19 class Category; 18 class Category;
20 class CategoryInfo;
21 } 19 }
22 20
21 @class CollectionViewItem;
23 @class ContentSuggestionsCategoryWrapper; 22 @class ContentSuggestionsCategoryWrapper;
24 23
25 // TODO(crbug.com/701275): Once base::BindBlock supports the move semantics, 24 // TODO(crbug.com/701275): Once base::BindBlock supports the move semantics,
26 // remove this wrapper. 25 // remove this wrapper.
27 // Wraps a callback taking a const ref to a callback taking an object. 26 // Wraps a callback taking a const ref to a callback taking an object.
28 void BindWrapper( 27 void BindWrapper(
29 base::Callback<void(ntp_snippets::Status status_code, 28 base::Callback<void(ntp_snippets::Status status_code,
30 const std::vector<ntp_snippets::ContentSuggestion>& 29 const std::vector<ntp_snippets::ContentSuggestion>&
31 suggestions)> callback, 30 suggestions)> callback,
32 ntp_snippets::Status status_code, 31 ntp_snippets::Status status_code,
33 std::vector<ntp_snippets::ContentSuggestion> suggestions); 32 std::vector<ntp_snippets::ContentSuggestion> suggestions);
34 33
35 // Returns the Type for this |category|.
36 ContentSuggestionType TypeForCategory(ntp_snippets::Category category);
37
38 // Returns the section ID for this |category|. 34 // Returns the section ID for this |category|.
39 ContentSuggestionsSectionID SectionIDForCategory( 35 ContentSuggestionsSectionID SectionIDForCategory(
40 ntp_snippets::Category category); 36 ntp_snippets::Category category);
41 37
42 // Returns the section layout corresponding to the category |layout|. 38 // Converts a ntp_snippets::ContentSuggestion to a CollectionViewItem.
43 ContentSuggestionsSectionLayout SectionLayoutForLayout( 39 CollectionViewItem<SuggestedContent>* ConvertSuggestion(
44 ntp_snippets::ContentSuggestionsCardLayout layout); 40 const ntp_snippets::ContentSuggestion& contentSuggestion,
45 41 ContentSuggestionsSectionInformation* sectionInfo,
46 // Converts a ntp_snippets::ContentSuggestion to an Objective-C 42 ntp_snippets::Category category);
47 // ContentSuggestion.
48 ContentSuggestion* ConvertContentSuggestion(
49 const ntp_snippets::ContentSuggestion& contentSuggestion);
50 43
51 // Returns a SectionInformation for a |category|, filled with the 44 // Returns a SectionInformation for a |category|, filled with the
52 // |categoryInfo|. 45 // |categoryInfo|.
53 ContentSuggestionsSectionInformation* SectionInformationFromCategoryInfo( 46 ContentSuggestionsSectionInformation* SectionInformationFromCategoryInfo(
54 const base::Optional<ntp_snippets::CategoryInfo>& categoryInfo, 47 const base::Optional<ntp_snippets::CategoryInfo>& categoryInfo,
55 const ntp_snippets::Category& category); 48 const ntp_snippets::Category& category);
56 49
57 // Returns a ntp_snippets::ID based on a Objective-C Category and the ID in the 50 // Returns a ntp_snippets::ID based on a Objective-C Category and the ID in the
58 // category. 51 // category.
59 ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID( 52 ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID(
60 ContentSuggestionsCategoryWrapper* category, 53 ContentSuggestionsCategoryWrapper* category,
61 const std::string& id_in_category); 54 const std::string& id_in_category);
62 55
63 // Creates and returns an empty suggestion.
64 ContentSuggestion* EmptySuggestion();
65
66 // Creates and returns a SectionInfo for the Most Visited section. 56 // Creates and returns a SectionInfo for the Most Visited section.
67 ContentSuggestionsSectionInformation* MostVisitedSectionInformation(); 57 ContentSuggestionsSectionInformation* MostVisitedSectionInformation();
68 58
69 // Records the page impression of the ntp tiles. 59 // Records the page impression of the ntp tiles.
70 void RecordPageImpression(const std::vector<ntp_tiles::NTPTile>& mostVisited); 60 void RecordPageImpression(const std::vector<ntp_tiles::NTPTile>& mostVisited);
71 61
72 // Converts a ntp_snippets::ContentSuggestion to an Objective-C 62 // Converts a ntp_snippets::ContentSuggestion to an adapted CollectionViewItem
73 // ContentSuggestion. 63 // with a |sectionInfo|.
74 ContentSuggestion* ConvertNTPTile(const ntp_tiles::NTPTile& tile); 64 CollectionViewItem<SuggestedContent>* ConvertNTPTile(
65 const ntp_tiles::NTPTile& tile,
66 ContentSuggestionsSectionInformation* sectionInfo);
75 67
76 #endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_ 68 #endif // IOS_CHROME_BROWSER_CONTENT_SUGGESTIONS_MEDIATOR_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698