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_factory_win.h" | 5 #include "chrome/browser/sync/credential_cache_service_factory_win.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 | 47 |
48 // static | 48 // static |
49 bool CredentialCacheServiceFactory::IsDefaultProfile(Profile* profile) { | 49 bool CredentialCacheServiceFactory::IsDefaultProfile(Profile* profile) { |
50 DCHECK(profile); | 50 DCHECK(profile); |
51 FilePath default_user_data_dir; | 51 FilePath default_user_data_dir; |
52 chrome::GetDefaultUserDataDirectory(&default_user_data_dir); | 52 chrome::GetDefaultUserDataDirectory(&default_user_data_dir); |
53 return profile->GetPath() == | 53 return profile->GetPath() == |
54 ProfileManager::GetDefaultProfileDir(default_user_data_dir); | 54 ProfileManager::GetDefaultProfileDir(default_user_data_dir); |
55 } | 55 } |
56 | 56 |
| 57 // static |
| 58 // TODO(rsimha): This is a test-only hook. Remove before shipping. |
| 59 // See http://crbug.com/144280. |
| 60 bool CredentialCacheServiceFactory::IsDefaultAlternateProfileForTest( |
| 61 Profile* profile) { |
| 62 DCHECK(profile); |
| 63 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 64 FilePath alternate_user_data_dir; |
| 65 chrome::GetAlternateUserDataDirectory(&alternate_user_data_dir); |
| 66 return profile->GetPath() == |
| 67 ProfileManager::GetDefaultProfileDir(alternate_user_data_dir); |
| 68 } |
| 69 |
57 bool CredentialCacheServiceFactory::ServiceIsCreatedWithProfile() { | 70 bool CredentialCacheServiceFactory::ServiceIsCreatedWithProfile() { |
58 return true; | 71 return true; |
59 } | 72 } |
60 | 73 |
61 ProfileKeyedService* CredentialCacheServiceFactory::BuildServiceInstanceFor( | 74 ProfileKeyedService* CredentialCacheServiceFactory::BuildServiceInstanceFor( |
62 Profile* profile) const { | 75 Profile* profile) const { |
63 // Only instantiate a CredentialCacheService object if we are running in the | 76 // Only instantiate a CredentialCacheService object if we are running in the |
64 // default profile on Windows 8, and if credential caching is enabled. | 77 // default profile on Windows 8, and if credential caching is enabled. |
| 78 // TODO(rsimha): To allow for testing, start CredentialCacheService if we are |
| 79 // either in the default profile or the default alternate profile, so that |
| 80 // an instance of desktop chrome using the default metro directory can be |
| 81 // used for testing. See http://crbug.com/144280. |
65 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 82 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
66 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 83 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
67 IsDefaultProfile(profile) && | 84 (IsDefaultProfile(profile) || |
| 85 IsDefaultAlternateProfileForTest(profile)) && |
68 command_line->HasSwitch(switches::kEnableSyncCredentialCaching)) { | 86 command_line->HasSwitch(switches::kEnableSyncCredentialCaching)) { |
69 return new syncer::CredentialCacheService(profile); | 87 return new syncer::CredentialCacheService(profile); |
70 } | 88 } |
71 return NULL; | 89 return NULL; |
72 } | 90 } |
73 | 91 |
74 } // namespace syncer | 92 } // namespace syncer |
OLD | NEW |