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

[iOS] Clicking on settings link in Sign-in should not start sync engine

SyncSetupService::CommitChanges() should not be called when the user
taps on the "Settings" link in the sign-in screen.
Bug introduced with crrev.com/c/1010346

-[ChromeSigninViewController signinCompletedWithUnity] is created
to get the correct behavior for Unity. This method is only called
with Unity.
-[ChromeSigninViewController acceptSignInAndCommitSyncChanges] has
now the same implementation than before Unity. This method is only
called without Unity.

Bug: 936461
Change-Id: I23353fe199d5e31b66feefe9fc5416f452ab35aa
Reviewed-on: https://chromium-review.googlesource.com/c/1495519Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636770}
parent 33c5fe60
......@@ -292,22 +292,32 @@ enum AuthenticationState {
_unifiedConsentCoordinator = nil;
}
- (void)acceptSignInAndCommitSyncChanges {
// Starts the sync engine only if the user tapped on "YES, I'm in", and closes
// the sign-in view.
- (void)signinCompletedWithUnity {
DCHECK(_didSignIn);
if (_unifiedConsentEnabled) {
// The consent has to be given as soon as the user is signed in. Even when
// they open the settings through the link.
unified_consent::UnifiedConsentService* unifiedConsentService =
UnifiedConsentServiceFactory::GetForBrowserState(_browserState);
// |unifiedConsentService| may be null in unit tests.
if (unifiedConsentService)
unifiedConsentService->SetUrlKeyedAnonymizedDataCollectionEnabled(true);
DCHECK(_unifiedConsentEnabled);
// The consent has to be given as soon as the user is signed in. Even when
// they open the settings through the link.
unified_consent::UnifiedConsentService* unifiedConsentService =
UnifiedConsentServiceFactory::GetForBrowserState(_browserState);
// |unifiedConsentService| may be null in unit tests.
if (unifiedConsentService)
unifiedConsentService->SetUrlKeyedAnonymizedDataCollectionEnabled(true);
if (!_unifiedConsentCoordinator.settingsLinkWasTapped) {
SyncSetupServiceFactory::GetForBrowserState(_browserState)->CommitChanges();
}
SyncSetupServiceFactory::GetForBrowserState(_browserState)->CommitChanges();
[self acceptSignInAndShowAccountsSettings:_unifiedConsentCoordinator
.settingsLinkWasTapped];
}
- (void)acceptSignInAndCommitSyncChanges {
DCHECK(_didSignIn);
DCHECK(!_unifiedConsentEnabled);
SyncSetupServiceFactory::GetForBrowserState(_browserState)->CommitChanges();
[self acceptSignInAndShowAccountsSettings:NO];
}
- (void)setPrimaryButtonStyling:(MDCButton*)button {
[button setBackgroundColor:[[MDCPalette cr_bluePalette] tint500]
forState:UIControlStateNormal];
......@@ -536,7 +546,7 @@ enum AuthenticationState {
_didSignIn = YES;
[_delegate didSignIn:self];
if (_unifiedConsentEnabled) {
[self acceptSignInAndCommitSyncChanges];
[self signinCompletedWithUnity];
} else {
[self changeToState:IDENTITY_SELECTED_STATE];
}
......
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