• Pâris MEULEMAN's avatar
    Use PrimaryAccountMutator in SigninManagerAndroid · 498f5876
    Pâris MEULEMAN authored
    Use the public API of IdentityManager, PrimaryAccountMutator, to set the
    primary account instead of using IdentityManager's internals
    (PrimaryAccountManager).
    
    PrimaryAccountMutatorImpl::SetPrimaryAccount calls PrimaryAccountManager::Signin, with added pre-conditions:
      - Preferences allow the signin
      - There is no primary account already set (IsAuthenticated)
      - AccountTrackerService knows about the account, and it has both a
        valid account_id and email.
    If those are not met, SetPrimaryAccount does not call PrimaryAccountManager::SignIn and returns false.
    
    In practice, those are already met or were already required:
      - Most of SignIn calls do check the preferences beforehand. Two
        exceptions: Re-authentication cases (SyncAndServicesPreferences, SignInHelper), SigninFragment.
      - PrimaryAccountManager::Signin and
        PrimaryAccountManager::SetAuthenticatedAccountId also verify that.
        If the user is authenticated, the signin is not completed, no
        notifications are sent. A slight behavior change could happen here
        though: a DCHECK verifies that the same user is re-authenticating.
      - PrimaryAccountManager::SignIn also needs AccountTrackerService to be
        properly initialized with the account.
    
    Bug: 987965
    Change-Id: I70f30bcf3536a79bb5983333233c59aeb5b8a5a1
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1738696
    Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
    Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
    Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
    Auto-Submit: Pâris Meuleman <pmeuleman@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#685149}
    498f5876
signin_manager_android.cc 14.6 KB