| OLD | NEW |
| 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 Loading... |
| 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 if (!weakItem || !weakSelf) |
| 484 return; |
| 485 |
| 486 weakItem.attributes = |
| 487 [FaviconAttributes attributesWithImage:favicon]; |
| 488 [weakSelf reconfigure:weakItem]; |
| 489 }]; |
| 490 |
| 479 return articleItem; | 491 return articleItem; |
| 480 } | 492 } |
| 481 | 493 |
| 482 // Returns a reading list item built with the |suggestion|. | 494 // Returns a reading list item built with the |suggestion|. |
| 483 - (ContentSuggestionsReadingListItem*)readingListItemForSuggestion: | 495 - (ContentSuggestionsReadingListItem*)readingListItemForSuggestion: |
| 484 (ContentSuggestion*)suggestion { | 496 (ContentSuggestion*)suggestion { |
| 485 ContentSuggestionsReadingListItem* readingListItem = | 497 ContentSuggestionsReadingListItem* readingListItem = |
| 486 [[ContentSuggestionsReadingListItem alloc] | 498 [[ContentSuggestionsReadingListItem alloc] |
| 487 initWithType:ItemTypeReadingList | 499 initWithType:ItemTypeReadingList |
| 488 url:suggestion.url | 500 url:suggestion.url |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 [model sectionIdentifierForSection:sectionNumber]; | 565 [model sectionIdentifierForSection:sectionNumber]; |
| 554 if ([model hasItem:item inSectionWithIdentifier:sectionIdentifier]) { | 566 if ([model hasItem:item inSectionWithIdentifier:sectionIdentifier]) { |
| 555 [self.collectionViewController | 567 [self.collectionViewController |
| 556 reconfigureCellsForItems:@[ item ] | 568 reconfigureCellsForItems:@[ item ] |
| 557 inSectionWithIdentifier:sectionIdentifier]; | 569 inSectionWithIdentifier:sectionIdentifier]; |
| 558 } | 570 } |
| 559 } | 571 } |
| 560 } | 572 } |
| 561 | 573 |
| 562 @end | 574 @end |
| OLD | NEW |