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

Side by Side Diff: ios/chrome/browser/ui/content_suggestions/content_suggestions_collection_updater.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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h" 5 #import "ios/chrome/browser/ui/content_suggestions/content_suggestions_collectio n_updater.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 469
470 articleItem.suggestionIdentifier = suggestion.suggestionIdentifier; 470 articleItem.suggestionIdentifier = suggestion.suggestionIdentifier;
471 471
472 __weak ContentSuggestionsArticleItem* weakItem = articleItem; 472 __weak ContentSuggestionsArticleItem* weakItem = articleItem;
473 [self fetchFaviconForItem:articleItem 473 [self fetchFaviconForItem:articleItem
474 withURL:articleItem.articleURL 474 withURL:articleItem.articleURL
475 callback:^void(FaviconAttributes* attributes) { 475 callback:^void(FaviconAttributes* attributes) {
476 weakItem.attributes = attributes; 476 weakItem.attributes = attributes;
477 }]; 477 }];
478 478
479 __weak ContentSuggestionsCollectionUpdater* weakSelf = self;
480 [self.dataSource
481 fetchFaviconImageForSuggestion:articleItem.suggestionIdentifier
482 completion:^void(UIImage* favicon) {
483 weakItem.attributes =
lpromero 2017/04/14 13:19:40 I'd advise to return early if one of the weak item
484 [FaviconAttributes attributesWithImage:favicon];
485 [weakSelf reconfigure:weakItem];
486 }];
487
479 return articleItem; 488 return articleItem;
480 } 489 }
481 490
482 // Returns a reading list item built with the |suggestion|. 491 // Returns a reading list item built with the |suggestion|.
483 - (ContentSuggestionsReadingListItem*)readingListItemForSuggestion: 492 - (ContentSuggestionsReadingListItem*)readingListItemForSuggestion:
484 (ContentSuggestion*)suggestion { 493 (ContentSuggestion*)suggestion {
485 ContentSuggestionsReadingListItem* readingListItem = 494 ContentSuggestionsReadingListItem* readingListItem =
486 [[ContentSuggestionsReadingListItem alloc] 495 [[ContentSuggestionsReadingListItem alloc]
487 initWithType:ItemTypeReadingList 496 initWithType:ItemTypeReadingList
488 url:suggestion.url 497 url:suggestion.url
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 [model sectionIdentifierForSection:sectionNumber]; 562 [model sectionIdentifierForSection:sectionNumber];
554 if ([model hasItem:item inSectionWithIdentifier:sectionIdentifier]) { 563 if ([model hasItem:item inSectionWithIdentifier:sectionIdentifier]) {
555 [self.collectionViewController 564 [self.collectionViewController
556 reconfigureCellsForItems:@[ item ] 565 reconfigureCellsForItems:@[ item ]
557 inSectionWithIdentifier:sectionIdentifier]; 566 inSectionWithIdentifier:sectionIdentifier];
558 } 567 }
559 } 568 }
560 } 569 }
561 570
562 @end 571 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698