Commit eac1ca98 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Prevents InfobarModal from being configured twice.

If an there's an existent modal it means one is currently presented, or in
the process of being presented. Configuring a new one would only cause
InfobarCoordinator to hold pointers to a Modal that won't be presented.

This CL prevents that by stopping any new configuration if a Modal already
exists.

It also removes modalNavigationController since we can get the
NavigationController from the modal.

Bug: 1040066
Change-Id: Ia2da22d67804e39780b19b78af2dcba58fa8a580
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032565Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737468}
parent 440da23e
...@@ -41,8 +41,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -41,8 +41,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
// Delegate that holds the Infobar information and actions. // Delegate that holds the Infobar information and actions.
@property(nonatomic, readonly) infobars::InfoBarDelegate* infobarDelegate; @property(nonatomic, readonly) infobars::InfoBarDelegate* infobarDelegate;
// NavigationController that contains the modalViewController.
@property(nonatomic, weak) UINavigationController* modalNavigationController;
// The transition delegate used by the Coordinator to present the InfobarBanner. // The transition delegate used by the Coordinator to present the InfobarBanner.
// nil if no Banner is being presented. // nil if no Banner is being presented.
@property(nonatomic, strong) @property(nonatomic, strong)
...@@ -387,6 +385,11 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -387,6 +385,11 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
- (void)presentInfobarModalFrom:(UIViewController*)presentingViewController - (void)presentInfobarModalFrom:(UIViewController*)presentingViewController
driver:(InfobarModalTransitionDriver*)driver driver:(InfobarModalTransitionDriver*)driver
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
// |self.modalViewController| only exists while one its being presented, if
// this is the case early return since there's one already being presented.
if (self.modalViewController)
return;
BOOL infobarWasConfigured = [self configureModalViewController]; BOOL infobarWasConfigured = [self configureModalViewController];
if (!infobarWasConfigured) { if (!infobarWasConfigured) {
if (driver.transitionMode == InfobarModalTransitionBanner) { if (driver.transitionMode == InfobarModalTransitionBanner) {
...@@ -400,7 +403,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -400,7 +403,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
initWithRootViewController:self.modalViewController]; initWithRootViewController:self.modalViewController];
navController.transitioningDelegate = driver; navController.transitioningDelegate = driver;
navController.modalPresentationStyle = UIModalPresentationCustom; navController.modalPresentationStyle = UIModalPresentationCustom;
self.modalNavigationController = navController;
[presentingViewController presentViewController:navController [presentingViewController presentViewController:navController
animated:YES animated:YES
completion:completion]; completion:completion];
...@@ -481,7 +483,8 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -481,7 +483,8 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
completion:completion]; completion:completion];
}]; }];
} else if (presentedViewController == self.modalNavigationController) { } else if (presentedViewController ==
self.modalViewController.navigationController) {
[self.baseViewController dismissViewControllerAnimated:animated [self.baseViewController dismissViewControllerAnimated:animated
completion:^{ completion:^{
if (completion) if (completion)
......
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