[iOS][Signin]Create a function from ShowSigninCommand to SigninCoordinator
This function will allow in future CL to get the correct signin coordinator without having to go through the SceneController nor repeating code. Bug: None Change-Id: I5d2ab4ac3cafe0fd97717178d5bf2d2137c2b742 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6516183 Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Auto-Submit: Arthur Milchior <arthurmilchior@chromium.org> Commit-Queue: Sylvain Defresne <sdefresne@chromium.org> Cr-Commit-Position: refs/heads/main@{#1456950}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b5509f3a5c
commit
d64c2eea6b
ios/chrome/browser
authentication
ui_bundled
shared
coordinator
scene
@ -80,6 +80,7 @@ source_set("signin_impl") {
|
||||
"//ios/chrome/browser/shared/model/browser",
|
||||
"//ios/chrome/browser/shared/model/prefs:pref_names",
|
||||
"//ios/chrome/browser/shared/model/profile:features",
|
||||
"//ios/chrome/browser/shared/public/commands",
|
||||
"//ios/chrome/browser/shared/public/features",
|
||||
"//ios/chrome/browser/shared/public/features:system_flags",
|
||||
"//ios/chrome/browser/signin/model",
|
||||
|
@ -27,6 +27,7 @@ enum class SecurityDomainId;
|
||||
namespace user_prefs {
|
||||
class PrefRegistrySyncable;
|
||||
} // namespace user_prefs
|
||||
@class ShowSigninCommand;
|
||||
|
||||
// Main class for sign-in coordinator. This class should not be instantiated
|
||||
// directly, this should be done using the class methods.
|
||||
@ -61,6 +62,12 @@ class PrefRegistrySyncable;
|
||||
// Registers preferences related to sign-in coordinator.
|
||||
+ (void)registerProfilePrefs:(user_prefs::PrefRegistrySyncable*)registry;
|
||||
|
||||
// Returns a coordinator according to the command
|
||||
+ (SigninCoordinator*)signinCoordinatorWithCommand:(ShowSigninCommand*)command
|
||||
browser:(Browser*)browser
|
||||
baseViewController:
|
||||
(UIViewController*)baseViewController;
|
||||
|
||||
// Returns a coordinator to sign-in the user without taps if the identity has
|
||||
// been selected with `identity`. Otherwise, it will ask the user to select
|
||||
// an identity, and starts the sign-in flow. If there is no identity on the
|
||||
|
@ -27,6 +27,7 @@
|
||||
#import "ios/chrome/browser/shared/model/browser/browser.h"
|
||||
#import "ios/chrome/browser/shared/model/prefs/pref_names.h"
|
||||
#import "ios/chrome/browser/shared/model/profile/profile_ios.h"
|
||||
#import "ios/chrome/browser/shared/public/commands/show_signin_command.h"
|
||||
#import "ios/chrome/browser/shared/public/features/features.h"
|
||||
#import "ios/chrome/browser/signin/model/chrome_account_manager_service_factory.h"
|
||||
|
||||
@ -54,6 +55,109 @@ using signin_metrics::PromoAction;
|
||||
registry->RegisterIntegerPref(prefs::kSigninWebSignDismissalCount, 0);
|
||||
registry->RegisterDictionaryPref(prefs::kSigninHasAcceptedManagementDialog);
|
||||
}
|
||||
// Returns a coordinator according to the command
|
||||
+ (SigninCoordinator*)signinCoordinatorWithCommand:(ShowSigninCommand*)command
|
||||
browser:(Browser*)browser
|
||||
baseViewController:
|
||||
(UIViewController*)baseViewController {
|
||||
switch (command.operation) {
|
||||
case AuthenticationOperation::kPrimaryAccountReauth:
|
||||
return [SigninCoordinator
|
||||
primaryAccountReauthCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:browser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
case AuthenticationOperation::kResignin:
|
||||
return [SigninCoordinator
|
||||
signinAndSyncReauthCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:browser
|
||||
contextStyle:command
|
||||
.contextStyle
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
case AuthenticationOperation::kSigninOnly: {
|
||||
auto& provider = command.changeProfileContinuationProvider;
|
||||
return [SigninCoordinator
|
||||
consistencyPromoSigninCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:browser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
accessPoint:
|
||||
command.accessPoint
|
||||
prepareChangeProfile:
|
||||
command.prepareChangeProfile
|
||||
continuationProvider:provider];
|
||||
}
|
||||
case AuthenticationOperation::kAddAccount:
|
||||
return [SigninCoordinator
|
||||
addAccountCoordinatorWithBaseViewController:baseViewController
|
||||
browser:browser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
continuationProvider:
|
||||
command.changeProfileContinuationProvider];
|
||||
case AuthenticationOperation::kForcedSigninAndSync:
|
||||
return [SigninCoordinator
|
||||
fullscreenSigninCoordinatorWithBaseViewController:baseViewController
|
||||
browser:browser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
changeProfileContinuationProvider:
|
||||
command.changeProfileContinuationProvider];
|
||||
case AuthenticationOperation::kInstantSignin:
|
||||
return [SigninCoordinator
|
||||
instantSigninCoordinatorWithBaseViewController:baseViewController
|
||||
browser:browser
|
||||
identity:command.identity
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
promoAction:command.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
case AuthenticationOperation::kSheetSigninAndHistorySync: {
|
||||
auto& provider = command.changeProfileContinuationProvider;
|
||||
return [SigninCoordinator
|
||||
signinAndHistorySyncCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:browser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
optionalHistorySync:
|
||||
command.optionalHistorySync
|
||||
fullscreenPromo:
|
||||
command.fullScreenPromo
|
||||
continuationProvider:provider];
|
||||
}
|
||||
case AuthenticationOperation::kHistorySync:
|
||||
return [SigninCoordinator
|
||||
historySyncCoordinatorWithBaseViewController:baseViewController
|
||||
browser:browser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
promoAction:command.promoAction];
|
||||
}
|
||||
}
|
||||
|
||||
+ (SigninCoordinator*)
|
||||
instantSigninCoordinatorWithBaseViewController:
|
||||
|
@ -2160,112 +2160,10 @@ using UserFeedbackDataCallback =
|
||||
return;
|
||||
}
|
||||
Browser* mainBrowser = self.mainInterface.browser;
|
||||
|
||||
switch (command.operation) {
|
||||
case AuthenticationOperation::kPrimaryAccountReauth:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
primaryAccountReauthCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
break;
|
||||
case AuthenticationOperation::kResignin:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
signinAndSyncReauthCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:command
|
||||
.contextStyle
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
break;
|
||||
case AuthenticationOperation::kSigninOnly: {
|
||||
auto& provider = command.changeProfileContinuationProvider;
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
consistencyPromoSigninCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
accessPoint:
|
||||
command.accessPoint
|
||||
prepareChangeProfile:
|
||||
command.prepareChangeProfile
|
||||
continuationProvider:provider];
|
||||
break;
|
||||
}
|
||||
case AuthenticationOperation::kAddAccount:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
addAccountCoordinatorWithBaseViewController:baseViewController
|
||||
self.signinCoordinator =
|
||||
[SigninCoordinator signinCoordinatorWithCommand:command
|
||||
browser:mainBrowser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
continuationProvider:
|
||||
command.changeProfileContinuationProvider];
|
||||
break;
|
||||
case AuthenticationOperation::kForcedSigninAndSync:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
fullscreenSigninCoordinatorWithBaseViewController:baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
changeProfileContinuationProvider:
|
||||
command.changeProfileContinuationProvider];
|
||||
break;
|
||||
case AuthenticationOperation::kInstantSignin:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
instantSigninCoordinatorWithBaseViewController:baseViewController
|
||||
browser:mainBrowser
|
||||
identity:command.identity
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
promoAction:command.promoAction
|
||||
continuationProvider:
|
||||
command
|
||||
.changeProfileContinuationProvider];
|
||||
break;
|
||||
case AuthenticationOperation::kSheetSigninAndHistorySync: {
|
||||
auto& provider = command.changeProfileContinuationProvider;
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
signinAndHistorySyncCoordinatorWithBaseViewController:
|
||||
baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:
|
||||
command.contextStyle
|
||||
accessPoint:command
|
||||
.accessPoint
|
||||
promoAction:command
|
||||
.promoAction
|
||||
optionalHistorySync:
|
||||
command.optionalHistorySync
|
||||
fullscreenPromo:
|
||||
command.fullScreenPromo
|
||||
continuationProvider:provider];
|
||||
break;
|
||||
}
|
||||
case AuthenticationOperation::kHistorySync:
|
||||
self.signinCoordinator = [SigninCoordinator
|
||||
historySyncCoordinatorWithBaseViewController:baseViewController
|
||||
browser:mainBrowser
|
||||
contextStyle:command.contextStyle
|
||||
accessPoint:command.accessPoint
|
||||
promoAction:command.promoAction];
|
||||
break;
|
||||
}
|
||||
baseViewController:baseViewController];
|
||||
[self startSigninCoordinatorWithCompletion:command.completion];
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user