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" |
11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
12 #include "chrome/browser/defaults.h" | 12 #include "chrome/browser/defaults.h" |
13 #include "chrome/browser/extensions/extension_system_factory.h" | 13 #include "chrome/browser/extensions/extension_system_factory.h" |
14 #include "chrome/browser/history/history_service_factory.h" | 14 #include "chrome/browser/history/history_service_factory.h" |
15 #include "chrome/browser/password_manager/password_store_factory.h" | 15 #include "chrome/browser/password_manager/password_store_factory.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/profiles/profile_dependency_manager.h" | 17 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 19 #include "chrome/browser/search_engines/template_url_service_factory.h" |
19 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 20 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
20 #include "chrome/browser/signin/about_signin_internals_factory.h" | 21 #include "chrome/browser/signin/about_signin_internals_factory.h" |
21 #include "chrome/browser/signin/signin_manager.h" | 22 #include "chrome/browser/signin/signin_manager.h" |
22 #include "chrome/browser/signin/signin_manager_factory.h" | 23 #include "chrome/browser/signin/signin_manager_factory.h" |
23 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 24 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
24 #include "chrome/browser/sync/profile_sync_service.h" | 25 #include "chrome/browser/sync/profile_sync_service.h" |
25 #include "chrome/browser/themes/theme_service_factory.h" | 26 #include "chrome/browser/themes/theme_service_factory.h" |
26 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 27 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
27 #include "chrome/browser/webdata/web_data_service_factory.h" | 28 #include "chrome/browser/webdata/web_data_service_factory.h" |
28 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
29 | 30 |
30 // static | 31 // static |
31 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 32 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
32 return Singleton<ProfileSyncServiceFactory>::get(); | 33 return Singleton<ProfileSyncServiceFactory>::get(); |
33 } | 34 } |
34 | 35 |
35 // static | 36 // static |
36 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 37 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
37 Profile* profile) { | 38 Profile* profile) { |
38 if (!ProfileSyncService::IsSyncEnabled()) | 39 if (!ProfileSyncService::IsSyncEnabled()) |
39 return NULL; | 40 return NULL; |
40 | 41 |
| 42 // Do not start sync on the import process. |
| 43 if (ProfileManager::IsImportProcess(*CommandLine::ForCurrentProcess())) |
| 44 return NULL; |
| 45 |
41 return static_cast<ProfileSyncService*>( | 46 return static_cast<ProfileSyncService*>( |
42 GetInstance()->GetServiceForProfile(profile, true)); | 47 GetInstance()->GetServiceForProfile(profile, true)); |
43 } | 48 } |
44 | 49 |
45 // static | 50 // static |
46 ProfileSyncServiceBase* ProfileSyncServiceBase::FromBrowserContext( | 51 ProfileSyncServiceBase* ProfileSyncServiceBase::FromBrowserContext( |
47 content::BrowserContext* context) { | 52 content::BrowserContext* context) { |
48 return ProfileSyncServiceFactory::GetForProfile( | 53 return ProfileSyncServiceFactory::GetForProfile( |
49 static_cast<Profile*>(context)); | 54 static_cast<Profile*>(context)); |
50 } | 55 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 113 |
109 pss->factory()->RegisterDataTypes(pss); | 114 pss->factory()->RegisterDataTypes(pss); |
110 pss->Initialize(); | 115 pss->Initialize(); |
111 return pss; | 116 return pss; |
112 } | 117 } |
113 | 118 |
114 // static | 119 // static |
115 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 120 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
116 return GetInstance()->GetServiceForProfile(profile, false) != NULL; | 121 return GetInstance()->GetServiceForProfile(profile, false) != NULL; |
117 } | 122 } |
OLD | NEW |