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..ff196620aeda88ecf4ce751bb2ff1731b3fc7b9d |
--- /dev/null |
+++ b/ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_generator.mm |
@@ -0,0 +1,33 @@ |
+// 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) { |
+ __weak Tab* weakTab = tab; |
+ ThumbnailGeneratorBlock generator = ^UIImage*(CGSize const& size) { |
+ Tab* strongTab = weakTab; |
+ // Do not generate thumbnails for incognito tabs. |
+ if (strongTab.browserState->IsOffTheRecord()) |
Olivier
2017/01/24 16:54:05
browser state is a C++ object.
If strongTab is nil
Olivier
2017/01/24 16:54:05
nit: I don't think tab can change between incognit
jif
2017/01/25 15:17:29
oops
jif
2017/01/25 15:17:29
Ack.
Because I don't like returning nil blocks, I'
|
+ return nil; |
+ UIImage* snapshot = |
+ [strongTab generateSnapshotWithOverlay:NO visibleFrameOnly:YES]; |
+ UIImage* thumbnail = |
+ ResizeImage(snapshot, size, ProjectionMode::kAspectFillAlignTop, YES); |
+ return thumbnail; |
+ }; |
+ return generator; |
+} |
+ |
+} // namespace activity_services |