• rsimha@google.com's avatar
    Re-land 151364 - [sync] Auto-create credential cache for users who are already... · b475ef4e
    rsimha@google.com authored
    Re-land 151364 - [sync] Auto-create credential cache for users who are already signed in and go on to upgrade Chrome
    
    Originally reverted due to crashes in GetLastUpdatedTime(). See crbug.com/143214. Turns out 151364 wasn't the root cause. Feature has been disabled via switch on canary. Root cause fix is under review in a separate patch. Re-landing 151364.
    
    Original description:
    
    CredentialCacheService on Windows 8 writes to the local credential cache
    when a user actively signs in / reconfigures sync. Existing cached
    credentials are not updated when Chrome is merely restarted after the
    user is signed in.
    
    This causes a problem when a user is already signed in, and then
    upgrades (and restarts) chrome from a version that didn't originally
    support credential caching. In such cases, we never end up caching
    credentials, and therefore, the user will have to sign in separately to
    Metro and Desktop.
    
    This patch contains the following changes:
    
    1) Adds logic to auto-heal already-signed-in users who upgrade from
    older versions, by writing existing credentials to the local cache if
    during restart, we notice that there is no local cache file, and the
    user is already signed in to sync.
    
    2) Simplifies the logic around checking if an alternate credential cache
    file exists, and only then initializing |alternate_store_|. It turns out
    that JsonPrefStore returns a useful PrefReadError field, and there is no
    need for CCS to do funky stuff on the FILE thread.
    
    3) Simplifies OnInitialzationCompleted, which was being used to observe
    two separate JsonPrefStores. Instead of having CCS be a
    PrefStore::Observer, we now use two helper classes -- LocalStoreObserver
    and AlternateStoreObserver to cleanly divide what is done when each pref
    store is initialized.
    
    4) Updates prefs::kGoogleServicesUsername by listening to the notifications
    NOTIFICATION_GOOGLE_SIGNED_OUT and NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL
    instead of directly listening to the pref change.
    
    5) Fixes a stray instance where we were accessing the gaia username
    pref via SyncPrefs instead of via the SigninManager.
    
    BUG=141555,143214
    TEST=Sign in to chrome, exit the browser, and delete "Sync Credentials" from the default profile directory. Restart Chrome and make sure that the credential cache file is freshly written using existing sync credentials.
    
    Original review URL: https://chromiumcodereview.appspot.com/10830239
    First revert review URL: https://chromiumcodereview.appspot.com/10830362
    TBR=zea@chromium.org
    Review URL: https://chromiumcodereview.appspot.com/10834395
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152122 0039d316-1c4b-4281-b951-d872f2087c98
    b475ef4e
credential_cache_service_win_unittest.cc 5.12 KB