Commit 5c4d509b authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Adding animated and completion to abort method for AdvancedSigninSettingsCoordinator

Changing -[AdvancedSigninSettingsCoordinator abortWithDismiss:] to
-[AdvancedSigninSettingsCoordinator abortWithDismiss:animated:completion:]
This is to prepare the main controller to dismiss the SigninInteractionCoordinator.

Related to: http://go/open-url-unity-project

See: crrev.com/c/1621136

Bug: 965463
Change-Id: Idd560498c544a9165a59274f41239fa9c968fd21
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1621172
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662569}
parent 4ee42dd3
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#ifndef IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_ADVANCED_SIGNIN_SETTINGS_COORDINATOR_H_ #ifndef IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_ADVANCED_SIGNIN_SETTINGS_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_ADVANCED_SIGNIN_SETTINGS_COORDINATOR_H_ #define IOS_CHROME_BROWSER_UI_SETTINGS_GOOGLE_SERVICES_ADVANCED_SIGNIN_SETTINGS_COORDINATOR_H_
#import "base/ios/block_types.h"
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h" #import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@class AdvancedSigninSettingsCoordinator; @class AdvancedSigninSettingsCoordinator;
...@@ -42,7 +43,13 @@ extern NSString* const kSyncSettingsCancelButtonId; ...@@ -42,7 +43,13 @@ extern NSString* const kSyncSettingsCancelButtonId;
// sync settings doesn't sign out the user. The sync is left unsetup and doesn't // sync settings doesn't sign out the user. The sync is left unsetup and doesn't
// start. This method does nothing if called twice. // start. This method does nothing if called twice.
// |dismiss|, dismisses the view controller if YES. // |dismiss|, dismisses the view controller if YES.
- (void)abortWithDismiss:(BOOL)dismiss; // |animated|, the view is animated if YES.
// |completion|, this completion block is called after the view is dismissed.
// It will be called even the view is already dismissed. The value
// can be nil.
- (void)abortWithDismiss:(BOOL)dismiss
animated:(BOOL)animated
completion:(ProceduralBlock)completion;
@end @end
......
...@@ -87,18 +87,28 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) { ...@@ -87,18 +87,28 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) {
completion:nil]; completion:nil];
} }
- (void)abortWithDismiss:(BOOL)dismiss { - (void)abortWithDismiss:(BOOL)dismiss
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
if (!self.advancedSigninSettingsNavigationController) { if (!self.advancedSigninSettingsNavigationController) {
if (completion) {
completion();
}
return; return;
} }
DCHECK_EQ(self.advancedSigninSettingsNavigationController, DCHECK_EQ(self.advancedSigninSettingsNavigationController,
self.baseViewController.presentedViewController); self.baseViewController.presentedViewController);
if (dismiss) { if (dismiss) {
[self dismissViewControllerAndFinishWithResult: [self dismissViewControllerAndFinishWithResult:
AdvancedSigninSettingsCoordinatorResultInterrupted]; AdvancedSigninSettingsCoordinatorResultInterrupted
animated:animated
completion:completion];
} else { } else {
[self [self
finishedWithResult:AdvancedSigninSettingsCoordinatorResultInterrupted]; finishedWithResult:AdvancedSigninSettingsCoordinatorResultInterrupted];
if (completion) {
completion();
}
} }
} }
...@@ -212,7 +222,9 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) { ...@@ -212,7 +222,9 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) {
DCHECK_EQ(self.advancedSigninSettingsNavigationController, DCHECK_EQ(self.advancedSigninSettingsNavigationController,
self.baseViewController.presentedViewController); self.baseViewController.presentedViewController);
[self dismissViewControllerAndFinishWithResult: [self dismissViewControllerAndFinishWithResult:
AdvancedSyncSettingsCoordinatorResultConfirm]; AdvancedSyncSettingsCoordinatorResultConfirm
animated:YES
completion:nil];
} }
// Called when a button of |self.cancelConfirmationAlertCoordinator| is pressed. // Called when a button of |self.cancelConfirmationAlertCoordinator| is pressed.
...@@ -222,7 +234,9 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) { ...@@ -222,7 +234,9 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) {
self.cancelConfirmationAlertCoordinator = nil; self.cancelConfirmationAlertCoordinator = nil;
if (cancelSync) { if (cancelSync) {
[self dismissViewControllerAndFinishWithResult: [self dismissViewControllerAndFinishWithResult:
AdvancedSigninSettingsCoordinatorResultCancel]; AdvancedSigninSettingsCoordinatorResultCancel
animated:YES
completion:nil];
} else { } else {
base::RecordAction(base::UserMetricsAction( base::RecordAction(base::UserMetricsAction(
"Signin_Signin_CancelCancelAdvancedSyncSettings")); "Signin_Signin_CancelCancelAdvancedSyncSettings"));
...@@ -232,14 +246,20 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) { ...@@ -232,14 +246,20 @@ typedef NS_ENUM(NSInteger, AdvancedSigninSettingsCoordinatorResult) {
// Dismisses the current view controller with animation, and calls // Dismisses the current view controller with animation, and calls
// -[self finishedWithResult:] with |result|. // -[self finishedWithResult:] with |result|.
- (void)dismissViewControllerAndFinishWithResult: - (void)dismissViewControllerAndFinishWithResult:
(AdvancedSigninSettingsCoordinatorResult)result { (AdvancedSigninSettingsCoordinatorResult)result
animated:(BOOL)animated
completion:(ProceduralBlock)completion {
DCHECK_EQ(self.advancedSigninSettingsNavigationController, DCHECK_EQ(self.advancedSigninSettingsNavigationController,
self.baseViewController.presentedViewController); self.baseViewController.presentedViewController);
[self.baseViewController __weak __typeof(self) weakSelf = self;
dismissViewControllerAnimated:YES ProceduralBlock dismissCompletion = ^() {
completion:^{ [weakSelf finishedWithResult:result];
[self finishedWithResult:result]; if (completion) {
}]; completion();
}
};
[self.baseViewController dismissViewControllerAnimated:animated
completion:dismissCompletion];
} }
@end @end
...@@ -118,12 +118,16 @@ ...@@ -118,12 +118,16 @@
- (void)cancel { - (void)cancel {
[self.controller cancel]; [self.controller cancel];
[self.advancedSigninSettingsCoordinator abortWithDismiss:NO]; [self.advancedSigninSettingsCoordinator abortWithDismiss:NO
animated:YES
completion:nil];
} }
- (void)cancelAndDismiss { - (void)cancelAndDismiss {
[self.controller cancelAndDismiss]; [self.controller cancelAndDismiss];
[self.advancedSigninSettingsCoordinator abortWithDismiss:YES]; [self.advancedSigninSettingsCoordinator abortWithDismiss:YES
animated:YES
completion:nil];
} }
- (BOOL)isActive { - (BOOL)isActive {
......
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