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

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

Issue 2798883002: Open Reading List on tap on More (Closed)
Patch Set: 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
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 930f2111c407ceb44314ac1fdd3327426b30e732..6730853237f1eecb1f37745619f75f2f1913b29d 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_category_wrapper.h"
#import "ios/chrome/browser/content_suggestions/content_suggestions_service_bridge_observer.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"
@@ -170,6 +171,7 @@ ntp_snippets::ContentSuggestion::ID SuggestionIDForSectionID(
@synthesize dataSink = _dataSink;
@synthesize sectionInformationByCategory = _sectionInformationByCategory;
@synthesize attributesProvider = _attributesProvider;
+@synthesize commandHandler = _commandHandler;
#pragma mark - Public
@@ -247,19 +249,39 @@ 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) {
stkhapugin 2017/04/05 13:06:02 nit: if (!categoryInfo) { return; } // to avoid id
gambard 2017/04/05 15:30:17 Done.
+ 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);
stkhapugin 2017/04/05 13:06:02 break;
gambard 2017/04/05 15:30:17 Done.
+ }
+ }
+ }
}
- (void)fetchFaviconAttributesForURL:(const GURL&)URL

Powered by Google App Engine
This is Rietveld 408576698