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

Unified Diff: ios/clean/chrome/browser/ui/tab_collection/tab_collection_tab_cell.mm

Issue 2967083002: [ios] TabCollectionTabCell to use SnapshotCache. (Closed)
Patch Set: Clean up Created 3 years, 5 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/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..2367e1c4cc15b7236043e4e2991acc3042d9901e 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,7 @@ const CGFloat kSelectedBorderWidth = 4.0f;
}
@interface TabCollectionTabCell ()
+@property(nonatomic, strong) TabCollectionItem* item;
@property(nonatomic, strong) UILabel* titleLabel;
@property(nonatomic, strong) UIImageView* favicon;
@property(nonatomic, strong) TabSwitcherButton* snapshotButton;
@@ -38,19 +40,38 @@ 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;
+}
+
+#pragma mark - Public methods
+
+- (void)configureCell:(TabCollectionItem*)item
+ snapshotCache:(SnapshotCache*)snapshotCache {
DCHECK(item);
- _item = item;
+ self.item = item;
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;
+ [snapshotCache
+ retrieveImageForSessionID:self.item.tabID
+ callback:^(UIImage* snapshot) {
+ // 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];

Powered by Google App Engine
This is Rietveld 408576698