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 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
634 profile_)); | 634 profile_)); |
635 chrome::GetDefaultUserDataDirectory(&alternate_user_data_dir); | 635 chrome::GetDefaultUserDataDirectory(&alternate_user_data_dir); |
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_ = JsonPrefStore::Create( |
645 GetCredentialPathInCurrentProfile(), | 645 GetCredentialPathInCurrentProfile(), |
646 content::BrowserThread::GetMessageLoopProxyForThread( | 646 JsonPrefStore::GetTaskRunnerForFile(GetCredentialPathInCurrentProfile(), |
647 content::BrowserThread::FILE)); | 647 BrowserThread::GetBlockingPool())); |
648 local_store_observer_ = new LocalStoreObserver(this, local_store_); | 648 local_store_observer_ = new LocalStoreObserver(this, local_store_); |
649 local_store_->ReadPrefsAsync(NULL); | 649 local_store_->ReadPrefsAsync(NULL); |
650 } | 650 } |
651 | 651 |
652 void CredentialCacheService::StartListeningForSyncConfigChanges() { | 652 void CredentialCacheService::StartListeningForSyncConfigChanges() { |
653 // Register for notifications for google sign in and sign out. | 653 // Register for notifications for google sign in and sign out. |
654 registrar_.Add(this, | 654 registrar_.Add(this, |
655 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | 655 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
656 content::Source<Profile>(profile_)); | 656 content::Source<Profile>(profile_)); |
657 registrar_.Add(this, | 657 registrar_.Add(this, |
(...skipping 30 matching lines...) Expand all Loading... | |
688 chrome::NOTIFICATION_TOKENS_CLEARED, | 688 chrome::NOTIFICATION_TOKENS_CLEARED, |
689 content::Source<TokenService>(token_service)); | 689 content::Source<TokenService>(token_service)); |
690 } | 690 } |
691 | 691 |
692 void CredentialCacheService::LookForCachedCredentialsInAlternateProfile() { | 692 void CredentialCacheService::LookForCachedCredentialsInAlternateProfile() { |
693 // Attempt to read cached credentials from the alternate profile. If no file | 693 // 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 | 694 // exists, ReadPrefsAsync() will cause PREF_READ_ERROR_NO_FILE to be returned |
695 // after initialization is complete. | 695 // after initialization is complete. |
696 alternate_store_ = new JsonPrefStore( | 696 alternate_store_ = new JsonPrefStore( |
697 GetCredentialPathInAlternateProfile(), | 697 GetCredentialPathInAlternateProfile(), |
698 content::BrowserThread::GetMessageLoopProxyForThread( | 698 BrowserThread::GetBlockingPool()); |
akalin
2012/10/19 02:00:51
change this one to use GetTaskRunnerForFile like a
zel
2012/10/19 18:45:07
Done.
| |
699 content::BrowserThread::FILE)); | |
700 alternate_store_observer_ = new AlternateStoreObserver(this, | 699 alternate_store_observer_ = new AlternateStoreObserver(this, |
701 alternate_store_); | 700 alternate_store_); |
702 alternate_store_->ReadPrefsAsync(NULL); | 701 alternate_store_->ReadPrefsAsync(NULL); |
703 } | 702 } |
704 | 703 |
705 bool CredentialCacheService::HasUserSignedOut() { | 704 bool CredentialCacheService::HasUserSignedOut() { |
706 DCHECK(local_store_.get()); | 705 DCHECK(local_store_.get()); |
707 // If HasPref() is false, the user never signed in, since there are no | 706 // If HasPref() is false, the user never signed in, since there are no |
708 // previously cached credentials. If the kGoogleServicesUsername pref is | 707 // previously cached credentials. If the kGoogleServicesUsername pref is |
709 // empty, it means that the user signed in and subsequently signed out. | 708 // 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() && | 868 !HasUserSignedOut() && |
870 !alternate_google_services_username.empty() && | 869 !alternate_google_services_username.empty() && |
871 !alternate_lsid.empty() && | 870 !alternate_lsid.empty() && |
872 !alternate_sid.empty() && | 871 !alternate_sid.empty() && |
873 !(alternate_encryption_bootstrap_token.empty() && | 872 !(alternate_encryption_bootstrap_token.empty() && |
874 alternate_keystore_encryption_bootstrap_token.empty()) && | 873 alternate_keystore_encryption_bootstrap_token.empty()) && |
875 !service->setup_in_progress(); | 874 !service->setup_in_progress(); |
876 } | 875 } |
877 | 876 |
878 } // namespace syncer | 877 } // namespace syncer |
OLD | NEW |