Commit 3658ad31 authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Add infobarActionInProgress property to InfobarCoordinator

This new property will be important for Infobars whose actions
will take some time and require the banner persisting to visualize
that process.

This change also adds InfobarTranslateCoordinator as implementing
InfobarCoordinatorImplementation.

Bug: 1014959
Change-Id: Iaa21fd9f3025e9797f9d0b63f6337efd0e3cb89a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1899635
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713300}
parent 69ab65d4
......@@ -103,10 +103,14 @@
// NO-OP.
}
- (void)dismissBannerWhenInteractionIsFinished {
- (void)dismissBannerIfReady {
[self.bannerViewController dismissWhenInteractionIsFinished];
}
- (BOOL)infobarActionInProgress {
return NO;
}
- (void)performInfobarAction {
self.confirmInfobarDelegate->Accept();
self.infobarAccepted = YES;
......
......@@ -66,10 +66,6 @@ enum class InfobarBannerPresentationState;
// Present the InfobarModal using |self.baseViewController|.
- (void)presentInfobarModal;
// Dismisses the InfobarBanner after the user is no longer interacting with it.
// e.g. No in progress touch gestures,etc. The dismissal will be animated.
- (void)dismissInfobarBannerAfterInteraction;
// Dismisses the InfobarBanner immediately, if none is being presented
// |completion| will still run.
- (void)dismissInfobarBannerAnimated:(BOOL)animated
......
......@@ -159,7 +159,7 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
}
__weak InfobarCoordinator* weakSelf = self;
self.dismissBannerBlock = ^(void) {
[weakSelf dismissInfobarBannerAfterInteraction];
[weakSelf dismissInfobarBannerIfReady];
weakSelf.dismissBannerBlock = nil;
};
dispatch_after(popTime, dispatch_get_main_queue(), self.dismissBannerBlock);
......@@ -193,12 +193,6 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
}
}
- (void)dismissInfobarBannerAfterInteraction {
if (!self.modalTransitionDriver) {
[self dismissBannerWhenInteractionIsFinished];
}
}
- (void)dismissInfobarBannerAnimated:(BOOL)animated
completion:(void (^)())completion {
[self dismissInfobarBanner:self animated:animated completion:completion];
......@@ -285,7 +279,13 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
self.bannerTransitionDriver = nil;
animatedFullscreenDisabler_ = nullptr;
[self infobarWasDismissed];
[self.infobarContainer childCoordinatorBannerWasDismissed:self];
if (!self.infobarActionInProgress) {
// Only inform InfobarContainer that the Infobar banner presentation is
// finished if it is not still executing the Infobar action. That way, the
// container won't start presenting a queued Infobar's banner when the
// current Infobar hasn't finished.
[self.infobarContainer childCoordinatorBannerFinishedPresented:self];
}
}
#pragma mark InfobarBannerPositioner
......@@ -398,10 +398,15 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
NOTREACHED() << "Subclass must implement.";
}
- (void)dismissBannerWhenInteractionIsFinished {
- (void)dismissBannerIfReady {
NOTREACHED() << "Subclass must implement.";
}
- (BOOL)infobarActionInProgress {
NOTREACHED() << "Subclass must implement.";
return NO;
}
- (void)performInfobarAction {
NOTREACHED() << "Subclass must implement.";
}
......@@ -421,6 +426,15 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
#pragma mark - Private
// Dismisses the Infobar banner if it is ready. i.e. the user is no longer
// interacting with it or the Infobar action is still in progress. The dismissal
// will be animated.
- (void)dismissInfobarBannerIfReady {
if (!self.modalTransitionDriver) {
[self dismissBannerIfReady];
}
}
// |presentingViewController| presents the InfobarModal using |driver|. If
// Modal is presented successfully |completion| will be executed.
- (void)presentInfobarModalFrom:(UIViewController*)presentingViewController
......
......@@ -26,9 +26,15 @@
// Performs any actions related to an Infobar Modal presentation.
- (void)infobarModalPresentedFromBanner:(BOOL)presentedFromBanner;
// Dismisses the InfobarBanner once there's no interaction in progress. An
// interaction is any user initiated behavior with the Banner.
- (void)dismissBannerWhenInteractionIsFinished;
// Dismisses the InfobarBanner if not currently being used. A user could be
// interacting with the banner or the Infobar may still be using the banner to
// present information (i.e. infobarActionInProgress is YES).
- (void)dismissBannerIfReady;
// YES if the infobar action has been started and has not finished yet (i.e.
// Translate is in progress). If the Infobar action is not async, this should
// most likely always return NO.
- (BOOL)infobarActionInProgress;
// Performs the main Infobar action. e.g. "Save Password", "Restore",etc.
- (void)performInfobarAction;
......
......@@ -171,10 +171,14 @@
self.passwordInfoBarDelegate->InfobarPresenting(NO /*automatic*/);
}
- (void)dismissBannerWhenInteractionIsFinished {
- (void)dismissBannerIfReady {
[self.bannerViewController dismissWhenInteractionIsFinished];
}
- (BOOL)infobarActionInProgress {
return NO;
}
- (void)performInfobarAction {
self.passwordInfoBarDelegate->Accept();
self.infobarAccepted = YES;
......
......@@ -129,10 +129,14 @@
// between automatic and manual presentation.
}
- (void)dismissBannerWhenInteractionIsFinished {
- (void)dismissBannerIfReady {
[self.bannerViewController dismissWhenInteractionIsFinished];
}
- (BOOL)infobarActionInProgress {
return NO;
}
- (void)infobarBannerWillBeDismissed:(BOOL)userInitiated {
// TODO(crbug.com/1014652): Record metrics here if there's a distinction
// between ignoring or dismissing the Infobar.
......
......@@ -47,6 +47,9 @@
// Tracks user actions taken throughout Translate lifetime.
@property(nonatomic, assign) UserAction userAction;
// YES if translate is currently in progress
@property(nonatomic, assign) BOOL translateInProgress;
@end
@implementation TranslateInfobarCoordinator
......@@ -54,6 +57,8 @@
@synthesize bannerViewController = _bannerViewController;
// Synthesize since readonly property from superclass is changed to readwrite.
@synthesize modalViewController = _modalViewController;
// Synthesized from InfobarCoordinatorImplementation
@synthesize translateInProgress = _translateInProgress;
- (instancetype)initWithInfoBarDelegate:
(translate::TranslateInfoBarDelegate*)infoBarDelegate {
......@@ -142,8 +147,15 @@
// TODO(crbug.com/1014959): implement
}
- (void)dismissBannerWhenInteractionIsFinished {
- (void)dismissBannerIfReady {
if (!self.translateInProgress) {
// Only attempt to dismiss banner if Translate is not in progress.
[self.bannerViewController dismissWhenInteractionIsFinished];
}
}
- (BOOL)infobarActionInProgress {
return self.translateInProgress;
}
- (void)infobarBannerWillBeDismissed:(BOOL)userInitiated {
......
......@@ -14,8 +14,8 @@
@protocol InfobarContainer
// Informs the InfobarContainerCoordinator that |infobarCoordinator| has
// dismissed its banner.
- (void)childCoordinatorBannerWasDismissed:
// finished presenting its banner(s).
- (void)childCoordinatorBannerFinishedPresented:
(InfobarCoordinator*)infobarCoordinator;
// Informs the InfobarContainerCoordinator that |infobarCoordinator| has
......
......@@ -245,7 +245,7 @@
#pragma mark InfobarContainer
- (void)childCoordinatorBannerWasDismissed:
- (void)childCoordinatorBannerFinishedPresented:
(InfobarCoordinator*)infobarCoordinator {
InfobarCoordinator* coordinator =
[self.infobarCoordinatorsToPresent firstObject];
......
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