• Mihai Sardarescu's avatar
    Fix order of notifications to update the unconsent/sync primary account · b531a162
    Mihai Sardarescu authored
    This CL fixes the order in which the notifications to update the
    primary account are being fired. The scenario that failed before
    this CL was the following (covered in test
    SigninManagerTest.UnconsentedPrimaryAccountUpdatedOnSyncConsentRevoked):
    1. Account A and B are signed in with this order in the cookie jar.
    2. Unconsented primary account: A
    3. User enables sync with account B. B becomes the primary account
    4. User revokes sync consent.
    5. Unconsented primary account is reverted to B
    
    Before this CL, 2 notifications were sent with primary account changed
    in the wrong order:
    1. { previous_state: { primary_account: gaia_id_for_me2_gmail.com,
                           consent_level:NotRequired }
         current_state: { primary_account: gaia_id_for_me_gmail.com,
                          consent_level:NotRequired } }
    2. { previous_state: { primary_account: gaia_id_for_me2_gmail.com,
                           consent_level:Sync },
         current_state: { primary_account: gaia_id_for_me2_gmail.com,
                           consent_level:NotRequired } }
    
    This CL fixes this order, and ensures that notification 2 above is
    correctly sent before notification 1.
    
    The change in the CL is fairly complex as it also updates the
    SigninManager to observe OnPrimaryAccountChanged notifications which
    is required as OnUnconsentedPrimaryAccountSet is deprecated.
    
    Bug: 1163126
    
    Change-Id: I047014ce9bc569040d44121d90670d375f8fba62
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2613971
    Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
    Reviewed-by: default avatarMonica Basta <msalama@chromium.org>
    Reviewed-by: default avatarDavid Roger <droger@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#841999}
    b531a162
identity_manager.h 33 KB