Commit 4abe4b62 authored by edchin's avatar edchin Committed by Commit Bot

[ios] Plumb SnapshotCache into tab grid.

BUG=686770

Review-Url: https://codereview.chromium.org/2971113002
Cr-Commit-Position: refs/heads/master@{#485145}
parent 6b409cea
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h" #import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h"
@class SnapshotCache;
// Controller for a scrolling view displaying square cells that represent // Controller for a scrolling view displaying square cells that represent
// the user's open tabs. // the user's open tabs.
@interface TabCollectionViewController @interface TabCollectionViewController
...@@ -18,6 +20,8 @@ ...@@ -18,6 +20,8 @@
// Model for collection view. // Model for collection view.
@property(nonatomic, strong, readonly) @property(nonatomic, strong, readonly)
NSMutableArray<TabCollectionItem*>* items; NSMutableArray<TabCollectionItem*>* items;
// Cache used to retrieve snapshot images for tab cells.
@property(nonatomic, weak) SnapshotCache* snapshotCache;
@end @end
#endif // IOS_CLEAN_CHROME_BROWSER_UI_TAB_COLLECTION_TAB_COLLECTION_VIEW_CONTROLLER_H_ #endif // IOS_CLEAN_CHROME_BROWSER_UI_TAB_COLLECTION_TAB_COLLECTION_VIEW_CONTROLLER_H_
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
@synthesize tabs = _tabs; @synthesize tabs = _tabs;
@synthesize items = _items; @synthesize items = _items;
@synthesize selectedIndex = _selectedIndex; @synthesize selectedIndex = _selectedIndex;
@synthesize snapshotCache = _snapshotCache;
#pragma mark - UIViewController #pragma mark - UIViewController
...@@ -118,8 +119,7 @@ ...@@ -118,8 +119,7 @@
[cell setSessionType:TabSwitcherSessionType::REGULAR_SESSION]; [cell setSessionType:TabSwitcherSessionType::REGULAR_SESSION];
DCHECK_LE(indexPath.item, INT_MAX); DCHECK_LE(indexPath.item, INT_MAX);
int index = static_cast<int>(indexPath.item); int index = static_cast<int>(indexPath.item);
// PLACEHOLDER: SnapshotCache will be passed into the cell. [cell configureCell:self.items[index] snapshotCache:self.snapshotCache];
[cell configureCell:self.items[index] snapshotCache:nil];
return cell; return cell;
} }
...@@ -194,8 +194,7 @@ ...@@ -194,8 +194,7 @@
TabCollectionTabCell* cell = base::mac::ObjCCastStrict<TabCollectionTabCell>( TabCollectionTabCell* cell = base::mac::ObjCCastStrict<TabCollectionTabCell>(
[self.tabs cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index [self.tabs cellForItemAtIndexPath:[NSIndexPath indexPathForItem:index
inSection:0]]); inSection:0]]);
// PLACEHOLDER: SnapshotCache will be passed into the cell. [cell configureCell:self.items[index] snapshotCache:self.snapshotCache];
[cell configureCell:self.items[index] snapshotCache:nil];
} }
- (void)populateItems:(NSArray<TabCollectionItem*>*)items - (void)populateItems:(NSArray<TabCollectionItem*>*)items
......
...@@ -16,6 +16,7 @@ source_set("tab_grid") { ...@@ -16,6 +16,7 @@ source_set("tab_grid") {
":tab_grid_ui", ":tab_grid_ui",
"//base", "//base",
"//ios/chrome/browser/browser_state", "//ios/chrome/browser/browser_state",
"//ios/chrome/browser/snapshots",
"//ios/chrome/browser/web_state_list", "//ios/chrome/browser/web_state_list",
"//ios/clean/chrome/browser", "//ios/clean/chrome/browser",
"//ios/clean/chrome/browser/ui/commands", "//ios/clean/chrome/browser/ui/commands",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/mac/foundation_util.h" #include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h" #include "base/strings/sys_string_conversions.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h" #include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/snapshots/snapshot_cache_factory.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h" #import "ios/chrome/browser/web_state_list/web_state_list.h"
#import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h" #import "ios/clean/chrome/browser/ui/commands/context_menu_commands.h"
#import "ios/clean/chrome/browser/ui/commands/settings_commands.h" #import "ios/clean/chrome/browser/ui/commands/settings_commands.h"
...@@ -43,6 +44,7 @@ ...@@ -43,6 +44,7 @@
@property(nonatomic, weak) TabCoordinator* activeTabCoordinator; @property(nonatomic, weak) TabCoordinator* activeTabCoordinator;
@property(nonatomic, readonly) WebStateList& webStateList; @property(nonatomic, readonly) WebStateList& webStateList;
@property(nonatomic, strong) TabGridMediator* mediator; @property(nonatomic, strong) TabGridMediator* mediator;
@property(nonatomic, readonly) SnapshotCache* snapshotCache;
@end @end
@implementation TabGridCoordinator @implementation TabGridCoordinator
...@@ -58,6 +60,11 @@ ...@@ -58,6 +60,11 @@
return self.browser->web_state_list(); return self.browser->web_state_list();
} }
- (SnapshotCache*)snapshotCache {
return SnapshotCacheFactory::GetForBrowserState(
self.browser->browser_state());
}
#pragma mark - BrowserCoordinator #pragma mark - BrowserCoordinator
- (void)start { - (void)start {
...@@ -71,6 +78,7 @@ ...@@ -71,6 +78,7 @@
self.viewController = [[TabGridViewController alloc] init]; self.viewController = [[TabGridViewController alloc] init];
self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher()); self.viewController.dispatcher = static_cast<id>(self.browser->dispatcher());
self.viewController.snapshotCache = self.snapshotCache;
self.mediator.consumer = self.viewController; self.mediator.consumer = self.viewController;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment