| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/sync/credential_cache_service_win.h" | 5 #include "chrome/browser/sync/credential_cache_service_win.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 636 } | 636 } |
| 637 | 637 |
| 638 FilePath alternate_default_profile_dir = | 638 FilePath alternate_default_profile_dir = |
| 639 ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); | 639 ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); |
| 640 return alternate_default_profile_dir.Append(chrome::kSyncCredentialsFilename); | 640 return alternate_default_profile_dir.Append(chrome::kSyncCredentialsFilename); |
| 641 } | 641 } |
| 642 | 642 |
| 643 void CredentialCacheService::InitializeLocalCredentialCacheWriter() { | 643 void CredentialCacheService::InitializeLocalCredentialCacheWriter() { |
| 644 local_store_ = new JsonPrefStore( | 644 local_store_ = new JsonPrefStore( |
| 645 GetCredentialPathInCurrentProfile(), | 645 GetCredentialPathInCurrentProfile(), |
| 646 content::BrowserThread::GetMessageLoopProxyForThread( | 646 BrowserThread::GetBlockingPool()); |
| 647 content::BrowserThread::FILE)); | |
| 648 local_store_observer_ = new LocalStoreObserver(this, local_store_); | 647 local_store_observer_ = new LocalStoreObserver(this, local_store_); |
| 649 local_store_->ReadPrefsAsync(NULL); | 648 local_store_->ReadPrefsAsync(NULL); |
| 650 } | 649 } |
| 651 | 650 |
| 652 void CredentialCacheService::StartListeningForSyncConfigChanges() { | 651 void CredentialCacheService::StartListeningForSyncConfigChanges() { |
| 653 // Register for notifications for google sign in and sign out. | 652 // Register for notifications for google sign in and sign out. |
| 654 registrar_.Add(this, | 653 registrar_.Add(this, |
| 655 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 654 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
| 656 content::Source<Profile>(profile_)); | 655 content::Source<Profile>(profile_)); |
| 657 registrar_.Add(this, | 656 registrar_.Add(this, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 688 chrome::NOTIFICATION_TOKENS_CLEARED, | 687 chrome::NOTIFICATION_TOKENS_CLEARED, |
| 689 content::Source<TokenService>(token_service)); | 688 content::Source<TokenService>(token_service)); |
| 690 } | 689 } |
| 691 | 690 |
| 692 void CredentialCacheService::LookForCachedCredentialsInAlternateProfile() { | 691 void CredentialCacheService::LookForCachedCredentialsInAlternateProfile() { |
| 693 // Attempt to read cached credentials from the alternate profile. If no file | 692 // Attempt to read cached credentials from the alternate profile. If no file |
| 694 // exists, ReadPrefsAsync() will cause PREF_READ_ERROR_NO_FILE to be returned | 693 // exists, ReadPrefsAsync() will cause PREF_READ_ERROR_NO_FILE to be returned |
| 695 // after initialization is complete. | 694 // after initialization is complete. |
| 696 alternate_store_ = new JsonPrefStore( | 695 alternate_store_ = new JsonPrefStore( |
| 697 GetCredentialPathInAlternateProfile(), | 696 GetCredentialPathInAlternateProfile(), |
| 698 content::BrowserThread::GetMessageLoopProxyForThread( | 697 BrowserThread::GetBlockingPool()); |
| 699 content::BrowserThread::FILE)); | |
| 700 alternate_store_observer_ = new AlternateStoreObserver(this, | 698 alternate_store_observer_ = new AlternateStoreObserver(this, |
| 701 alternate_store_); | 699 alternate_store_); |
| 702 alternate_store_->ReadPrefsAsync(NULL); | 700 alternate_store_->ReadPrefsAsync(NULL); |
| 703 } | 701 } |
| 704 | 702 |
| 705 bool CredentialCacheService::HasUserSignedOut() { | 703 bool CredentialCacheService::HasUserSignedOut() { |
| 706 DCHECK(local_store_.get()); | 704 DCHECK(local_store_.get()); |
| 707 // If HasPref() is false, the user never signed in, since there are no | 705 // If HasPref() is false, the user never signed in, since there are no |
| 708 // previously cached credentials. If the kGoogleServicesUsername pref is | 706 // previously cached credentials. If the kGoogleServicesUsername pref is |
| 709 // empty, it means that the user signed in and subsequently signed out. | 707 // empty, it means that the user signed in and subsequently signed out. |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 !HasUserSignedOut() && | 867 !HasUserSignedOut() && |
| 870 !alternate_google_services_username.empty() && | 868 !alternate_google_services_username.empty() && |
| 871 !alternate_lsid.empty() && | 869 !alternate_lsid.empty() && |
| 872 !alternate_sid.empty() && | 870 !alternate_sid.empty() && |
| 873 !(alternate_encryption_bootstrap_token.empty() && | 871 !(alternate_encryption_bootstrap_token.empty() && |
| 874 alternate_keystore_encryption_bootstrap_token.empty()) && | 872 alternate_keystore_encryption_bootstrap_token.empty()) && |
| 875 !service->setup_in_progress(); | 873 !service->setup_in_progress(); |
| 876 } | 874 } |
| 877 | 875 |
| 878 } // namespace syncer | 876 } // namespace syncer |
| OLD | NEW |