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;
animated:NO];
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: {
DCHECK(self.baseViewController);
[self.baseViewController presentViewController:self.viewController
......
......@@ -48,6 +48,11 @@
// Updates the primary button based on the user sign-in state.
- (void)updatePrimaryButtonStyle;
// Returns the supported orientations for the device type:
// |UIInterfaceOrientationPortrait| orientation on iPhone and all other
// orientations on iPad.
- (NSUInteger)supportedInterfaceOrientations;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTHENTICATION_SIGNIN_USER_SIGNIN_USER_SIGNIN_VIEW_CONTROLLER_H_
......@@ -112,6 +112,11 @@ enum AuthenticationButtonType {
forControlEvents:UIControlEventTouchUpInside];
}
- (NSUInteger)supportedInterfaceOrientations {
return IsIPadIdiom() ? [super supportedInterfaceOrientations]
: UIInterfaceOrientationMaskPortrait;
}
#pragma mark - MDCActivityIndicator
- (void)startAnimatingActivityIndicator {
......
......@@ -40,6 +40,7 @@
#include "ios/chrome/browser/system_flags.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/signin/signin_coordinator.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/commands/browser_commands.h"
......@@ -183,6 +184,10 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
// YES while animating the dismissal of tab switcher.
@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
@implementation SceneController
......@@ -494,10 +499,27 @@ const NSTimeInterval kDisplayPromoDelay = 0.1;
initWithBrowser:browser
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,
(int64_t)(kDisplayPromoDelay * NSEC_PER_SEC)),
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