| 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 "base/time/time.h" | 
| 10 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 
| 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 
|  | 13 #include "chrome/browser/browser_process.h" | 
| 12 #include "chrome/browser/defaults.h" | 14 #include "chrome/browser/defaults.h" | 
| 13 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" | 
| 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 
| 15 #include "chrome/browser/password_manager/password_store_factory.h" | 17 #include "chrome/browser/password_manager/password_store_factory.h" | 
| 16 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" | 
| 17 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" | 
| 18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 
| 19 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 
| 20 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 22 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 
| 21 #include "chrome/browser/signin/about_signin_internals_factory.h" | 23 #include "chrome/browser/signin/about_signin_internals_factory.h" | 
| 22 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 24 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 
| 23 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 
| 24 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" | 
| 25 #include "chrome/browser/sync/chrome_sync_client.h" | 27 #include "chrome/browser/sync/chrome_sync_client.h" | 
| 26 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 28 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | 
| 27 #include "chrome/browser/sync/profile_sync_service.h" | 29 #include "chrome/browser/sync/profile_sync_service.h" | 
| 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 30 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 
| 29 #include "chrome/browser/themes/theme_service_factory.h" | 31 #include "chrome/browser/themes/theme_service_factory.h" | 
| 30 #include "chrome/browser/web_data_service_factory.h" | 32 #include "chrome/browser/web_data_service_factory.h" | 
| 31 #include "chrome/common/channel_info.h" | 33 #include "chrome/common/channel_info.h" | 
| 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 34 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 
|  | 35 #include "components/network_time/network_time_tracker.h" | 
| 33 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 
| 34 #include "components/signin/core/browser/signin_manager.h" | 37 #include "components/signin/core/browser/signin_manager.h" | 
| 35 #include "components/sync_driver/signin_manager_wrapper.h" | 38 #include "components/sync_driver/signin_manager_wrapper.h" | 
| 36 #include "components/sync_driver/startup_controller.h" | 39 #include "components/sync_driver/startup_controller.h" | 
| 37 #include "components/sync_driver/sync_util.h" | 40 #include "components/sync_driver/sync_util.h" | 
| 38 #include "components/variations/variations_associated_data.h" | 41 #include "components/variations/variations_associated_data.h" | 
|  | 42 #include "content/public/browser/browser_thread.h" | 
| 39 #include "url/gurl.h" | 43 #include "url/gurl.h" | 
| 40 | 44 | 
| 41 #if defined(ENABLE_EXTENSIONS) | 45 #if defined(ENABLE_EXTENSIONS) | 
| 42 #include "extensions/browser/extension_system_provider.h" | 46 #include "extensions/browser/extension_system_provider.h" | 
| 43 #include "extensions/browser/extensions_browser_client.h" | 47 #include "extensions/browser/extensions_browser_client.h" | 
| 44 #endif | 48 #endif | 
| 45 | 49 | 
| 46 #if !defined(OS_ANDROID) | 50 #if !defined(OS_ANDROID) | 
| 47 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 51 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 
| 48 #endif | 52 #endif | 
| 49 | 53 | 
|  | 54 namespace { | 
|  | 55 | 
|  | 56 void UpdateNetworkTimeOnUIThread(base::Time network_time, | 
|  | 57                                  base::TimeDelta resolution, | 
|  | 58                                  base::TimeDelta latency, | 
|  | 59                                  base::TimeTicks post_time) { | 
|  | 60   g_browser_process->network_time_tracker()->UpdateNetworkTime( | 
|  | 61       network_time, resolution, latency, post_time); | 
|  | 62 } | 
|  | 63 | 
|  | 64 void UpdateNetworkTime(const base::Time& network_time, | 
|  | 65                        const base::TimeDelta& resolution, | 
|  | 66                        const base::TimeDelta& latency) { | 
|  | 67   content::BrowserThread::PostTask( | 
|  | 68       content::BrowserThread::UI, FROM_HERE, | 
|  | 69       base::Bind(&UpdateNetworkTimeOnUIThread, network_time, resolution, | 
|  | 70                  latency, base::TimeTicks::Now())); | 
|  | 71 } | 
|  | 72 | 
|  | 73 }  // anonymous namespace | 
|  | 74 | 
| 50 // static | 75 // static | 
| 51 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 76 ProfileSyncServiceFactory* ProfileSyncServiceFactory::GetInstance() { | 
| 52   return base::Singleton<ProfileSyncServiceFactory>::get(); | 77   return base::Singleton<ProfileSyncServiceFactory>::get(); | 
| 53 } | 78 } | 
| 54 | 79 | 
| 55 // static | 80 // static | 
| 56 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 81 ProfileSyncService* ProfileSyncServiceFactory::GetForProfile( | 
| 57     Profile* profile) { | 82     Profile* profile) { | 
| 58   if (!ProfileSyncService::IsSyncAllowedByFlag()) | 83   if (!ProfileSyncService::IsSyncAllowedByFlag()) | 
| 59     return NULL; | 84     return NULL; | 
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 154   // those two cases. Bug 88109. | 179   // those two cases. Bug 88109. | 
| 155   browser_sync::ProfileSyncServiceStartBehavior behavior = | 180   browser_sync::ProfileSyncServiceStartBehavior behavior = | 
| 156       browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START | 181       browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START | 
| 157                                         : browser_sync::MANUAL_START; | 182                                         : browser_sync::MANUAL_START; | 
| 158   scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( | 183   scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( | 
| 159       new ProfileSyncComponentsFactoryImpl( | 184       new ProfileSyncComponentsFactoryImpl( | 
| 160           profile, base::CommandLine::ForCurrentProcess(), sync_service_url, | 185           profile, base::CommandLine::ForCurrentProcess(), sync_service_url, | 
| 161           token_service, url_request_context_getter)); | 186           token_service, url_request_context_getter)); | 
| 162   scoped_ptr<browser_sync::ChromeSyncClient> sync_client( | 187   scoped_ptr<browser_sync::ChromeSyncClient> sync_client( | 
| 163       new browser_sync::ChromeSyncClient(profile, sync_factory.Pass())); | 188       new browser_sync::ChromeSyncClient(profile, sync_factory.Pass())); | 
| 164   ProfileSyncService* pss = | 189   ProfileSyncService* pss = new ProfileSyncService( | 
| 165       new ProfileSyncService(sync_client.Pass(), profile, signin_wrapper.Pass(), | 190       sync_client.Pass(), profile, signin_wrapper.Pass(), token_service, | 
| 166                              token_service, behavior); | 191       behavior, base::Bind(&UpdateNetworkTime)); | 
| 167   pss->Initialize(); | 192   pss->Initialize(); | 
| 168   return pss; | 193   return pss; | 
| 169 } | 194 } | 
| 170 | 195 | 
| 171 // static | 196 // static | 
| 172 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 197 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 
| 173   return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 198   return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 
| 174 } | 199 } | 
| OLD | NEW | 
|---|