Commit bde0a25f authored by Chris Lu's avatar Chris Lu Committed by Commit Bot

[ios] Remove highlight from Infobarbadge when InfoBarModal is dismissed

When a non-coordinator dismissal of the InfoBarModal (i.e. via shortcut)
occurs, this change informs the coordinator of the dismissal so the
proper cleanup can happen and the badge state can be set.

Bug: 911864
Change-Id: Ic1b9b8091e64d2f884963b9bfa656dccccf1c291
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1601565Reviewed-by: default avatarRohit Rao <rohitrao@chromium.org>
Reviewed-by: default avatarChris Lu <thegreenfrog@chromium.org>
Reviewed-by: default avatarSergio Collazos <sczs@chromium.org>
Commit-Queue: Chris Lu <thegreenfrog@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658251}
parent 1becd99a
...@@ -213,10 +213,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -213,10 +213,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
// Deselect infobar badge in parallel with modal dismissal. // Deselect infobar badge in parallel with modal dismissal.
[self.badgeDelegate infobarModalWillDismiss]; [self.badgeDelegate infobarModalWillDismiss];
__weak __typeof(self) weakSelf = self; __weak __typeof(self) weakSelf = self;
ProceduralBlock modalCleanUp = ^{
weakSelf.modalTransitionDriver = nil;
[weakSelf infobarWasDismissed];
};
// 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
...@@ -225,7 +221,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -225,7 +221,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
[self.bannerViewController [self.bannerViewController
dismissViewControllerAnimated:animated dismissViewControllerAnimated:animated
completion:^{ completion:^{
modalCleanUp();
[weakSelf [weakSelf
dismissInfobarBannerAnimated:NO dismissInfobarBannerAnimated:NO
completion:completion]; completion:completion];
...@@ -233,7 +228,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -233,7 +228,6 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
} else { } else {
[self.baseViewController dismissViewControllerAnimated:animated [self.baseViewController dismissViewControllerAnimated:animated
completion:^{ completion:^{
modalCleanUp();
if (completion) if (completion)
completion(); completion();
}]; }];
...@@ -244,6 +238,15 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0; ...@@ -244,6 +238,15 @@ const CGFloat kBannerOverlapWithOmnibox = 5.0;
} }
} }
- (void)modalInfobarWasDismissed:(id)sender {
// infobarModalWillDismiss call is needed, because sometimes the
// baseViewController will dismiss the modal without going through the
// coordinator.
[self.badgeDelegate infobarModalWillDismiss];
self.modalTransitionDriver = nil;
[self infobarWasDismissed];
}
#pragma mark InfobarModalPositioner #pragma mark InfobarModalPositioner
- (CGFloat)modalHeight { - (CGFloat)modalHeight {
......
...@@ -21,6 +21,9 @@ ...@@ -21,6 +21,9 @@
// action. // action.
- (void)modalInfobarButtonWasAccepted:(id)sender; - (void)modalInfobarButtonWasAccepted:(id)sender;
// Called when the InfobarModal was dismissed.
- (void)modalInfobarWasDismissed:(id)sender;
@end @end
#endif // IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_MODAL_DELEGATE_H_ #endif // IOS_CHROME_BROWSER_UI_INFOBARS_MODALS_INFOBAR_MODAL_DELEGATE_H_
...@@ -52,6 +52,11 @@ ...@@ -52,6 +52,11 @@
self.navigationItem.rightBarButtonItem = settingsButton; self.navigationItem.rightBarButtonItem = settingsButton;
} }
- (void)viewDidDisappear:(BOOL)animated {
[self.infobarModalDelegate modalInfobarWasDismissed:self];
[super viewDidDisappear:animated];
}
#pragma mark - Private Methods #pragma mark - Private Methods
- (void)dismissInfobarModal:(UIButton*)sender { - (void)dismissInfobarModal:(UIButton*)sender {
......
...@@ -89,6 +89,11 @@ typedef NS_ENUM(NSInteger, ItemType) { ...@@ -89,6 +89,11 @@ typedef NS_ENUM(NSInteger, ItemType) {
self.tableView.contentSize.height > self.view.frame.size.height; self.tableView.contentSize.height > self.view.frame.size.height;
} }
- (void)viewDidDisappear:(BOOL)animated {
[self.infobarModalDelegate modalInfobarWasDismissed:self];
[super viewDidDisappear:animated];
}
#pragma mark - TableViewModel #pragma mark - TableViewModel
- (void)loadModel { - (void)loadModel {
......
// Copyright 2016 The Chromium Authors. All rights reserved. // Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
......
...@@ -147,4 +147,7 @@ NSString* const kInfobarBannerPresentedModalLabel = @"Modal Infobar"; ...@@ -147,4 +147,7 @@ NSString* const kInfobarBannerPresentedModalLabel = @"Modal Infobar";
completion:nil]; completion:nil];
} }
- (void)modalInfobarWasDismissed:(id)sender {
}
@end @end
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