| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 12 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 13 #include "base/time.h" | 14 #include "base/time.h" |
| 14 #include "base/values.h" | 15 #include "base/values.h" |
| 15 #include "base/win/windows_version.h" | 16 #include "base/win/windows_version.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/signin/signin_manager.h" | 20 #include "chrome/browser/signin/signin_manager.h" |
| 20 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 21 #include "chrome/browser/signin/token_service.h" | 22 #include "chrome/browser/signin/token_service.h" |
| 22 #include "chrome/browser/signin/token_service_factory.h" | 23 #include "chrome/browser/signin/token_service_factory.h" |
| 24 #include "chrome/browser/sync/credential_cache_service_factory_win.h" |
| 23 #include "chrome/browser/sync/glue/chrome_encryptor.h" | 25 #include "chrome/browser/sync/glue/chrome_encryptor.h" |
| 24 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
| 25 #include "chrome/browser/sync/profile_sync_service_factory.h" | 27 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 26 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 28 #include "chrome/common/chrome_paths_internal.h" | 30 #include "chrome/common/chrome_paths_internal.h" |
| 31 #include "chrome/common/chrome_switches.h" |
| 29 #include "chrome/common/net/gaia/gaia_auth_consumer.h" | 32 #include "chrome/common/net/gaia/gaia_auth_consumer.h" |
| 30 #include "chrome/common/net/gaia/gaia_constants.h" | 33 #include "chrome/common/net/gaia/gaia_constants.h" |
| 31 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
| 32 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 33 #include "content/public/browser/notification_details.h" | 36 #include "content/public/browser/notification_details.h" |
| 34 #include "content/public/browser/notification_source.h" | 37 #include "content/public/browser/notification_source.h" |
| 35 #include "sync/internal_api/public/base/model_type.h" | 38 #include "sync/internal_api/public/base/model_type.h" |
| 36 | 39 |
| 37 namespace syncer { | 40 namespace syncer { |
| 38 | 41 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 // the sync credential path in the default Metro profile is | 602 // the sync credential path in the default Metro profile is |
| 600 // "%Appdata%\Local\Google\Chrome\Metro\User Data\Default\Sync Credentials". | 603 // "%Appdata%\Local\Google\Chrome\Metro\User Data\Default\Sync Credentials". |
| 601 DCHECK(profile_); | 604 DCHECK(profile_); |
| 602 return profile_->GetPath().Append(chrome::kSyncCredentialsFilename); | 605 return profile_->GetPath().Append(chrome::kSyncCredentialsFilename); |
| 603 } | 606 } |
| 604 | 607 |
| 605 FilePath CredentialCacheService::GetCredentialPathInAlternateProfile() const { | 608 FilePath CredentialCacheService::GetCredentialPathInAlternateProfile() const { |
| 606 DCHECK(profile_); | 609 DCHECK(profile_); |
| 607 FilePath alternate_user_data_dir; | 610 FilePath alternate_user_data_dir; |
| 608 chrome::GetAlternateUserDataDirectory(&alternate_user_data_dir); | 611 chrome::GetAlternateUserDataDirectory(&alternate_user_data_dir); |
| 612 |
| 613 // TODO(rsimha): This code path is to allow for testing in the presence of |
| 614 // strange singleton mode. Delete this block before shipping. |
| 615 // See http://crbug.com/144280. |
| 616 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 617 if (command_line->HasSwitch(switches::kEnableSyncCredentialCaching) && |
| 618 !CredentialCacheServiceFactory::IsDefaultProfile(profile_)) { |
| 619 DCHECK(CredentialCacheServiceFactory::IsDefaultAlternateProfileForTest( |
| 620 profile_)); |
| 621 chrome::GetDefaultUserDataDirectory(&alternate_user_data_dir); |
| 622 } |
| 623 |
| 609 FilePath alternate_default_profile_dir = | 624 FilePath alternate_default_profile_dir = |
| 610 ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); | 625 ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); |
| 611 return alternate_default_profile_dir.Append(chrome::kSyncCredentialsFilename); | 626 return alternate_default_profile_dir.Append(chrome::kSyncCredentialsFilename); |
| 612 } | 627 } |
| 613 | 628 |
| 614 void CredentialCacheService::InitializeLocalCredentialCacheWriter() { | 629 void CredentialCacheService::InitializeLocalCredentialCacheWriter() { |
| 615 local_store_ = new JsonPrefStore( | 630 local_store_ = new JsonPrefStore( |
| 616 GetCredentialPathInCurrentProfile(), | 631 GetCredentialPathInCurrentProfile(), |
| 617 content::BrowserThread::GetMessageLoopProxyForThread( | 632 content::BrowserThread::GetMessageLoopProxyForThread( |
| 618 content::BrowserThread::FILE)); | 633 content::BrowserThread::FILE)); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 !HasUserSignedOut() && | 846 !HasUserSignedOut() && |
| 832 !alternate_google_services_username.empty() && | 847 !alternate_google_services_username.empty() && |
| 833 !alternate_lsid.empty() && | 848 !alternate_lsid.empty() && |
| 834 !alternate_sid.empty() && | 849 !alternate_sid.empty() && |
| 835 !(alternate_encryption_bootstrap_token.empty() && | 850 !(alternate_encryption_bootstrap_token.empty() && |
| 836 alternate_keystore_encryption_bootstrap_token.empty()) && | 851 alternate_keystore_encryption_bootstrap_token.empty()) && |
| 837 !service->setup_in_progress(); | 852 !service->setup_in_progress(); |
| 838 } | 853 } |
| 839 | 854 |
| 840 } // namespace syncer | 855 } // namespace syncer |
| OLD | NEW |