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

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

Issue 2971093002: [ios] Take snapshot for tab grid. (Closed)
Patch Set: Update unit test. 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_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();

Powered by Google App Engine
This is Rietveld 408576698