Chromium Code Reviews| Index: ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| diff --git a/ios/chrome/browser/ui/dialogs/dialog_presenter.mm b/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| index 5be1336d79c6197da14be2bf9134ffb2e13f5a03..812bdf2c834432e8a0bc8e70a4df6af939a62085 100644 |
| --- a/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| +++ b/ios/chrome/browser/ui/dialogs/dialog_presenter.mm |
| @@ -312,15 +312,23 @@ - (void)runAuthDialogForProtectionSpace:(NSURLProtectionSpace*)protectionSpace |
| } |
| - (void)cancelDialogForWebState:(web::WebState*)webState { |
| - DCHECK_NE(webState, self.presentedDialogWebState); |
| - AlertCoordinator* dialogToCancel = _dialogCoordinatorsForWebStates[webState]; |
| - if (dialogToCancel) { |
| + BOOL cancelingPresentedDialog = webState == self.presentedDialogWebState; |
| + AlertCoordinator* dialogToCancel = |
| + cancelingPresentedDialog ? self.presentedDialogCoordinator |
| + : _dialogCoordinatorsForWebStates[webState]; |
| + DCHECK(!cancelingPresentedDialog || dialogToCancel); |
| + [dialogToCancel executeCancelHandler]; |
| + [dialogToCancel stop]; |
| + |
| + if (cancelingPresentedDialog) { |
|
rohitrao (ping after 24h)
2017/06/12 23:43:50
Should we DCHECK(_dialogCoordinatorsForWebStates[w
kkhorimoto
2017/06/13 00:10:13
Done.
|
| + // Simulate a button tap to trigger showing the next dialog. |
|
rohitrao (ping after 24h)
2017/06/12 23:43:50
Can a single WebState have multiple dialogs queued
kkhorimoto
2017/06/13 00:10:13
This class was built on the assumption that it was
|
| + [self buttonWasTappedForCoordinator:dialogToCancel]; |
|
rohitrao (ping after 24h)
2017/06/12 23:43:50
It feels a little weird to call a function with th
kkhorimoto
2017/06/13 00:10:13
I renamed it to |-dialogCoordinatorWasStopped:|, w
|
| + } else if (dialogToCancel) { |
| + // Clean up queued state. |
| auto it = |
| std::find(_queuedWebStates.begin(), _queuedWebStates.end(), webState); |
| DCHECK(it != _queuedWebStates.end()); |
| _queuedWebStates.erase(it); |
| - [dialogToCancel executeCancelHandler]; |
| - [dialogToCancel stop]; |
| _dialogCoordinatorsForWebStates.erase(webState); |
| } |
| } |