Commit 7db3923f authored by Nohemi Fernandez's avatar Nohemi Fernandez Committed by Commit Bot

[iOS] Do not allow simultaneous sign-in operations.

The SignOut operation with Chrome data clearing does not have the
proper conditionals in place to ensure that a subsequent operation
cannot occur while sign-out is in progress.

We suspect this causes a crash on sign-out / sign-in to switch accounts
since the navigation controller that AccountsTableViewController
attempts to perform an operation on may no longer exist.

https://crash.corp.google.com/browse?q=product_name%3D%27Chrome_iOS%27+AND+expanded_custom_data.ChromeCrashProto.channel%3D%27%27+AND+expanded_custom_data.ChromeCrashProto.magic_signature_1.name%3D%27%5BHang%5Dweb%3A%3AWebSubThread%3A%3AIOThreadRun%27+AND+%28EXISTS+%28SELECT+1+FROM+UNNEST%28productdata%29+WHERE+key%3D%27breadcrumbs0%27%29+OR+EXISTS+%28SELECT+1+FROM+UNNEST%28productdata%29+WHERE+key%3D%27breadcrumbs%27%29%29&stbtiq=&reportid=&index=0

Bug: 1108310
Change-Id: I66d1852d1071d7acea243005bfabc7797af14dd3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2408754Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Nohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806613}
parent c7a79f64
......@@ -256,6 +256,23 @@ id<GREYMatcher> NoBookmarksLabel() {
assertWithMatcher:grey_notNil()];
}
// Tests that given two accounts A and B that are available on the device -
// signing in and out from account A, then signing in to account B, properly
// identifies the user with account B.
- (void)testSwitchingAccountsWithClearedData {
FakeChromeIdentity* fakeIdentity1 = [SigninEarlGrey fakeIdentity1];
FakeChromeIdentity* fakeIdentity2 = [SigninEarlGrey fakeIdentity2];
[SigninEarlGrey addFakeIdentity:fakeIdentity1];
[SigninEarlGrey addFakeIdentity:fakeIdentity2];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity1];
[SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity1];
[SigninEarlGreyUI signOutAndClearDataFromDevice];
[SigninEarlGreyUI signinWithFakeIdentity:fakeIdentity2];
[SigninEarlGrey verifySignedInWithFakeIdentity:fakeIdentity2];
}
// Tests that the user isn't signed out and the UI is correct when the
// disconnect is cancelled in the Account Settings screen.
#if !TARGET_IPHONE_SIMULATOR
......
......@@ -498,6 +498,12 @@ typedef NS_ENUM(NSInteger, ItemType) {
- (void)showSignOutWithClearData:(BOOL)forceClearData
itemView:(UIView*)itemView {
if (_authenticationOperationInProgress || [_alertCoordinator isVisible] ||
self != [self.navigationController topViewController]) {
// An action is already in progress, ignore user's request.
return;
}
NSString* alertMessage = nil;
NSString* signOutTitle = nil;
UIAlertActionStyle actionStyle = UIAlertActionStyleDefault;
......@@ -537,51 +543,6 @@ typedef NS_ENUM(NSInteger, ItemType) {
[_alertCoordinator start];
}
- (void)showSignOut {
if (_authenticationOperationInProgress || [_alertCoordinator isVisible] ||
self != [self.navigationController topViewController]) {
// An action is already in progress, ignore user's request.
return;
}
NSString* title = nil;
NSString* message = nil;
NSString* continueButtonTitle = nil;
if ([self authService] -> IsAuthenticatedIdentityManaged()) {
title =
l10n_util::GetNSString(IDS_IOS_MANAGED_DISCONNECT_DIALOG_TITLE_UNITY);
message = l10n_util::GetNSStringF(
IDS_IOS_MANAGED_DISCONNECT_DIALOG_INFO_UNITY, self.hostedDomain);
continueButtonTitle =
l10n_util::GetNSString(IDS_IOS_MANAGED_DISCONNECT_DIALOG_ACCEPT_UNITY);
} else {
title = l10n_util::GetNSString(IDS_IOS_DISCONNECT_DIALOG_TITLE_UNITY);
message =
l10n_util::GetNSString(IDS_IOS_DISCONNECT_DIALOG_INFO_MOBILE_UNITY);
continueButtonTitle = l10n_util::GetNSString(
IDS_IOS_DISCONNECT_DIALOG_CONTINUE_BUTTON_MOBILE);
}
_alertCoordinator =
[[AlertCoordinator alloc] initWithBaseViewController:self
browser:_browser
title:title
message:message];
__weak AccountsTableViewController* weakSelf = self;
[_alertCoordinator addItemWithTitle:l10n_util::GetNSString(IDS_CANCEL)
action:nil
style:UIAlertActionStyleCancel];
[_alertCoordinator addItemWithTitle:continueButtonTitle
action:^{
[weakSelf handleSignOutWithForceClearData:NO];
}
style:UIAlertActionStyleDefault];
[_alertCoordinator start];
}
- (void)handleSignOutWithForceClearData:(BOOL)forceClearData {
AuthenticationService* authService = [self authService];
if (authService->IsAuthenticated()) {
......@@ -590,10 +551,7 @@ typedef NS_ENUM(NSInteger, ItemType) {
authService->SignOut(
signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, forceClearData, ^{
[self allowUserInteraction];
_authenticationOperationInProgress = NO;
[base::mac::ObjCCastStrict<SettingsNavigationController>(
self.navigationController)
popViewControllerOrCloseSettingsAnimated:YES];
[self handleAuthenticationOperationDidFinish];
});
// Get UMA metrics on the usage of different options for signout available
// for users with non-managed accounts.
......
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