Commit a1c2aee1 authored by adamta's avatar adamta Committed by Commit Bot

[iOS] Only present IPH if feed menu button was created

The IPH bubble for the Discover feed should only be shown if the NTP
has been created with the Discover feed. This can be determined by
checking if the named guide for the Discover feed menu button has been
created.

Bug: 1132757
Change-Id: I0bbf35fba8fb49fcb080ce581f3bf953d56ce0f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2434910
Commit-Queue: Adam Trudeau-Arcaro <adamta@google.com>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Reviewed-by: default avataredchin <edchin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812821}
parent 55ebd355
......@@ -163,11 +163,7 @@ const CGFloat kBubblePresentationDelay = 1;
// The bottom toolbar and Discover feed header menu don't use the
// isUserEngaged, so don't check if the user is engaged here.
[self presentBottomToolbarTipBubble];
// TODO(crbug.com/1132757): Reenable this once the DCHECKS for bubble size in
// [BubbleViewControllerPresenter frameForBubbleInRect:atAnchorPoint:] stop
// being hit.
// [self presentDiscoverFeedHeaderTipBubble];
[self presentDiscoverFeedHeaderTipBubble];
}
- (void)presentLongPressBubble {
......@@ -264,9 +260,6 @@ presentBubbleForFeature:(const base::Feature&)feature
// Presents a bubble associated with the Discover feed header's menu button.
- (void)presentDiscoverFeedHeaderTipBubble {
if (![self canPresentBubble])
return;
BubbleArrowDirection arrowDirection = BubbleArrowDirectionDown;
NSString* text =
l10n_util::GetNSStringWithFixup(IDS_IOS_DISCOVER_FEED_HEADER_IPH);
......@@ -275,6 +268,12 @@ presentBubbleForFeature:(const base::Feature&)feature
view:self.rootViewController.view];
DCHECK(guide);
UIView* menuButton = guide.constrainedView;
// Checks "canPresentBubble" after checking that the NTP with feed is visible.
// This ensures that the feature tracker doesn't trigger the IPH event if the
// bubble isn't shown, which would prevent it from ever being shown again.
if (!menuButton || ![self canPresentBubble]) {
return;
}
CGPoint discoverFeedHeaderAnchor =
[menuButton.superview convertPoint:menuButton.frame.origin toView:nil];
discoverFeedHeaderAnchor.x += menuButton.frame.size.width / 2;
......
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