Commit 510dff87 authored by sczs's avatar sczs Committed by Commit Bot

[ios] Dismiss the InfobarModal after Never for This Site is tapped.

The password InfobarModal was never getting dismissed after deleting
the backing Infobar delegate. It was only working previously because deleting
the delegate dismissed the banner which had a side effect of dismissing the
modal.

After changes on https://crrev.com/c/1670393/ the banner will no longer dismiss
the modal, so now we have to explicitly dismiss the Modal before deleting
the backing Infobar delegate.

This CL also dismisses the Modal if the detachView gets called. This way
the user won't be able to manipulate the Modal/Infobar once the Infobar
has been destroyed.

Bug: 978384
Change-Id: I0f8578bab082b16887111328931a356870455258
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1676912Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Commit-Queue: Sergio Collazos <sczs@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672526}
parent 8469697c
...@@ -37,6 +37,8 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0; ...@@ -37,6 +37,8 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.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)
...@@ -173,7 +175,8 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0; ...@@ -173,7 +175,8 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
} }
- (void)detachView { - (void)detachView {
[self dismissInfobarBanner:self animated:YES completion:nil]; [self dismissInfobarBanner:self animated:NO completion:nil];
[self dismissInfobarModal:self animated:NO completion:nil];
[self stop]; [self stop];
} }
...@@ -269,14 +272,14 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0; ...@@ -269,14 +272,14 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
DCHECK(self.baseViewController); DCHECK(self.baseViewController);
if (self.baseViewController.presentedViewController) { if (self.baseViewController.presentedViewController) {
// Deselect infobar badge in parallel with modal dismissal.
[self.badgeDelegate infobarModalWillDismiss:self.infobarType];
__weak __typeof(self) weakSelf = self;
// If the Modal is being presented by the Banner, call dismiss on it. // If the Modal is being presented by the Banner, call dismiss on it.
// This way the modal dismissal will animate correctly and the completion // This way the modal dismissal will animate correctly and the completion
// block cleans up the banner correctly. // block cleans up the banner correctly.
if (self.bannerViewController.presentedViewController) { if (self.baseViewController.presentedViewController ==
self.bannerViewController) {
// Deselect infobar badge in parallel with modal dismissal.
[self.badgeDelegate infobarModalWillDismiss:self.infobarType];
__weak __typeof(self) weakSelf = self;
[self.bannerViewController [self.bannerViewController
dismissViewControllerAnimated:animated dismissViewControllerAnimated:animated
completion:^{ completion:^{
...@@ -284,7 +287,11 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0; ...@@ -284,7 +287,11 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0;
dismissInfobarBannerAnimated:NO dismissInfobarBannerAnimated:NO
completion:completion]; completion:completion];
}]; }];
} else {
} else if (self.baseViewController.presentedViewController ==
self.modalNavigationController) {
// Deselect infobar badge in parallel with modal dismissal.
[self.badgeDelegate infobarModalWillDismiss:self.infobarType];
[self.baseViewController dismissViewControllerAnimated:animated [self.baseViewController dismissViewControllerAnimated:animated
completion:^{ completion:^{
if (completion) if (completion)
...@@ -359,6 +366,7 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.0; ...@@ -359,6 +366,7 @@ const CGFloat kiPadBannerOverlapWithOmnibox = 10.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:nil]; completion:nil];
......
...@@ -196,9 +196,13 @@ ...@@ -196,9 +196,13 @@
- (void)neverSaveCredentialsForCurrentSite { - (void)neverSaveCredentialsForCurrentSite {
self.passwordInfoBarDelegate->Cancel(); self.passwordInfoBarDelegate->Cancel();
// Completely remove the Infobar along with its badge after blacklisting the [self dismissInfobarModal:self
// Website. animated:YES
[self detachView]; completion:^{
// Completely remove the Infobar along with its badge after
// blacklisting the Website.
[self detachView];
}];
} }
- (void)presentPasswordSettings { - (void)presentPasswordSettings {
......
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