Commit f606ecfd authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Add first run flow to UserSigninCoordinator architecture.

This patch concerns the change in the skip button text to 'No Thanks'
and the presentation of the user sign-in as fullscreen.
Note that the first run logging will be extracted in a separate patch.

Bug: 971989
Change-Id: I372937780288b190948819605a913d50dae81cc1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087617
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Reviewed-by: default avatarJérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#747758}
parent a340aadc
...@@ -54,12 +54,11 @@ typedef void (^SigninCoordinatorCompletionCallback)( ...@@ -54,12 +54,11 @@ typedef void (^SigninCoordinatorCompletionCallback)(
promoAction; promoAction;
// Returns a coordinator for first run sign-in workflow. // Returns a coordinator for first run sign-in workflow.
// |viewController| presents the sign-in. // |viewController| presents the sign-in. Will be responsible for dismissing
// |presenter| to present sync-related UI. // itself upon sign-in completion.
+ (instancetype) + (instancetype)firstRunCoordinatorWithBaseViewController:
firstRunCoordinatorWithBaseViewController:(UIViewController*)viewController (UINavigationController*)viewController
browser:(Browser*)browser browser:(Browser*)browser;
syncPresenter:(id<SyncPresenter>)presenter;
// Returns a coordinator for upgrade sign-in workflow. // Returns a coordinator for upgrade sign-in workflow.
// |viewController| presents the sign-in. // |viewController| presents the sign-in.
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#import "ios/chrome/browser/ui/authentication/signin/add_account_signin/add_account_signin_coordinator.h" #import "ios/chrome/browser/ui/authentication/signin/add_account_signin/add_account_signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/advanced_settings_signin/advanced_settings_signin_coordinator.h" #import "ios/chrome/browser/ui/authentication/signin/advanced_settings_signin/advanced_settings_signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_constants.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_coordinator.h" #import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_coordinator.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -24,24 +25,25 @@ using signin_metrics::PromoAction; ...@@ -24,24 +25,25 @@ using signin_metrics::PromoAction;
identity:(ChromeIdentity*)identity identity:(ChromeIdentity*)identity
accessPoint:(AccessPoint)accessPoint accessPoint:(AccessPoint)accessPoint
promoAction:(PromoAction)promoAction { promoAction:(PromoAction)promoAction {
return return [[UserSigninCoordinator alloc]
[[UserSigninCoordinator alloc] initWithBaseViewController:viewController initWithBaseViewController:viewController
browser:browser browser:browser
identity:identity identity:identity
accessPoint:accessPoint accessPoint:accessPoint
promoAction:promoAction]; promoAction:promoAction
signinIntent:UserSigninIntentSignin];
} }
+ (instancetype) + (instancetype)firstRunCoordinatorWithBaseViewController:
firstRunCoordinatorWithBaseViewController:(UIViewController*)viewController (UINavigationController*)viewController
browser:(Browser*)browser browser:(Browser*)browser {
syncPresenter:(id<SyncPresenter>)syncPresenter {
return [[UserSigninCoordinator alloc] return [[UserSigninCoordinator alloc]
initWithBaseViewController:viewController initWithBaseViewController:viewController
browser:browser browser:browser
identity:nil identity:nil
accessPoint:AccessPoint::ACCESS_POINT_START_PAGE accessPoint:AccessPoint::ACCESS_POINT_START_PAGE
promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO]; promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO
signinIntent:UserSigninIntentFirstRun];
} }
+ (instancetype) + (instancetype)
...@@ -53,7 +55,8 @@ using signin_metrics::PromoAction; ...@@ -53,7 +55,8 @@ using signin_metrics::PromoAction;
browser:browser browser:browser
identity:nil identity:nil
accessPoint:AccessPoint::ACCESS_POINT_SIGNIN_PROMO accessPoint:AccessPoint::ACCESS_POINT_SIGNIN_PROMO
promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO]; promoAction:PromoAction::PROMO_ACTION_NO_SIGNIN_PROMO
signinIntent:UserSigninIntentUpgrade];
} }
+ (instancetype) + (instancetype)
......
...@@ -9,6 +9,8 @@ source_set("user_signin") { ...@@ -9,6 +9,8 @@ source_set("user_signin") {
sources = [ sources = [
"gradient_view.h", "gradient_view.h",
"gradient_view.mm", "gradient_view.mm",
"user_signin_constants.h",
"user_signin_constants.mm",
"user_signin_coordinator.h", "user_signin_coordinator.h",
"user_signin_coordinator.mm", "user_signin_coordinator.mm",
"user_signin_mediator.h", "user_signin_mediator.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.
#ifndef IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_CONSTANTS_H_
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_CONSTANTS_H_
#import <UIKit/UIKit.h>
// Intent when the user begins a sign-in flow.
typedef NS_ENUM(NSUInteger, UserSigninIntent) {
// First run sign-in flow.
UserSigninIntentFirstRun,
// Upgrade sign-in flow.
UserSigninIntentUpgrade,
// Sign-in flow.
UserSigninIntentSignin,
};
// Name of notification sent when the user has attempted a sign-in.
extern NSString* const kUserSigninAttemptedNotification;
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_CONSTANTS_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.
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_constants.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kUserSigninAttemptedNotification = @"kUserSigninAttempted";
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_COORDINATOR_H_ #define IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_COORDINATOR_H_
#import "ios/chrome/browser/ui/authentication/signin/signin_coordinator.h" #import "ios/chrome/browser/ui/authentication/signin/signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_constants.h"
// Coordinates the user sign-in with different intents: // Coordinates the user sign-in with different intents:
// + user sign-in when triggered from UI (settings, bookmarks...) // + user sign-in when triggered from UI (settings, bookmarks...)
...@@ -32,6 +33,7 @@ ...@@ -32,6 +33,7 @@
identity:(ChromeIdentity*)identity identity:(ChromeIdentity*)identity
accessPoint:(signin_metrics::AccessPoint)accessPoint accessPoint:(signin_metrics::AccessPoint)accessPoint
promoAction:(signin_metrics::PromoAction)promoAction promoAction:(signin_metrics::PromoAction)promoAction
signinIntent:(UserSigninIntent)signinIntent
NS_DESIGNATED_INITIALIZER; NS_DESIGNATED_INITIALIZER;
@end @end
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_coordinator.h" #import "ios/chrome/browser/ui/authentication/signin/user_signin/user_signin_coordinator.h"
#import "base/mac/foundation_util.h"
#import "base/metrics/user_metrics.h" #import "base/metrics/user_metrics.h"
#import "ios/chrome/browser/main/browser.h" #import "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/signin/authentication_service_factory.h" #import "ios/chrome/browser/signin/authentication_service_factory.h"
...@@ -27,6 +28,10 @@ ...@@ -27,6 +28,10 @@
using signin_metrics::AccessPoint; using signin_metrics::AccessPoint;
using signin_metrics::PromoAction; using signin_metrics::PromoAction;
namespace {
const CGFloat kFadeOutAnimationDuration = 0.16f;
} // namespace
@interface UserSigninCoordinator () <UnifiedConsentCoordinatorDelegate, @interface UserSigninCoordinator () <UnifiedConsentCoordinatorDelegate,
UserSigninViewControllerDelegate, UserSigninViewControllerDelegate,
UserSigninMediatorDelegate> UserSigninMediatorDelegate>
...@@ -49,6 +54,8 @@ using signin_metrics::PromoAction; ...@@ -49,6 +54,8 @@ using signin_metrics::PromoAction;
@property(nonatomic, assign) AccessPoint accessPoint; @property(nonatomic, assign) AccessPoint accessPoint;
// Promo button used to trigger the sign-in. // Promo button used to trigger the sign-in.
@property(nonatomic, assign) PromoAction promoAction; @property(nonatomic, assign) PromoAction promoAction;
// Sign-in intent.
@property(nonatomic, assign, readonly) UserSigninIntent signinIntent;
@end @end
...@@ -60,12 +67,14 @@ using signin_metrics::PromoAction; ...@@ -60,12 +67,14 @@ using signin_metrics::PromoAction;
browser:(Browser*)browser browser:(Browser*)browser
identity:(ChromeIdentity*)identity identity:(ChromeIdentity*)identity
accessPoint:(AccessPoint)accessPoint accessPoint:(AccessPoint)accessPoint
promoAction:(PromoAction)promoAction { promoAction:(PromoAction)promoAction
signinIntent:(UserSigninIntent)signinIntent {
self = [super initWithBaseViewController:viewController browser:browser]; self = [super initWithBaseViewController:viewController browser:browser];
if (self) { if (self) {
_defaultIdentity = identity; _defaultIdentity = identity;
_accessPoint = accessPoint; _accessPoint = accessPoint;
_promoAction = promoAction; _promoAction = promoAction;
_signinIntent = signinIntent;
} }
return self; return self;
} }
...@@ -76,6 +85,8 @@ using signin_metrics::PromoAction; ...@@ -76,6 +85,8 @@ using signin_metrics::PromoAction;
[super start]; [super start];
self.viewController = [[UserSigninViewController alloc] init]; self.viewController = [[UserSigninViewController alloc] init];
self.viewController.delegate = self; self.viewController.delegate = self;
self.viewController.useFirstRunSkipButton =
self.signinIntent == UserSigninIntentFirstRun;
self.mediator = [[UserSigninMediator alloc] self.mediator = [[UserSigninMediator alloc]
initWithAuthenticationService:AuthenticationServiceFactory:: initWithAuthenticationService:AuthenticationServiceFactory::
...@@ -105,13 +116,28 @@ using signin_metrics::PromoAction; ...@@ -105,13 +116,28 @@ using signin_metrics::PromoAction;
// Display UnifiedConsentViewController within the host. // Display UnifiedConsentViewController within the host.
self.viewController.unifiedConsentViewController = self.viewController.unifiedConsentViewController =
self.unifiedConsentCoordinator.viewController; self.unifiedConsentCoordinator.viewController;
[self.baseViewController presentViewController:self.viewController
animated:YES switch (self.signinIntent) {
completion:nil]; case UserSigninIntentFirstRun: {
[self presentFirstRun];
break;
}
case UserSigninIntentSignin:
case UserSigninIntentUpgrade: {
[self.baseViewController presentViewController:self.viewController
animated:YES
completion:nil];
break;
}
}
} }
- (void)interruptWithAction:(SigninCoordinatorInterruptAction)action - (void)interruptWithAction:(SigninCoordinatorInterruptAction)action
completion:(ProceduralBlock)completion { completion:(ProceduralBlock)completion {
// Chrome should never start before the first run is fully finished. Therefore
// we do not expect the sign-in to be interrupted for first run.
DCHECK(self.signinIntent != UserSigninIntentFirstRun);
__weak UserSigninCoordinator* weakSelf = self; __weak UserSigninCoordinator* weakSelf = self;
if (self.addAccountSigninCoordinator) { if (self.addAccountSigninCoordinator) {
// |self.addAccountSigninCoordinator| needs to be interupted before // |self.addAccountSigninCoordinator| needs to be interupted before
...@@ -184,6 +210,8 @@ using signin_metrics::PromoAction; ...@@ -184,6 +210,8 @@ using signin_metrics::PromoAction;
} }
- (void)userSigninViewControllerDidTapOnAddAccount { - (void)userSigninViewControllerDidTapOnAddAccount {
[self notifyUserSigninAttempted];
self.addAccountSigninCoordinator = [SigninCoordinator self.addAccountSigninCoordinator = [SigninCoordinator
addAccountCoordinatorWithBaseViewController:self.viewController addAccountCoordinatorWithBaseViewController:self.viewController
browser:self.browser browser:self.browser
...@@ -210,6 +238,7 @@ using signin_metrics::PromoAction; ...@@ -210,6 +238,7 @@ using signin_metrics::PromoAction;
} }
- (void)userSigninViewControllerDidTapOnSignin { - (void)userSigninViewControllerDidTapOnSignin {
[self notifyUserSigninAttempted];
[self startSigninFlow]; [self startSigninFlow];
} }
...@@ -250,7 +279,12 @@ using signin_metrics::PromoAction; ...@@ -250,7 +279,12 @@ using signin_metrics::PromoAction;
identity:identity identity:identity
settingsLinkWasTapped:settingsWasTapped]; settingsLinkWasTapped:settingsWasTapped];
}; };
[self.viewController dismissViewControllerAnimated:YES completion:completion]; // The caller is responsible for cleaning up the base view controller for
// first run sign-in.
if (self.signinIntent != UserSigninIntentFirstRun) {
[self.viewController dismissViewControllerAnimated:YES
completion:completion];
}
} }
- (void)userSigninMediatorNeedPrimaryButtonUpdate { - (void)userSigninMediatorNeedPrimaryButtonUpdate {
...@@ -259,6 +293,13 @@ using signin_metrics::PromoAction; ...@@ -259,6 +293,13 @@ using signin_metrics::PromoAction;
#pragma mark - Private #pragma mark - Private
// Notifies the observers that the user is attempting sign-in.
- (void)notifyUserSigninAttempted {
[[NSNotificationCenter defaultCenter]
postNotificationName:kUserSigninAttemptedNotification
object:nil];
}
// Called when |self.viewController| is dismissed. If |settingsWasTapped| is // Called when |self.viewController| is dismissed. If |settingsWasTapped| is
// NO, the sign-in is finished and // NO, the sign-in is finished and
// |runCompletionCallbackWithSigninResult:identity:| is called. // |runCompletionCallbackWithSigninResult:identity:| is called.
...@@ -315,6 +356,21 @@ using signin_metrics::PromoAction; ...@@ -315,6 +356,21 @@ using signin_metrics::PromoAction;
} }
} }
// Displays the sign-in screen with transitions specific to first-run.
- (void)presentFirstRun {
DCHECK(self.viewController);
UINavigationController* navigationController =
base::mac::ObjCCastStrict<UINavigationController>(
self.baseViewController);
CATransition* transition = [CATransition animation];
transition.duration = kFadeOutAnimationDuration;
transition.type = kCATransitionFade;
[navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[navigationController pushViewController:self.viewController animated:NO];
}
// Interrupts the sign-in when |self.viewController| is presented, by dismissing // Interrupts the sign-in when |self.viewController| is presented, by dismissing
// it if needed (according to |action|). Then |completion| is called. // it if needed (according to |action|). Then |completion| is called.
// This method should not be called if |self.addAccountSigninCoordinator| has // This method should not be called if |self.addAccountSigninCoordinator| has
......
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
@property(nonatomic, assign, readonly) int acceptSigninButtonStringId; @property(nonatomic, assign, readonly) int acceptSigninButtonStringId;
@property(nonatomic, assign) BOOL useFirstRunSkipButton;
// Informs the view controller that the unified consent has reached the bottom // Informs the view controller that the unified consent has reached the bottom
// of the screen. // of the screen.
- (void)markUnifiedConsentScreenReachedBottom; - (void)markUnifiedConsentScreenReachedBottom;
......
...@@ -192,6 +192,10 @@ enum AuthenticationButtonType { ...@@ -192,6 +192,10 @@ enum AuthenticationButtonType {
return l10n_util::GetNSString(IDS_IOS_ACCOUNT_UNIFIED_CONSENT_OK_BUTTON); return l10n_util::GetNSString(IDS_IOS_ACCOUNT_UNIFIED_CONSENT_OK_BUTTON);
} }
- (NSString*)skipSigninButtonTitle { - (NSString*)skipSigninButtonTitle {
if (self.useFirstRunSkipButton) {
return l10n_util::GetNSString(
IDS_IOS_FIRSTRUN_ACCOUNT_CONSISTENCY_SKIP_BUTTON);
}
return l10n_util::GetNSString(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON); return l10n_util::GetNSString(IDS_IOS_ACCOUNT_CONSISTENCY_SETUP_SKIP_BUTTON);
} }
......
...@@ -41,7 +41,6 @@ source_set("first_run") { ...@@ -41,7 +41,6 @@ source_set("first_run") {
"//ios/chrome/browser/ui/icons", "//ios/chrome/browser/ui/icons",
"//ios/chrome/browser/ui/material_components", "//ios/chrome/browser/ui/material_components",
"//ios/chrome/browser/ui/promos", "//ios/chrome/browser/ui/promos",
"//ios/chrome/browser/ui/settings",
"//ios/chrome/browser/ui/settings/sync/utils", "//ios/chrome/browser/ui/settings/sync/utils",
"//ios/chrome/browser/ui/settings/utils", "//ios/chrome/browser/ui/settings/utils",
"//ios/chrome/browser/ui/util", "//ios/chrome/browser/ui/util",
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "ios/chrome/browser/signin/identity_manager_factory.h" #include "ios/chrome/browser/signin/identity_manager_factory.h"
#include "ios/chrome/browser/ui/first_run/first_run_histograms.h" #include "ios/chrome/browser/ui/first_run/first_run_histograms.h"
#import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h" #import "ios/chrome/browser/ui/settings/sync/utils/sync_util.h"
#import "ios/chrome/browser/ui/settings/utils/settings_utils.h"
#include "ios/chrome/browser/ui/util/ui_util.h" #include "ios/chrome/browser/ui/util/ui_util.h"
#include "ios/web/public/thread/web_thread.h" #include "ios/web/public/thread/web_thread.h"
#import "ui/gfx/ios/NSString+CrStringDrawing.h" #import "ui/gfx/ios/NSString+CrStringDrawing.h"
......
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