Chromium Code Reviews| Index: ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm |
| diff --git a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm |
| index f9c79142e81d794817e10c73e155d2f0eb32c368..e6924b50868b41e729fd6c47f1189d720939fcb5 100644 |
| --- a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm |
| +++ b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm |
| @@ -4,6 +4,7 @@ |
| #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.h" |
| +#import "ios/chrome/browser/snapshots/snapshot_cache.h" |
| #import "ios/chrome/browser/ui/tab_switcher/tab_switcher_button.h" |
| #import "ios/chrome/browser/ui/uikit_ui_util.h" |
| #include "ios/chrome/grit/ios_theme_resources.h" |
| @@ -20,6 +21,8 @@ const CGFloat kSelectedBorderWidth = 4.0f; |
| } |
| @interface TabCollectionTabCell () |
| +@property(nonatomic, strong) TabCollectionItem* item; |
| +@property(nonatomic, strong) SnapshotCache* snapshotCache; |
| @property(nonatomic, strong) UILabel* titleLabel; |
| @property(nonatomic, strong) UIImageView* favicon; |
| @property(nonatomic, strong) TabSwitcherButton* snapshotButton; |
| @@ -27,6 +30,7 @@ const CGFloat kSelectedBorderWidth = 4.0f; |
| @implementation TabCollectionTabCell |
| @synthesize item = _item; |
| +@synthesize snapshotCache = _snapshotCache; |
| @dynamic titleLabel; |
| @dynamic favicon; |
| @dynamic snapshotButton; |
| @@ -38,19 +42,41 @@ const CGFloat kSelectedBorderWidth = 4.0f; |
| return self; |
| } |
| -#pragma mark - Properties |
| +#pragma mark - Cell lifecycle |
| -- (void)setItem:(TabCollectionItem*)item { |
| +- (void)prepareForReuse { |
| + [super prepareForReuse]; |
| + self.item = nil; |
| + self.snapshotCache = nil; |
| +} |
| + |
| +#pragma mark - Public methods |
| + |
| +- (void)configureCell:(TabCollectionItem*)item |
| + snapshotCache:(SnapshotCache*)snapshotCache { |
| DCHECK(item); |
| - _item = item; |
| + self.item = item; |
| + self.snapshotCache = snapshotCache; |
| self.titleLabel.text = item.title; |
| self.snapshotButton.accessibilityIdentifier = |
| [NSString stringWithFormat:@"%@_button", item.title]; |
| self.contentView.accessibilityLabel = item.title; |
| self.favicon.image = NativeImage(IDR_IOS_OMNIBOX_HTTP); |
| + __weak TabCollectionTabCell* weakSelf = self; |
| + [self.snapshotCache |
| + retrieveImageForSessionID:self.item.tabID |
| + callback:^(UIImage* snapshot) { |
| + DCHECK([NSThread isMainThread]); |
|
marq (ping after 24h)
2017/07/06 12:41:17
This check shouldn't be needed; if the contract is
edchin
2017/07/06 14:47:18
Done.
|
| + // PLACEHOLDER: This operation will be cancellable. |
| + if ([weakSelf.item.tabID isEqualToString:item.tabID]) { |
| + [weakSelf.snapshotButton |
| + setImage:snapshot |
| + forState:UIControlStateNormal]; |
| + } |
| + }]; |
| } |
| -#pragma mark - Private |
| +#pragma mark - Private methods |
| - (void)setupSelectedBackgroundView { |
| self.selectedBackgroundView = [[UIView alloc] init]; |