Index: ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm |
diff --git a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm |
index d99ad201e0063e1c8772362c14301c5839e8c075..248ab6ede62f2c94c3e4700c107927992897b69b 100644 |
--- a/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm |
+++ b/ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.mm |
@@ -4,15 +4,19 @@ |
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_mediator.h" |
+#include "base/mac/bind_objc_block.h" |
#include "base/memory/ptr_util.h" |
#include "base/scoped_observer.h" |
#include "base/strings/sys_string_conversions.h" |
+#import "ios/chrome/browser/snapshots/snapshot_cache.h" |
+#import "ios/chrome/browser/snapshots/snapshot_constants.h" |
#import "ios/chrome/browser/web/tab_id_tab_helper.h" |
#import "ios/chrome/browser/web_state_list/web_state_list.h" |
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_consumer.h" |
#import "ios/clean/chrome/browser/ui/tab_collection/tab_collection_item.h" |
#include "ios/web/public/web_state/web_state.h" |
#import "ios/web/public/web_state/web_state_observer_bridge.h" |
+#include "ui/gfx/image/image.h" |
danakj
2017/07/11 19:14:15
I thought IOS cant depend on skia?
|
#if !defined(__has_feature) || !__has_feature(objc_arc) |
#error "This file requires ARC support." |
@@ -48,6 +52,21 @@ |
#pragma mark - Public |
+- (void)takeSnapshotWithCache:(SnapshotCache*)snapshotCache { |
+ web::WebState* webState = self.webStateList->GetActiveWebState(); |
+ TabIdTabHelper* tabHelper = TabIdTabHelper::FromWebState(webState); |
+ DCHECK(tabHelper); |
+ NSString* tabID = tabHelper->tab_id(); |
+ int index = self.webStateList->active_index(); |
+ __weak TabCollectionMediator* weakSelf = self; |
+ webState->TakeSnapshot(base::BindBlockArc(^(const gfx::Image& snapshot) { |
+ [snapshotCache setImage:snapshot.ToUIImage() |
+ withSessionID:tabID]; |
+ [weakSelf.consumer updateSnapshotAtIndex:index]; |
+ }), |
+ kSnapshotThumbnailSize); |
+} |
+ |
- (void)disconnect { |
_webStateList = nullptr; |
_webStateObserver.reset(); |