Commit 357cf1f2 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

Adding -[AddAccountSigninCoordinator interruptWithAction:completion:]

Adding implementation for  -[AddAccountSigninCoordinator
interruptWithAction:completion:], and updating SigninCoordinator
to call this method when the sign-in should be canceled.

Also, when -[AddAccountSigninCoordinator stop] is called, the following
instance variable should be nil:
 - signinCompletion
 - identityInteractionManager
 - userSigninCoordinator
 - alertCoordinator
Those variables should set to nil in -[AddAccountSigninCoordinator
runCompletionCallbackWithSigninResult:identity:].

Adding [super stop] and [super start] in start and stop methods of
AddAccountSigninCoordinator.

Bug: 971989
Change-Id: Icdb209a2edab58bd3bc42472534a7f3d4c7b3299
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2046529
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741110}
parent 68e9cfed
......@@ -70,9 +70,35 @@ using signin_metrics::PromoAction;
return self;
}
#pragma mark - SigninCoordinator
- (void)interruptWithAction:(SigninCoordinatorInterruptAction)action
completion:(ProceduralBlock)completion {
DCHECK(self.identityInteractionManager);
switch (action) {
case SigninCoordinatorInterruptActionNoDismiss:
// SSO doesn't support cancel without dismiss, so to make sure the cancel
// is properly done, -[ChromeIdentityInteractionManager
// cancelAndDismissAnimated:NO] has to be called.
case SigninCoordinatorInterruptActionDismissWithoutAnimation:
[self.identityInteractionManager cancelAndDismissAnimated:NO];
break;
case SigninCoordinatorInterruptActionDismissWithAnimation:
// TODO(crbug.com/1051340): SSO doesn't support dismiss completion block.
// To make sure |completion| is called after the SSO view is fully
// dismissed, we need to dismiss without animation.
[self.identityInteractionManager cancelAndDismissAnimated:NO];
break;
}
if (completion) {
completion();
}
}
#pragma mark - ChromeCoordinator
- (void)start {
[super start];
self.identityInteractionManager =
ios::GetChromeBrowserProvider()
->GetChromeIdentityService()
......@@ -92,14 +118,13 @@ using signin_metrics::PromoAction;
}
- (void)stop {
[self.identityInteractionManager cancelAndDismissAnimated:NO];
[self.alertCoordinator executeCancelHandler];
[self.alertCoordinator stop];
self.alertCoordinator = nil;
[self.userSigninCoordinator stop];
self.userSigninCoordinator = nil;
[super stop];
// If one of those 4 DCHECK() fails, -[AddAccountSigninCoordinator
// runCompletionCallbackWithSigninResult] has not been called.
DCHECK(!self.signinCompletion);
DCHECK(!self.identityInteractionManager);
DCHECK(!self.alertCoordinator);
DCHECK(!self.userSigninCoordinator);
}
#pragma mark - ChromeIdentityInteractionManagerDelegate
......@@ -155,11 +180,16 @@ using signin_metrics::PromoAction;
identity:(ChromeIdentity*)identity {
// Cleaning up and calling the |signinCompletion| should be done last.
self.identityInteractionManager = nil;
self.alertCoordinator = nil;
DCHECK(!self.alertCoordinator);
DCHECK(!self.userSigninCoordinator);
if (self.signinCompletion) {
self.signinCompletion(signinResult, identity);
SigninCoordinatorCompletionCallback signinCompletion =
self.signinCompletion;
self.signinCompletion = nil;
// The owner should call the stop method, during the callback.
// |self.signinCompletion| needs to be set to nil before calling it.
signinCompletion(signinResult, identity);
}
}
......
......@@ -127,6 +127,9 @@
- (void)cancel {
[self.controller cancel];
[self.coordinator
interruptWithAction:SigninCoordinatorInterruptActionNoDismiss
completion:nil];
[self.coordinator stop];
self.coordinator = nil;
[self.advancedSigninSettingsCoordinator abortWithDismiss:NO
......@@ -136,6 +139,9 @@
- (void)cancelAndDismiss {
[self.controller cancelAndDismiss];
[self.coordinator
interruptWithAction:SigninCoordinatorInterruptActionDismissWithAnimation
completion:nil];
[self.coordinator stop];
self.coordinator = nil;
[self.advancedSigninSettingsCoordinator abortWithDismiss:YES
......
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