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 2818453002: Download favicon from server for suggested articles (Closed)
Patch Set: Reviewable 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 19dbe62a4ee352666e252241b74221e5f525a326..12d593fde2523b7238140672ba3038d248e5715e 100644
--- a/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
+++ b/ios/chrome/browser/content_suggestions/content_suggestions_mediator.mm
@@ -234,6 +234,26 @@ initWithContentService:(ntp_snippets::ContentSuggestionsService*)contentService
completion:completion];
}
+- (void)fetchFaviconImageForSuggestion:(ContentSuggestionIdentifier*)suggestion
+ completion:(void (^)(UIImage*))completion {
+ if (!completion)
+ return;
+
+ void (^imageCallback)(const gfx::Image&) = ^(const gfx::Image& image) {
+ if (!image.IsEmpty()) {
+ completion([image.ToUIImage() copy]);
lpromero 2017/04/14 13:19:40 Is the copy necessary? UIImage is immutable.
gambard 2017/04/14 13:28:10 It is a memory management thing. You can ask stkha
+ }
+ };
+
+ ntp_snippets::ContentSuggestion::ID identifier =
+ ntp_snippets::ContentSuggestion::ID(
+ [[self categoryWrapperForSectionInfo:suggestion.sectionInfo]
+ category],
+ suggestion.IDInSection);
+ self.contentService->FetchSuggestionFavicon(
+ identifier, 1, kDefaultFaviconSize, base::BindBlockArc(imageCallback));
lpromero 2017/04/14 13:19:40 Optional nit: Can you add something like: "identif
gambard 2017/04/14 13:28:10 Done.
+}
+
#pragma mark - ContentSuggestionsServiceObserver
- (void)contentSuggestionsService:

Powered by Google App Engine
This is Rietveld 408576698