| 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 14 matching lines...) Expand all Loading... |
| 25 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 25 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" |
| 26 #include "chrome/browser/sync/profile_sync_service.h" | 26 #include "chrome/browser/sync/profile_sync_service.h" |
| 27 #include "chrome/browser/sync/startup_controller.h" | 27 #include "chrome/browser/sync/startup_controller.h" |
| 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 29 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 30 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 31 #include "chrome/browser/webdata/web_data_service_factory.h" | 31 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 33 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 33 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 34 #include "components/signin/core/browser/signin_manager.h" | 34 #include "components/signin/core/browser/signin_manager.h" |
| 35 #include "components/variations/variations_associated_data.h" |
| 35 #include "url/gurl.h" | 36 #include "url/gurl.h" |
| 36 | 37 |
| 37 #if defined(ENABLE_EXTENSIONS) | 38 #if defined(ENABLE_EXTENSIONS) |
| 38 #include "extensions/browser/extension_system_provider.h" | 39 #include "extensions/browser/extension_system_provider.h" |
| 39 #include "extensions/browser/extensions_browser_client.h" | 40 #include "extensions/browser/extensions_browser_client.h" |
| 40 #endif | 41 #endif |
| 41 | 42 |
| 42 // static | 43 // static |
| 43 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 44 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { |
| 44 return Singleton<ProfileSyncServiceFactory>::get(); | 45 return Singleton<ProfileSyncServiceFactory>::get(); |
| 45 } | 46 } |
| 46 | 47 |
| 47 // static | 48 // static |
| 48 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 49 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( |
| 49 Profile* profile) { | 50 Profile* profile) { |
| 50 if (!ProfileSyncService::IsSyncEnabled()) | 51 if (!ProfileSyncService::IsSyncEnabled()) |
| 51 return NULL; | 52 return NULL; |
| 52 | 53 |
| 54 // Disable sync experimentally to measure impact on startup time. Supervised |
| 55 // users are unaffected, since supervised users rely completely on sync. |
| 56 // TODO(mlerman): Remove this after the experiment. crbug.com/454788 |
| 57 if (!profile->IsSupervised() && |
| 58 !variations::GetVariationParamValue("LightSpeed", "DisableSync") |
| 59 .empty()) { |
| 60 return NULL; |
| 61 } |
| 62 |
| 53 return static_cast<ProfileSyncService*>( | 63 return static_cast<ProfileSyncService*>( |
| 54 GetInstance()->GetServiceForBrowserContext(profile, true)); | 64 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 55 } | 65 } |
| 56 | 66 |
| 57 ProfileSyncServiceFactory::ProfileSyncServiceFactory() | 67 ProfileSyncServiceFactory::ProfileSyncServiceFactory() |
| 58 : BrowserContextKeyedServiceFactory( | 68 : BrowserContextKeyedServiceFactory( |
| 59 "ProfileSyncService", | 69 "ProfileSyncService", |
| 60 BrowserContextDependencyManager::GetInstance()) { | 70 BrowserContextDependencyManager::GetInstance()) { |
| 61 // The ProfileSyncService depends on various SyncableServices being around | 71 // The ProfileSyncService depends on various SyncableServices being around |
| 62 // when it is shut down. Specify those dependencies here to build the proper | 72 // when it is shut down. Specify those dependencies here to build the proper |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 | 148 |
| 139 pss->factory()->RegisterDataTypes(pss); | 149 pss->factory()->RegisterDataTypes(pss); |
| 140 pss->Initialize(); | 150 pss->Initialize(); |
| 141 return pss; | 151 return pss; |
| 142 } | 152 } |
| 143 | 153 |
| 144 // static | 154 // static |
| 145 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 155 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 146 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 156 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 147 } | 157 } |
| OLD | NEW |