Index: ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.mm |
diff --git a/ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.mm b/ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.mm |
new file mode 100644 |
index 0000000000000000000000000000000000000000..51dcb3eeef0250e6f97885f18aa8be1f19bb8fef |
--- /dev/null |
+++ b/ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.mm |
@@ -0,0 +1,37 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#import "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.h" |
+ |
+#include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
+#import "ios/chrome/browser/tabs/tab.h" |
+#import "ios/chrome/browser/ui/uikit_ui_util.h" |
+ |
+#if !defined(__has_feature) || !__has_feature(objc_arc) |
+#error "This file requires ARC support." |
+#endif |
+ |
+namespace activity_services { |
+ |
+ThumbnailGeneratorBlock ThumbnailGeneratorForTab(Tab* tab) { |
+ DCHECK(tab); |
+ // Do not generate thumbnails for incognito tabs. |
+ if (tab.browserState->IsOffTheRecord()) { |
+ return ^UIImage*(CGSize const& size) { return nil; }; |
+ } else { |
+ __weak Tab* weakTab = tab; |
+ return ^UIImage*(CGSize const& size) { |
+ Tab* strongTab = weakTab; |
+ if (!strongTab) |
+ return nil; |
+ UIImage* snapshot = |
+ [strongTab generateSnapshotWithOverlay:NO visibleFrameOnly:YES]; |
marq (ping after 24h)
2017/01/26 16:28:09
Nit: You can just call this method on weakTab here
jif
2017/01/27 11:56:11
The pattern of calling a method on a weak object i
marq (ping after 24h)
2017/01/27 12:52:56
You are of course correct.
You can (and should),
jif
2017/01/27 13:51:54
Done.
|
+ UIImage* thumbnail = |
+ ResizeImage(snapshot, size, ProjectionMode::kAspectFillAlignTop, YES); |
+ return thumbnail; |
+ }; |
+ } |
+} |
+ |
+} // namespace activity_services |