Index: chrome/browser/sync/credential_cache_service_factory_win.cc |
diff --git a/chrome/browser/sync/credential_cache_service_factory_win.cc b/chrome/browser/sync/credential_cache_service_factory_win.cc |
index a66c72b4ad169498d3da5ab47160f9e38589b70d..35f8697ae1c9f227d80653531481e3ebd2aca48c 100644 |
--- a/chrome/browser/sync/credential_cache_service_factory_win.cc |
+++ b/chrome/browser/sync/credential_cache_service_factory_win.cc |
@@ -54,6 +54,19 @@ bool CredentialCacheServiceFactory::IsDefaultProfile(Profile* profile) { |
ProfileManager::GetDefaultProfileDir(default_user_data_dir); |
} |
+// static |
+// TODO(rsimha): This is a test-only hook. Remove before shipping. |
+// See http://crbug.com/144280. |
+bool CredentialCacheServiceFactory::IsDefaultAlternateProfileForTest( |
+ Profile* profile) { |
+ DCHECK(profile); |
+ const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
+ FilePath alternate_user_data_dir; |
+ chrome::GetAlternateUserDataDirectory(&alternate_user_data_dir); |
+ return profile->GetPath() == |
+ ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); |
+} |
+ |
bool CredentialCacheServiceFactory::ServiceIsCreatedWithProfile() { |
return true; |
} |
@@ -62,9 +75,14 @@ ProfileKeyedService* CredentialCacheServiceFactory::BuildServiceInstanceFor( |
Profile* profile) const { |
// Only instantiate a CredentialCacheService object if we are running in the |
// default profile on Windows 8, and if credential caching is enabled. |
+ // TODO(rsimha): To allow for testing, start CredentialCacheService if we are |
+ // either in the default profile or the default alternate profile, so that |
+ // an instance of desktop chrome using the default metro directory can be |
+ // used for testing. See http://crbug.com/144280. |
const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
- IsDefaultProfile(profile) && |
+ (IsDefaultProfile(profile) || |
+ IsDefaultAlternateProfileForTest(profile)) && |
command_line->HasSwitch(switches::kEnableSyncCredentialCaching)) { |
return new syncer::CredentialCacheService(profile); |
} |