OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" | 5 #import "ios/chrome/browser/snapshots/web_controller_snapshot_helper.h" |
6 | 6 |
7 #import "base/ios/weak_nsobject.h" | 7 #import "base/ios/weak_nsobject.h" |
8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
9 #import "ios/chrome/browser/snapshots/snapshot_manager.h" | 9 #import "ios/chrome/browser/snapshots/snapshot_manager.h" |
10 #import "ios/chrome/browser/tabs/tab.h" | 10 #import "ios/chrome/browser/tabs/tab.h" |
11 #import "ios/chrome/browser/ui/fullscreen_controller.h" | 11 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" |
12 #import "ios/chrome/browser/ui/uikit_ui_util.h" | 12 #import "ios/chrome/browser/ui/uikit_ui_util.h" |
13 #import "ios/web/web_state/ui/crw_web_controller.h" | 13 #import "ios/web/web_state/ui/crw_web_controller.h" |
14 | 14 |
15 @interface WebControllerSnapshotHelper () | 15 @interface WebControllerSnapshotHelper () |
16 | 16 |
17 // Takes a snapshot image for the WebController's current page. Returns an | 17 // Takes a snapshot image for the WebController's current page. Returns an |
18 // autoreleased image cropped and scaled appropriately. Returns a default image | 18 // autoreleased image cropped and scaled appropriately. Returns a default image |
19 // if a snapshot cannot be generated. | 19 // if a snapshot cannot be generated. |
20 - (UIImage*)generateSnapshotOrDefaultForWebController: | 20 - (UIImage*)generateSnapshotOrDefaultForWebController: |
21 (CRWWebController*)webController | 21 (CRWWebController*)webController |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 return snapshot; | 189 return snapshot; |
190 | 190 |
191 UIImage* snapshotToCache = nil; | 191 UIImage* snapshotToCache = nil; |
192 // TODO(crbug.com/370994): Remove all code that references a Tab's delegates | 192 // TODO(crbug.com/370994): Remove all code that references a Tab's delegates |
193 // from this file. | 193 // from this file. |
194 if (visibleFrameOnly || ![_tab fullScreenControllerDelegate]) { | 194 if (visibleFrameOnly || ![_tab fullScreenControllerDelegate]) { |
195 snapshotToCache = snapshot; | 195 snapshotToCache = snapshot; |
196 } else { | 196 } else { |
197 // Crops the bottom of the fullscreen snapshot. | 197 // Crops the bottom of the fullscreen snapshot. |
198 CGRect cropRect = | 198 CGRect cropRect = |
199 CGRectMake(0, [[_tab fullScreenControllerDelegate] headerHeight], | 199 CGRectMake(0, [[_tab tabHeadersDelegate] headerHeightForTab:_tab], |
200 [snapshot size].width, [snapshot size].height); | 200 [snapshot size].width, [snapshot size].height); |
201 snapshotToCache = CropImage(snapshot, cropRect); | 201 snapshotToCache = CropImage(snapshot, cropRect); |
202 } | 202 } |
203 [_snapshotManager setImage:snapshotToCache withSessionID:sessionID]; | 203 [_snapshotManager setImage:snapshotToCache withSessionID:sessionID]; |
204 return snapshot; | 204 return snapshot; |
205 } | 205 } |
206 | 206 |
207 - (UIImage*)generateSnapshotForWebController:(CRWWebController*)webController | 207 - (UIImage*)generateSnapshotForWebController:(CRWWebController*)webController |
208 withOverlays:(NSArray*)overlays | 208 withOverlays:(NSArray*)overlays |
209 visibleFrameOnly:(BOOL)visibleFrameOnly { | 209 visibleFrameOnly:(BOOL)visibleFrameOnly { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 257 } |
258 | 258 |
259 - (UIImage*)cachedSnapshotWithOverlays:(NSArray*)overlays | 259 - (UIImage*)cachedSnapshotWithOverlays:(NSArray*)overlays |
260 visibleFrameOnly:(BOOL)visibleFrameOnly { | 260 visibleFrameOnly:(BOOL)visibleFrameOnly { |
261 return | 261 return |
262 [_coalescingSnapshotContext cachedSnapshotWithOverlays:overlays | 262 [_coalescingSnapshotContext cachedSnapshotWithOverlays:overlays |
263 visibleFrameOnly:visibleFrameOnly]; | 263 visibleFrameOnly:visibleFrameOnly]; |
264 } | 264 } |
265 | 265 |
266 @end | 266 @end |
OLD | NEW |