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

Unified Diff: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm

Issue 2798883002: Open Reading List on tap on More (Closed)
Patch Set: Address comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/browser/content_suggestions/content_suggestions_mediator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
diff --git a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
index 15c36ba9e8e5c4696a7ffc4a855132149a5f1a5e..fc7bb22bb27a4c29729b544f39cab92e7fd8c622 100644
--- a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
@@ -15,6 +15,7 @@
#import "ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.h"
#import "ios/chrome/browser/content_suggestions/mediator_util.h"
#import "ios/chrome/browser/ui/content_suggestions/content_suggestion.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_image_fetcher.h"
#import "ios/chrome/browser/ui/content_suggestions/identifier/content_suggestion_identifier.h"
@@ -72,6 +73,7 @@ const CGFloat kDefaultFaviconSize = 16;
@synthesize dataSink = _dataSink;
@synthesize sectionInformationByCategory = _sectionInformationByCategory;
@synthesize attributesProvider = _attributesProvider;
+@synthesize commandHandler = _commandHandler;
#pragma mark - Public
@@ -149,19 +151,41 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService
ContentSuggestionsCategoryWrapper* wrapper =
[self categoryWrapperForSectionInfo:sectionInfo];
- __weak ContentSuggestionsMediator* weakSelf = self;
- ntp_snippets::FetchDoneCallback serviceCallback = base::Bind(
- &BindWrapper,
- base::BindBlockArc(^void(
- ntp_snippets::Status status,
- const std::vector<ntp_snippets::ContentSuggestion>& suggestions) {
- [weakSelf didFetchMoreSuggestions:suggestions
- withStatusCode:status
- callback:callback];
- }));
+ base::Optional<ntp_snippets::CategoryInfo> categoryInfo =
+ self.contentService->GetCategoryInfo([wrapper category]);
- self.contentService->Fetch([wrapper category], known_suggestion_ids,
- serviceCallback);
+ if (!categoryInfo) {
+ return;
+ }
+ switch (categoryInfo->additional_action()) {
+ case ntp_snippets::ContentSuggestionsAdditionalAction::NONE:
+ return;
+
+ case ntp_snippets::ContentSuggestionsAdditionalAction::VIEW_ALL:
+ if ([wrapper category].IsKnownCategory(
+ ntp_snippets::KnownCategories::READING_LIST)) {
+ [self.commandHandler openReadingList];
+ }
+ break;
+
+ case ntp_snippets::ContentSuggestionsAdditionalAction::FETCH: {
+ __weak ContentSuggestionsMediator* weakSelf = self;
+ ntp_snippets::FetchDoneCallback serviceCallback = base::Bind(
+ &BindWrapper,
+ base::BindBlockArc(^void(
+ ntp_snippets::Status status,
+ const std::vector<ntp_snippets::ContentSuggestion>& suggestions) {
+ [weakSelf didFetchMoreSuggestions:suggestions
+ withStatusCode:status
+ callback:callback];
+ }));
+
+ self.contentService->Fetch([wrapper category], known_suggestion_ids,
+ serviceCallback);
+
+ break;
+ }
+ }
}
- (void)fetchFaviconAttributesForURL:(const GURL&)URL
« no previous file with comments | « ios/chrome/browser/content_suggestions/content_suggestions_mediator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698