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