Commit 3b59ad16 authored by adamta's avatar adamta Committed by Commit Bot

[ios] ContentSuggestions Section for Discover Feed

Adds a section in the ContentSuggestions collection view
which will later be populated by the Discover feed.

Bug: 1085419
Change-Id: I36d6c55a4c3041d730d7189cdf2074d6e66ac0ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2215302
Commit-Queue: Adam Trudeau-Arcaro <adamta@google.com>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#773261}
parent b702b9ce
...@@ -28,6 +28,7 @@ source_set("content_suggestions") { ...@@ -28,6 +28,7 @@ source_set("content_suggestions") {
"ntp_home_metrics.mm", "ntp_home_metrics.mm",
] ]
deps = [ deps = [
":feature_flags",
"//base", "//base",
"//components/favicon/core", "//components/favicon/core",
"//components/feed/core/shared_prefs:feed_shared_prefs", "//components/feed/core/shared_prefs:feed_shared_prefs",
......
...@@ -50,6 +50,7 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -50,6 +50,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
ItemTypeMostVisited, ItemTypeMostVisited,
ItemTypePromo, ItemTypePromo,
ItemTypeLearnMore, ItemTypeLearnMore,
ItemTypeDiscover,
ItemTypeUnknown, ItemTypeUnknown,
}; };
...@@ -62,6 +63,7 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) { ...@@ -62,6 +63,7 @@ typedef NS_ENUM(NSInteger, SectionIdentifier) {
SectionIdentifierLogo, SectionIdentifierLogo,
SectionIdentifierPromo, SectionIdentifierPromo,
SectionIdentifierLearnMore, SectionIdentifierLearnMore,
SectionIdentifierDiscover,
SectionIdentifierDefault, SectionIdentifierDefault,
}; };
...@@ -98,7 +100,8 @@ ItemType ItemTypeForInfo(ContentSuggestionsSectionInformation* info) { ...@@ -98,7 +100,8 @@ ItemType ItemTypeForInfo(ContentSuggestionsSectionInformation* info) {
return ItemTypePromo; return ItemTypePromo;
case ContentSuggestionsSectionLearnMore: case ContentSuggestionsSectionLearnMore:
return ItemTypeLearnMore; return ItemTypeLearnMore;
case ContentSuggestionsSectionDiscover:
return ItemTypeDiscover;
case ContentSuggestionsSectionLogo: case ContentSuggestionsSectionLogo:
case ContentSuggestionsSectionUnknown: case ContentSuggestionsSectionUnknown:
return ItemTypeUnknown; return ItemTypeUnknown;
...@@ -121,7 +124,8 @@ SectionIdentifier SectionIdentifierForInfo( ...@@ -121,7 +124,8 @@ SectionIdentifier SectionIdentifierForInfo(
return SectionIdentifierPromo; return SectionIdentifierPromo;
case ContentSuggestionsSectionLearnMore: case ContentSuggestionsSectionLearnMore:
return SectionIdentifierLearnMore; return SectionIdentifierLearnMore;
case ContentSuggestionsSectionDiscover:
return SectionIdentifierDiscover;
case ContentSuggestionsSectionUnknown: case ContentSuggestionsSectionUnknown:
return SectionIdentifierDefault; return SectionIdentifierDefault;
} }
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_commands.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_data_sink.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_favicon_mediator.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_favicon_mediator.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_feature.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_provider.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_header_provider.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestions_service_bridge_observer.h" #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_service_bridge_observer.h"
#import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h" #import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h"
...@@ -93,6 +94,9 @@ const NSInteger kMaxNumMostVisitedTiles = 4; ...@@ -93,6 +94,9 @@ const NSInteger kMaxNumMostVisitedTiles = 4;
// suggested content. // suggested content.
@property(nonatomic, strong) @property(nonatomic, strong)
ContentSuggestionsSectionInformation* learnMoreSectionInfo; ContentSuggestionsSectionInformation* learnMoreSectionInfo;
// Section Info for the section containing the Discover feed.
@property(nonatomic, strong)
ContentSuggestionsSectionInformation* discoverSectionInfo;
// Whether the page impression has been recorded. // Whether the page impression has been recorded.
@property(nonatomic, assign) BOOL recordedPageImpression; @property(nonatomic, assign) BOOL recordedPageImpression;
// The ContentSuggestionsService, serving suggestions. // The ContentSuggestionsService, serving suggestions.
...@@ -152,6 +156,8 @@ const NSInteger kMaxNumMostVisitedTiles = 4; ...@@ -152,6 +156,8 @@ const NSInteger kMaxNumMostVisitedTiles = 4;
_learnMoreItem = [[ContentSuggestionsLearnMoreItem alloc] init]; _learnMoreItem = [[ContentSuggestionsLearnMoreItem alloc] init];
_discoverSectionInfo = DiscoverSectionInformation();
_notificationPromo = std::make_unique<NotificationPromoWhatsNew>( _notificationPromo = std::make_unique<NotificationPromoWhatsNew>(
GetApplicationContext()->GetLocalState()); GetApplicationContext()->GetLocalState());
_notificationPromo->Init(); _notificationPromo->Init();
...@@ -221,6 +227,10 @@ const NSInteger kMaxNumMostVisitedTiles = 4; ...@@ -221,6 +227,10 @@ const NSInteger kMaxNumMostVisitedTiles = 4;
[sectionsInfo addObject:self.learnMoreSectionInfo]; [sectionsInfo addObject:self.learnMoreSectionInfo];
if (IsDiscoverFeedEnabled()) {
[sectionsInfo addObject:self.discoverSectionInfo];
}
return sectionsInfo; return sectionsInfo;
} }
......
...@@ -24,6 +24,7 @@ typedef NS_ENUM(NSInteger, ContentSuggestionsSectionID) { ...@@ -24,6 +24,7 @@ typedef NS_ENUM(NSInteger, ContentSuggestionsSectionID) {
ContentSuggestionsSectionArticles, ContentSuggestionsSectionArticles,
ContentSuggestionsSectionReadingList, ContentSuggestionsSectionReadingList,
ContentSuggestionsSectionLearnMore, ContentSuggestionsSectionLearnMore,
ContentSuggestionsSectionDiscover,
// Do not use this. It will trigger a DCHECK. // Do not use this. It will trigger a DCHECK.
// Do not add value after this one. // Do not add value after this one.
......
...@@ -60,6 +60,9 @@ ContentSuggestionsSectionInformation* MostVisitedSectionInformation(); ...@@ -60,6 +60,9 @@ ContentSuggestionsSectionInformation* MostVisitedSectionInformation();
// Creates and returns a SectionInfo for the Learn More section. // Creates and returns a SectionInfo for the Learn More section.
ContentSuggestionsSectionInformation* LearnMoreSectionInformation(); ContentSuggestionsSectionInformation* LearnMoreSectionInformation();
// Creates and returns a SectionInfo for the Discover feed section.
ContentSuggestionsSectionInformation* DiscoverSectionInformation();
// Converts a ntp_tiles::NTPTile |tile| to a ContentSuggestionsMostVisitedItem // Converts a ntp_tiles::NTPTile |tile| to a ContentSuggestionsMostVisitedItem
// with a |sectionInfo|. // with a |sectionInfo|.
ContentSuggestionsMostVisitedItem* ConvertNTPTile( ContentSuggestionsMostVisitedItem* ConvertNTPTile(
......
...@@ -132,6 +132,18 @@ ContentSuggestionsSectionInformation* LearnMoreSectionInformation() { ...@@ -132,6 +132,18 @@ ContentSuggestionsSectionInformation* LearnMoreSectionInformation() {
return EmptySectionInfo(ContentSuggestionsSectionLearnMore); return EmptySectionInfo(ContentSuggestionsSectionLearnMore);
} }
ContentSuggestionsSectionInformation* DiscoverSectionInformation() {
ContentSuggestionsSectionInformation* sectionInfo =
[[ContentSuggestionsSectionInformation alloc]
initWithSectionID:ContentSuggestionsSectionDiscover];
sectionInfo.title = nil;
sectionInfo.footerTitle = nil;
sectionInfo.showIfEmpty = YES;
sectionInfo.layout = ContentSuggestionsSectionLayoutCustom;
return sectionInfo;
}
ContentSuggestionsMostVisitedItem* ConvertNTPTile( ContentSuggestionsMostVisitedItem* ConvertNTPTile(
const ntp_tiles::NTPTile& tile, const ntp_tiles::NTPTile& tile,
ContentSuggestionsSectionInformation* sectionInfo) { ContentSuggestionsSectionInformation* sectionInfo) {
......
...@@ -121,6 +121,7 @@ using CSCollectionViewItem = CollectionViewItem<SuggestedContent>; ...@@ -121,6 +121,7 @@ using CSCollectionViewItem = CollectionViewItem<SuggestedContent>;
} }
case ContentSuggestionsSectionLogo: case ContentSuggestionsSectionLogo:
case ContentSuggestionsSectionPromo: case ContentSuggestionsSectionPromo:
case ContentSuggestionsSectionDiscover:
case ContentSuggestionsSectionUnknown: case ContentSuggestionsSectionUnknown:
return @[]; return @[];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment