Commit a114706d authored by edchin's avatar edchin Committed by Commit Bot

[ios] Cleanup SnapshotTabHelper deprecated method

This CL removes an unused deprecated method in SnapshotTabHelper.

Bug: 917929
Change-Id: Iba8cf2864790b5a24279cfd846695e7a21893d25
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2376545Reviewed-by: default avatarJustin Cohen <justincohen@chromium.org>
Commit-Queue: edchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801617}
parent c0d246f0
...@@ -61,12 +61,6 @@ class SnapshotTabHelper : public infobars::InfoBarManager::Observer, ...@@ -61,12 +61,6 @@ class SnapshotTabHelper : public infobars::InfoBarManager::Observer,
// if snapshot generation fails. // if snapshot generation fails.
void UpdateSnapshotWithCallback(void (^callback)(UIImage*)); void UpdateSnapshotWithCallback(void (^callback)(UIImage*));
// DEPRECATED(crbug.com/917929): Use the asynchronous function
// |UpdateSnapshotWithCallback()| for all new callsites.
// Generates a new snapshot, updates the snapshot cache, and returns the new
// snapshot image. Returns nil if snapshot generation fails.
UIImage* UpdateSnapshot();
// Generates a new snapshot without any overlays, and returns the new snapshot // Generates a new snapshot without any overlays, and returns the new snapshot
// image. This does not update the snapshot cache. Returns nil if snapshot // image. This does not update the snapshot cache. Returns nil if snapshot
// generation fails. // generation fails.
......
...@@ -86,17 +86,13 @@ void SnapshotTabHelper::UpdateSnapshotWithCallback(void (^callback)(UIImage*)) { ...@@ -86,17 +86,13 @@ void SnapshotTabHelper::UpdateSnapshotWithCallback(void (^callback)(UIImage*)) {
} }
// Use the UIKit-based snapshot API as a fallback when the WKWebView API is // Use the UIKit-based snapshot API as a fallback when the WKWebView API is
// unavailable. // unavailable.
UIImage* image = UpdateSnapshot(); UIImage* image = [snapshot_generator_ updateSnapshot];
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
if (callback) if (callback)
callback(image); callback(image);
}); });
} }
UIImage* SnapshotTabHelper::UpdateSnapshot() {
return [snapshot_generator_ updateSnapshot];
}
UIImage* SnapshotTabHelper::GenerateSnapshotWithoutOverlays() { UIImage* SnapshotTabHelper::GenerateSnapshotWithoutOverlays() {
return [snapshot_generator_ generateSnapshotWithOverlays:NO]; return [snapshot_generator_ generateSnapshotWithOverlays:NO];
} }
......
...@@ -290,14 +290,24 @@ TEST_F(SnapshotTabHelperTest, RetrieveGreySnapshotGenerate) { ...@@ -290,14 +290,24 @@ TEST_F(SnapshotTabHelperTest, RetrieveGreySnapshotGenerate) {
EXPECT_EQ(delegate_.snapshotTakenCount, 1u); EXPECT_EQ(delegate_.snapshotTakenCount, 1u);
} }
// Tests that UpdateSnapshot ignores any cached snapshots, generate a new one // Tests that UpdateSnapshotWithCallback ignores any cached snapshots, generate
// and updates the cache. // a new one and updates the cache.
TEST_F(SnapshotTabHelperTest, UpdateSnapshot) { TEST_F(SnapshotTabHelperTest, UpdateSnapshotWithCallback) {
SetCachedSnapshot( SetCachedSnapshot(
UIImageWithSizeAndSolidColor(kDefaultSnapshotSize, [UIColor greenColor])); UIImageWithSizeAndSolidColor(kDefaultSnapshotSize, [UIColor greenColor]));
UIImage* original_cached_snapshot = GetCachedSnapshot();
UIImage* snapshot = base::RunLoop run_loop;
SnapshotTabHelper::FromWebState(&web_state_)->UpdateSnapshot(); base::RunLoop* run_loop_ptr = &run_loop;
__block UIImage* snapshot = nil;
SnapshotTabHelper::FromWebState(&web_state_)
->UpdateSnapshotWithCallback(^(UIImage* image) {
snapshot = image;
run_loop_ptr->Quit();
});
run_loop.Run();
ASSERT_TRUE(snapshot); ASSERT_TRUE(snapshot);
EXPECT_TRUE(CGSizeEqualToSize(snapshot.size, kWebStateViewSize)); EXPECT_TRUE(CGSizeEqualToSize(snapshot.size, kWebStateViewSize));
...@@ -305,6 +315,7 @@ TEST_F(SnapshotTabHelperTest, UpdateSnapshot) { ...@@ -305,6 +315,7 @@ TEST_F(SnapshotTabHelperTest, UpdateSnapshot) {
UIImage* cached_snapshot = GetCachedSnapshot(); UIImage* cached_snapshot = GetCachedSnapshot();
EXPECT_TRUE(UIImagesAreEqual(snapshot, cached_snapshot)); EXPECT_TRUE(UIImagesAreEqual(snapshot, cached_snapshot));
EXPECT_FALSE(UIImagesAreEqual(snapshot, original_cached_snapshot));
EXPECT_EQ(delegate_.snapshotTakenCount, 1u); EXPECT_EQ(delegate_.snapshotTakenCount, 1u);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment