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

[iOS] Add flag for new sign-in architecture in SceneController.

Adds a flag to the upgrade sign-in flow to use the new sign-in
architecture and updates the user sign-in coordinator to ensure
that the orientation restrictions are applied.

Bug: 971989
Change-Id: I9f844029ba81b54c396d72d62e50ea565bf28b24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2120501Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#753611}
parent f296e3bf
...@@ -376,7 +376,30 @@ const CGFloat kFadeOutAnimationDuration = 0.16f; ...@@ -376,7 +376,30 @@ const CGFloat kFadeOutAnimationDuration = 0.16f;
animated:NO]; animated:NO];
break; break;
} }
case UserSigninIntentUpgrade: case UserSigninIntentUpgrade: {
DCHECK(self.baseViewController);
// Avoid presenting the promo if the current device orientation is not
// supported. The promo will be presented at a later moment, when the
// device orientation is supported.
UIInterfaceOrientation orientation =
[UIApplication sharedApplication].statusBarOrientation;
NSUInteger supportedOrientationsMask =
[self.viewController supportedInterfaceOrientations];
if (!((1 << orientation) & supportedOrientationsMask)) {
[self
runCompletionCallbackWithSigninResult:
SigninCoordinatorResultInterrupted
identity:self.unifiedConsentCoordinator
.selectedIdentity];
return;
}
[self.baseViewController presentViewController:self.viewController
animated:YES
completion:nil];
break;
}
case UserSigninIntentSignin: { case UserSigninIntentSignin: {
DCHECK(self.baseViewController); DCHECK(self.baseViewController);
[self.baseViewController presentViewController:self.viewController [self.baseViewController presentViewController:self.viewController
......
...@@ -48,6 +48,11 @@ ...@@ -48,6 +48,11 @@
// Updates the primary button based on the user sign-in state. // Updates the primary button based on the user sign-in state.
- (void)updatePrimaryButtonStyle; - (void)updatePrimaryButtonStyle;
// Returns the supported orientations for the device type:
// |UIInterfaceOrientationPortrait| orientation on iPhone and all other
// orientations on iPad.
- (NSUInteger)supportedInterfaceOrientations;
@end @end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_VIEW_CONTROLLER_H_ #endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_VIEW_CONTROLLER_H_
...@@ -112,6 +112,11 @@ enum AuthenticationButtonType { ...@@ -112,6 +112,11 @@ enum AuthenticationButtonType {
forControlEvents:UIControlEventTouchUpInside]; forControlEvents:UIControlEventTouchUpInside];
} }
- (NSUInteger)supportedInterfaceOrientations {
return IsIPadIdiom() ? [super supportedInterfaceOrientations]
: UIInterfaceOrientationMaskPortrait;
}
#pragma mark - MDCActivityIndicator #pragma mark - MDCActivityIndicator
- (void)startAnimatingActivityIndicator { - (void)startAnimatingActivityIndicator {
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "ios/chrome/browser/system_flags.h" #include "ios/chrome/browser/system_flags.h"
#import "ios/chrome/browser/tabs/tab_model.h" #import "ios/chrome/browser/tabs/tab_model.h"
#import "ios/chrome/browser/ui/authentication/signed_in_accounts_view_controller.h" #import "ios/chrome/browser/ui/authentication/signed_in_accounts_view_controller.h"
#import "ios/chrome/browser/ui/authentication/signin/signin_coordinator.h"
#import "ios/chrome/browser/ui/authentication/signin/signin_utils.h" #import "ios/chrome/browser/ui/authentication/signin/signin_utils.h"
#import "ios/chrome/browser/ui/browser_view/browser_view_controller.h" #import "ios/chrome/browser/ui/browser_view/browser_view_controller.h"
#import "ios/chrome/browser/ui/commands/browser_commands.h" #import "ios/chrome/browser/ui/commands/browser_commands.h"
...@@ -183,6 +184,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -183,6 +184,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// YES while animating the dismissal of tab switcher. // YES while animating the dismissal of tab switcher.
@property(nonatomic, assign) BOOL dismissingTabSwitcher; @property(nonatomic, assign) BOOL dismissingTabSwitcher;
// The coordinator used to control sign-in UI flows. Lazily created the first
// time it is accessed.
@property(nonatomic, strong) SigninCoordinator* signinCoordinator;
@end @end
@implementation SceneController @implementation SceneController
...@@ -494,10 +499,27 @@ const NSTimeInterval kDisplayPromoDelay = 0.1; ...@@ -494,10 +499,27 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
initWithBrowser:browser initWithBrowser:browser
dispatcher:self.mainInterface.bvc.dispatcher]; dispatcher:self.mainInterface.bvc.dispatcher];
if (base::FeatureList::IsEnabled(kNewSigninArchitecture)) {
self.signinCoordinator = [SigninCoordinator
upgradeSigninPromoCoordinatorWithBaseViewController:self.mainInterface
.bvc
browser:browser];
__weak SceneController* weakSelf = self;
self.signinCoordinator.signinCompletion =
^(SigninCoordinatorResult signinResult, ChromeIdentity* identity) {
[weakSelf.signinCoordinator stop];
weakSelf.signinCoordinator = nil;
};
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, dispatch_after(dispatch_time(DISPATCH_TIME_NOW,
(int64_t)(kDisplayPromoDelay * NSEC_PER_SEC)), (int64_t)(kDisplayPromoDelay * NSEC_PER_SEC)),
dispatch_get_main_queue(), ^{ dispatch_get_main_queue(), ^{
[self showPromo:promoController]; if (base::FeatureList::IsEnabled(kNewSigninArchitecture)) {
[self.signinCoordinator start];
} else {
[self showPromo:promoController];
}
}); });
} }
} }
......
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