Chromium Code Reviews| 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 "base/time/time.h" |
| 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/defaults.h" | 14 #include "chrome/browser/defaults.h" |
| 15 #include "chrome/browser/history/history_service_factory.h" | 15 #include "chrome/browser/history/history_service_factory.h" |
| 16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 17 #include "chrome/browser/password_manager/password_store_factory.h" | 17 #include "chrome/browser/password_manager/password_store_factory.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/search_engines/template_url_service_factory.h" | 20 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 22 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 22 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
| 23 #include "chrome/browser/signin/about_signin_internals_factory.h" | 23 #include "chrome/browser/signin/about_signin_internals_factory.h" |
| 24 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 24 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 26 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
| 27 #include "chrome/browser/sync/chrome_sync_client.h" | 27 #include "chrome/browser/sync/chrome_sync_client.h" |
| 28 #include "chrome/browser/sync/profile_sync_components_factory_impl.h" | |
| 29 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" | 28 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h" |
| 30 #include "chrome/browser/themes/theme_service_factory.h" | 29 #include "chrome/browser/themes/theme_service_factory.h" |
| 31 #include "chrome/browser/web_data_service_factory.h" | 30 #include "chrome/browser/web_data_service_factory.h" |
| 32 #include "chrome/common/channel_info.h" | 31 #include "chrome/common/channel_info.h" |
| 32 #include "chrome/common/pref_names.h" | |
| 33 #include "components/browser_sync/browser/profile_sync_components_factory_impl.h " | |
| 33 #include "components/browser_sync/browser/profile_sync_service.h" | 34 #include "components/browser_sync/browser/profile_sync_service.h" |
| 34 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 35 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 35 #include "components/network_time/network_time_tracker.h" | 36 #include "components/network_time/network_time_tracker.h" |
| 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 37 #include "components/signin/core/browser/signin_manager.h" | 38 #include "components/signin/core/browser/signin_manager.h" |
| 38 #include "components/sync_driver/signin_manager_wrapper.h" | 39 #include "components/sync_driver/signin_manager_wrapper.h" |
| 39 #include "components/sync_driver/startup_controller.h" | 40 #include "components/sync_driver/startup_controller.h" |
| 40 #include "components/sync_driver/sync_util.h" | 41 #include "components/sync_driver/sync_util.h" |
| 41 #include "components/variations/variations_associated_data.h" | 42 #include "components/variations/variations_associated_data.h" |
| 42 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
| 44 #include "ui/base/device_form_factor.h" | |
| 43 #include "url/gurl.h" | 45 #include "url/gurl.h" |
| 44 | 46 |
| 45 #if defined(ENABLE_EXTENSIONS) | 47 #if defined(ENABLE_EXTENSIONS) |
| 46 #include "extensions/browser/extension_system_provider.h" | 48 #include "extensions/browser/extension_system_provider.h" |
| 47 #include "extensions/browser/extensions_browser_client.h" | 49 #include "extensions/browser/extensions_browser_client.h" |
| 48 #endif | 50 #endif |
| 49 | 51 |
| 50 #if !defined(OS_ANDROID) | 52 #if !defined(OS_ANDROID) |
| 51 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 53 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 52 #endif | 54 #endif |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 158 |
| 157 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup | 159 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup |
| 158 // once http://crbug.com/171406 has been fixed. | 160 // once http://crbug.com/171406 has been fixed. |
| 159 AboutSigninInternalsFactory::GetForProfile(profile); | 161 AboutSigninInternalsFactory::GetForProfile(profile); |
| 160 | 162 |
| 161 const GURL sync_service_url = GetSyncServiceURL( | 163 const GURL sync_service_url = GetSyncServiceURL( |
| 162 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); | 164 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); |
| 163 | 165 |
| 164 scoped_ptr<SigninManagerWrapper> signin_wrapper( | 166 scoped_ptr<SigninManagerWrapper> signin_wrapper( |
| 165 new SupervisedUserSigninManagerWrapper(profile, signin)); | 167 new SupervisedUserSigninManagerWrapper(profile, signin)); |
| 166 std::string account_id = signin_wrapper->GetAccountIdToUse(); | |
| 167 OAuth2TokenService::ScopeSet scope_set; | 168 OAuth2TokenService::ScopeSet scope_set; |
|
blundell
2015/11/12 10:33:47
it seems like this isn't used either?
Nicolas Zea
2015/11/12 19:07:29
Good catch, done.
| |
| 168 scope_set.insert(signin_wrapper->GetSyncScopeToUse()); | 169 scope_set.insert(signin_wrapper->GetSyncScopeToUse()); |
| 169 ProfileOAuth2TokenService* token_service = | 170 ProfileOAuth2TokenService* token_service = |
| 170 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); | 171 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); |
| 171 net::URLRequestContextGetter* url_request_context_getter = | 172 net::URLRequestContextGetter* url_request_context_getter = |
| 172 profile->GetRequestContext(); | 173 profile->GetRequestContext(); |
| 173 | 174 |
| 174 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync | 175 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync |
| 175 // is set up and *not* a browser restart for a manual-start platform (where | 176 // is set up and *not* a browser restart for a manual-start platform (where |
| 176 // sync has already been set up, and should be able to start without user | 177 // sync has already been set up, and should be able to start without user |
| 177 // intervention). We can get rid of the browser_default eventually, but | 178 // intervention). We can get rid of the browser_default eventually, but |
| 178 // need to take care that ProfileSyncService doesn't get tripped up between | 179 // need to take care that ProfileSyncService doesn't get tripped up between |
| 179 // those two cases. Bug 88109. | 180 // those two cases. Bug 88109. |
| 180 browser_sync::ProfileSyncServiceStartBehavior behavior = | 181 browser_sync::ProfileSyncServiceStartBehavior behavior = |
| 181 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START | 182 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START |
| 182 : browser_sync::MANUAL_START; | 183 : browser_sync::MANUAL_START; |
| 183 scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( | 184 browser_sync::ChromeSyncClient* chrome_sync_client = |
| 185 new browser_sync::ChromeSyncClient(profile); | |
| 186 sync_driver::SyncApiComponentFactory* sync_factory = | |
| 184 new ProfileSyncComponentsFactoryImpl( | 187 new ProfileSyncComponentsFactoryImpl( |
| 185 profile, base::CommandLine::ForCurrentProcess(), sync_service_url, | 188 chrome_sync_client, chrome::GetChannel(), chrome::GetVersionString(), |
| 186 token_service, url_request_context_getter)); | 189 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, |
| 187 scoped_ptr<browser_sync::ChromeSyncClient> sync_client( | 190 *base::CommandLine::ForCurrentProcess(), |
| 188 new browser_sync::ChromeSyncClient(profile, sync_factory.Pass())); | 191 prefs::kSavingBrowserHistoryDisabled, sync_service_url, |
| 192 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 193 content::BrowserThread::UI), | |
| 194 content::BrowserThread::GetMessageLoopProxyForThread( | |
| 195 content::BrowserThread::DB), | |
| 196 token_service, url_request_context_getter); | |
| 189 ProfileSyncService* pss = new ProfileSyncService( | 197 ProfileSyncService* pss = new ProfileSyncService( |
| 190 sync_client.Pass(), signin_wrapper.Pass(), token_service, | 198 make_scoped_ptr(chrome_sync_client), signin_wrapper.Pass(), token_service, |
| 191 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(), | 199 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(), |
| 192 profile->GetRequestContext(), profile->GetDebugName(), | 200 profile->GetRequestContext(), profile->GetDebugName(), |
| 193 chrome::GetChannel(), | 201 chrome::GetChannel(), |
| 194 content::BrowserThread::GetMessageLoopProxyForThread( | 202 content::BrowserThread::GetMessageLoopProxyForThread( |
| 195 content::BrowserThread::DB), | 203 content::BrowserThread::DB), |
| 196 content::BrowserThread::GetMessageLoopProxyForThread( | 204 content::BrowserThread::GetMessageLoopProxyForThread( |
| 197 content::BrowserThread::FILE), | 205 content::BrowserThread::FILE), |
| 198 content::BrowserThread::GetBlockingPool()); | 206 content::BrowserThread::GetBlockingPool()); |
| 207 | |
| 208 // The order in which these are performed matters. The PSS depends on the | |
| 209 // SyncClient being initialized before it can initalize itself. | |
| 210 chrome_sync_client->Initialize(make_scoped_ptr(sync_factory), pss); | |
| 199 pss->Initialize(); | 211 pss->Initialize(); |
| 200 return pss; | 212 return pss; |
| 201 } | 213 } |
| 202 | 214 |
| 203 // static | 215 // static |
| 204 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { | 216 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { |
| 205 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; | 217 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; |
| 206 } | 218 } |
| OLD | NEW |