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

[iOS] Starting the new implementation of the sign-in UI

Adding SigninCoordinator class for the new implementation of sign-in
UI.
Based on design: http://go/chrome-ios-signin-migration
Related to:
 + crrev.com/c/2025353
 + crrev.com/c/2027809

Bug: 971989
Change-Id: Ib9e07a05cb843a7335bb79b5cf576d7b00e91970
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2025547
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736440}
parent 98257ea9
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chrome_build.gni")
source_set("signin") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ "signin_coordinator.h" ]
public_deps = [
"//base",
"//components/signin/public/base",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
]
}
source_set("private") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [ "signin_coordinator.mm" ]
deps = [ ":signin" ]
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_SIGNIN_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_SIGNIN_COORDINATOR_H_
#import <UIKit/UIKit.h>
#import "base/ios/block_types.h"
#import "components/signin/public/base/signin_metrics.h"
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
class Browser;
@class ChromeIdentity;
@protocol ApplicationCommands;
@protocol BrowsingDataCommands;
@protocol SyncPresenter;
// Sign-in result returned Sign-in result.
typedef NS_ENUM(NSUInteger, SigninCoordinatorResult) {
// Sign-in has been canceled by the user or by another reason.
SigninCoordinatorResultCanceledByUser,
// Sign-in has been done, but the user didn’t accept nor refuse to sync.
SigninCoordinatorResultInterrupted,
// Sign-in has been done, the user has been explicitly accepted or refused
// sync.
SigninCoordinatorResultSuccess,
};
// Action to do when the sign-in dialog needs to be interrupted.
typedef NS_ENUM(NSUInteger, SigninCoordinatorInterruptAction) {
// Stops the sign-in coordinator without dismissing the view.
SigninCoordinatorInterruptActionNoDismiss,
// Stops the sign-in coordinator and dismisses the view without animation.
SigninCoordinatorInterruptActionDismissWithoutAnimation,
// Stops the sign-in coordinator and dismisses the view with animation.
SigninCoordinatorInterruptActionDismissWithAnimation,
};
// Called when the sign-in dialog is closed.
// |result| is the sign-in result state.
// |identity| is the identity chosen by the user during the sign-in.
typedef void (^SigninCoordinatorCompletionCallback)(
SigninCoordinatorResult signinResult,
ChromeIdentity* identity);
// Main class for sign-in coordinator. This class should not be instantiated
// directly, this should be done using the class methods.
@interface SigninCoordinator : ChromeCoordinator
// Dispatcher.
@property(nonatomic, strong, readonly)
id<ApplicationCommands, BrowsingDataCommands>
dispatcher;
// Called when the sign-in dialog is interrupted, canceled or successful.
@property(nonatomic, copy) SigninCoordinatorCompletionCallback signinCompletion;
// Returns a coordinator for user sign-in workflow.
// |viewController| presents the sign-in.
// |identity| is the identity preselected with the sign-in opens.
// |accessPoint| is the view where the sign-in button was displayed.
// |promoAction| is promo button used to trigger the sign-in.
+ (instancetype)
userSigninCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
identity:(ChromeIdentity*)identity
accessPoint:
(signin_metrics::AccessPoint)accessPoint
promoAction:(signin_metrics::PromoAction)
promoAction;
// Returns a coordinator for first run sign-in workflow.
// |viewController| presents the sign-in.
// |presenter| to present sync-related UI.
+ (instancetype)
firstRunCoordinatorWithBaseViewController:(UIViewController*)viewController
browser:(Browser*)browser
syncPresenter:(id<SyncPresenter>)presenter;
// Returns a coordinator for upgrade sign-in workflow.
// |viewController| presents the sign-in.
+ (instancetype)upgradeSigninPromoCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)
browser;
// Returns a coordinator for advanced sign-in settings workflow.
// |viewController| presents the sign-in.
+ (instancetype)
advancedSettingsSigninCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser;
// Returns a coordinator to add an account.
// |viewController| presents the sign-in.
// |accessPoint| access point from the sign-in where is started.
+ (instancetype)
addAccountCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
accessPoint:(signin_metrics::AccessPoint)
accessPoint;
// Returns a coordinator for re-authentication workflow.
// |viewController| presents the sign-in.
// |accessPoint| access point from the sign-in where is started.
// |promoAction| is promo button used to trigger the sign-in.
+ (instancetype)
reAuthenticationCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
accessPoint:
(signin_metrics::AccessPoint)
accessPoint
promoAction:
(signin_metrics::PromoAction)
promoAction;
// Interrupts the sign-in flow.
// |action| action describing how to interrupt the sign-in.
// |completion| called once the sign-in is fully interrupted.
- (void)interruptWithAction:(SigninCoordinatorInterruptAction)action
completion:(ProceduralBlock)completion;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_SIGNIN_COORDINATOR_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ios/chrome/browser/ui/authentication/signin/signin_coordinator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
using signin_metrics::AccessPoint;
using signin_metrics::PromoAction;
@implementation SigninCoordinator
+ (instancetype)
userSigninCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
identity:(ChromeIdentity*)identity
accessPoint:(AccessPoint)accessPoint
promoAction:(PromoAction)promoAction {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
+ (instancetype)
firstRunCoordinatorWithBaseViewController:(UIViewController*)viewController
browser:(Browser*)browser
syncPresenter:(id<SyncPresenter>)syncPresenter {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
+ (instancetype)
upgradeSigninPromoCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
+ (instancetype)
advancedSettingsSigninCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
+ (instancetype)addAccountCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
accessPoint:
(AccessPoint)accessPoint {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
+ (instancetype)
reAuthenticationCoordinatorWithBaseViewController:
(UIViewController*)viewController
browser:(Browser*)browser
accessPoint:(AccessPoint)accessPoint
promoAction:(PromoAction)promoAction {
// TODO(crbug.com/971989): Needs implementation.
NOTIMPLEMENTED();
return nil;
}
- (void)interruptWithAction:(SigninCoordinatorInterruptAction)action
completion:(ProceduralBlock)completion {
// This method needs to be implemented in the subclass.
NOTREACHED();
}
@end
......@@ -21,6 +21,7 @@ source_set("signin_interaction") {
"//ios/chrome/browser/signin",
"//ios/chrome/browser/ui/alert_coordinator",
"//ios/chrome/browser/ui/authentication",
"//ios/chrome/browser/ui/authentication/signin",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/public/provider/chrome/browser",
......
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