[iOS][ffr] Prevent ptr iph from showing when overscroll not supported
This CL checks whether overscroll is supported before attempting to
show the PTR IPH. To do so, a new delegate method is added to Bubble-
PresenterDelegate.
Bug: N/A
Change-Id: I4fb321fd438ae4b97bf3440fc4d8303d861c9b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5664376
Commit-Queue: Ginny Huang <ginnyhuang@chromium.org>
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Reviewed-by: Federica Germinario <fedegermi@google.com>
Auto-Submit: Ginny Huang <ginnyhuang@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1320914}
diff --git a/ios/chrome/browser/browser_view/ui_bundled/browser_coordinator.mm b/ios/chrome/browser/browser_view/ui_bundled/browser_coordinator.mm
index ee12760..f03a160 100644
--- a/ios/chrome/browser/browser_view/ui_bundled/browser_coordinator.mm
+++ b/ios/chrome/browser/browser_view/ui_bundled/browser_coordinator.mm
@@ -788,6 +788,13 @@
#pragma mark - Private
+// Returns whether overscroll actions should be allowed. When screeen size is
+// not regular, they should be enabled.
+- (BOOL)shouldAllowOverscrollActions {
+ return !_toolbarAccessoryPresenter.presenting &&
+ !IsRegularXRegularSizeClass(self.viewController);
+}
+
// Stops the password protection coordinator.
- (void)stopPasswordProtectionCoordinator {
[self.passwordProtectionCoordinator stop];
@@ -3407,20 +3414,26 @@
#pragma mark - BubblePresenterDelegate
- (BOOL)rootViewVisibleForBubblePresenter:(BubblePresenter*)bubblePresenter {
- DCHECK(bubblePresenter == _bubblePresenter);
+ CHECK(bubblePresenter == _bubblePresenter);
return self.viewController.viewVisible;
}
- (BOOL)isNTPActiveForBubblePresenter:(BubblePresenter*)bubblePresenter {
- DCHECK(bubblePresenter == _bubblePresenter);
+ CHECK(bubblePresenter == _bubblePresenter);
return self.NTPCoordinator.isNTPActiveForCurrentWebState;
}
- (BOOL)isNTPScrolledToTopForBubblePresenter:(BubblePresenter*)bubblePresenter {
- DCHECK(bubblePresenter == _bubblePresenter);
+ CHECK(bubblePresenter == _bubblePresenter);
return [self.NTPCoordinator isScrolledToTop];
}
+- (BOOL)isOverscrollActionsSupportedForBubblePresenter:
+ (BubblePresenter*)bubblePresenter {
+ CHECK(bubblePresenter == _bubblePresenter);
+ return [self shouldAllowOverscrollActions];
+}
+
- (void)bubblePresenterDidPerformPullToRefreshGesture:
(BubblePresenter*)bubblePresenter {
if (!self.activeWebState) {
@@ -3475,9 +3488,7 @@
- (BOOL)shouldAllowOverscrollActionsForOverscrollActionsController:
(OverscrollActionsController*)controller {
- // When screeen size is not regular, overscroll actions should be enabled.
- return !_toolbarAccessoryPresenter.presenting &&
- !IsRegularXRegularSizeClass(self.viewController);
+ return [self shouldAllowOverscrollActions];
}
- (UIView*)headerViewForOverscrollActionsController:
diff --git a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter.mm b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter.mm
index 28968c0..7e7bc02a 100644
--- a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter.mm
+++ b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter.mm
@@ -584,7 +584,9 @@
}
- (void)presentPullToRefreshGestureInProductHelp {
- if (UIAccessibilityIsVoiceOverRunning() || (![self canPresentBubble])) {
+ if (UIAccessibilityIsVoiceOverRunning() ||
+ (![self.delegate isOverscrollActionsSupportedForBubblePresenter:self]) ||
+ (![self canPresentBubble])) {
// TODO(crbug.com/41494458): Add voice over announcement once fixed.
return;
}
diff --git a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_delegate.h b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_delegate.h
index 13b21c4e..cb112705 100644
--- a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_delegate.h
+++ b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_delegate.h
@@ -19,6 +19,10 @@
// Whether the NTP is scrolled to top.
- (BOOL)isNTPScrolledToTopForBubblePresenter:(BubblePresenter*)bubblePresenter;
+// Whether overscroll actions are supported.
+- (BOOL)isOverscrollActionsSupportedForBubblePresenter:
+ (BubblePresenter*)bubblePresenter;
+
// Notifies the delegate that the user has performed the pull-to-refresh gesture
// as instructed by the in-product help.
- (void)bubblePresenterDidPerformPullToRefreshGesture:
diff --git a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_egtest.mm b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_egtest.mm
index 0a6b35e..2d556e5 100644
--- a/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_egtest.mm
+++ b/ios/chrome/browser/bubble/ui_bundled/bubble_presenter_egtest.mm
@@ -140,11 +140,11 @@
// Tests that the pull-to-refresh IPH is attempted when user reloads the page
// using context menu.
- (void)testPullToRefreshIPHAfterReloadFromContextMenuAndDisappearsOnSwitchTab {
- RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
- /*safari_switcher=*/YES);
if ([ChromeEarlGrey isIPadIdiom]) {
EARL_GREY_TEST_SKIPPED(@"Skipped for iPad.");
}
+ RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
+ /*safari_switcher=*/YES);
[BaseEarlGreyTestCaseAppInterface disableFastAnimation];
GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
@@ -215,6 +215,23 @@
@"Pull to refresh IPH still appeared despite loading fails.");
}
+// Tests that the pull-to-refresh IPH is atttempted when user taps the omnibox
+// to reload the same page, and disappears after the user navigates away.
+- (void)testPullToRefreshIPHShouldNotShowOnRegularXRegular {
+ if (![ChromeEarlGrey isIPadIdiom]) {
+ EARL_GREY_TEST_SKIPPED(@"Skipped for iPhone.");
+ }
+ RelaunchWithIPHFeature(@"IPH_iOSPullToRefreshFeature",
+ /*safari_switcher=*/YES);
+ [BaseEarlGreyTestCaseAppInterface disableFastAnimation];
+
+ GREYAssertTrue(self.testServer->Start(), @"Server did not start.");
+ [ChromeEarlGrey loadURL:self.testServer->GetURL("/pony.html")];
+ ReloadFromOmnibox();
+ AssertGestureIPHInvisible(
+ @"Pull to refresh IPH showed on regular x regular size class.");
+}
+
// Tests that the swipe back/forward IPH is attempted on navigation, and
// disappears when user leaves the page.
- (void)testSwipeBackForwardIPHShowsOnNavigationAndHidesOnNavigation {