| 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/profile_sync_service_factory.h" | 5 #include "chrome/browser/sync/profile_sync_service_factory.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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 32 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
| 33 return Singleton<ProfileSyncServiceFactory>::get(); | 33 return Singleton<ProfileSyncServiceFactory>::get(); |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 37 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
| 38 Profile* profile) { | 38 Profile* profile) { |
| 39 if (!ProfileSyncService::IsSyncEnabled()) | 39 if (!ProfileSyncService::IsSyncEnabled()) |
| 40 return NULL; | 40 return NULL; |
| 41 | 41 |
| 42 // Do not start sync on the import process. |
| 43 if (ProfileManager::IsImportProcess(*CommandLine::ForCurrentProcess())) |
| 44 return NULL; |
| 45 |
| 42 return static_cast<ProfileSyncService*>( | 46 return static_cast<ProfileSyncService*>( |
| 43 GetInstance()->GetServiceForBrowserContext(profile, true)); | 47 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 44 } | 48 } |
| 45 | 49 |
| 46 ProfileSyncServiceFactory::ProfileSyncServiceFactory() | 50 ProfileSyncServiceFactory::ProfileSyncServiceFactory() |
| 47 : BrowserContextKeyedServiceFactory( | 51 : BrowserContextKeyedServiceFactory( |
| 48 "ProfileSyncService", | 52 "ProfileSyncService", |
| 49 BrowserContextDependencyManager::GetInstance()) { | 53 BrowserContextDependencyManager::GetInstance()) { |
| 50 | 54 |
| 51 // The ProfileSyncService depends on various SyncableServices being around | 55 // The ProfileSyncService depends on various SyncableServices being around |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 109 |
| 106 pss->factory()->RegisterDataTypes(pss); | 110 pss->factory()->RegisterDataTypes(pss); |
| 107 pss->Initialize(); | 111 pss->Initialize(); |
| 108 return pss; | 112 return pss; |
| 109 } | 113 } |
| 110 | 114 |
| 111 // static | 115 // static |
| 112 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 116 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 113 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 117 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 114 } | 118 } |
| OLD | NEW |