Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(746)

Side by Side Diff: chrome/browser/sync/profile_sync_service_factory.cc

Issue 1421003007: [Sync] Componentize ProfileSyncComponentsFactoryImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix sessions api test Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
10 #include "base/time/time.h" 9 #include "base/time/time.h"
11 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
12 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 11 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
13 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/defaults.h" 13 #include "chrome/browser/defaults.h"
15 #include "chrome/browser/history/history_service_factory.h" 14 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" 15 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h"
17 #include "chrome/browser/password_manager/password_store_factory.h" 16 #include "chrome/browser/password_manager/password_store_factory.h"
18 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
20 #include "chrome/browser/search_engines/template_url_service_factory.h" 19 #include "chrome/browser/search_engines/template_url_service_factory.h"
21 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" 20 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h"
22 #include "chrome/browser/sessions/tab_restore_service_factory.h" 21 #include "chrome/browser/sessions/tab_restore_service_factory.h"
23 #include "chrome/browser/signin/about_signin_internals_factory.h" 22 #include "chrome/browser/signin/about_signin_internals_factory.h"
24 #include "chrome/browser/signin/chrome_signin_client_factory.h" 23 #include "chrome/browser/signin/chrome_signin_client_factory.h"
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
26 #include "chrome/browser/signin/signin_manager_factory.h" 25 #include "chrome/browser/signin/signin_manager_factory.h"
27 #include "chrome/browser/sync/chrome_sync_client.h" 26 #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" 27 #include "chrome/browser/sync/supervised_user_signin_manager_wrapper.h"
30 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
31 #include "chrome/browser/web_data_service_factory.h" 29 #include "chrome/browser/web_data_service_factory.h"
32 #include "chrome/common/channel_info.h" 30 #include "chrome/common/channel_info.h"
31 #include "components/browser_sync/browser/profile_sync_components_factory_impl.h "
33 #include "components/browser_sync/browser/profile_sync_service.h" 32 #include "components/browser_sync/browser/profile_sync_service.h"
34 #include "components/keyed_service/content/browser_context_dependency_manager.h" 33 #include "components/keyed_service/content/browser_context_dependency_manager.h"
35 #include "components/network_time/network_time_tracker.h" 34 #include "components/network_time/network_time_tracker.h"
36 #include "components/signin/core/browser/profile_oauth2_token_service.h" 35 #include "components/signin/core/browser/profile_oauth2_token_service.h"
37 #include "components/signin/core/browser/signin_manager.h" 36 #include "components/signin/core/browser/signin_manager.h"
38 #include "components/sync_driver/signin_manager_wrapper.h" 37 #include "components/sync_driver/signin_manager_wrapper.h"
39 #include "components/sync_driver/startup_controller.h" 38 #include "components/sync_driver/startup_controller.h"
40 #include "components/sync_driver/sync_util.h" 39 #include "components/sync_driver/sync_util.h"
41 #include "content/public/browser/browser_thread.h" 40 #include "content/public/browser/browser_thread.h"
42 #include "url/gurl.h" 41 #include "url/gurl.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 140
142 // Always create the GCMProfileService instance such that we can listen to 141 // Always create the GCMProfileService instance such that we can listen to
143 // the profile notifications and purge the GCM store when the profile is 142 // the profile notifications and purge the GCM store when the profile is
144 // being signed out. 143 // being signed out.
145 gcm::GCMProfileServiceFactory::GetForProfile(profile); 144 gcm::GCMProfileServiceFactory::GetForProfile(profile);
146 145
147 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup 146 // TODO(atwilson): Change AboutSigninInternalsFactory to load on startup
148 // once http://crbug.com/171406 has been fixed. 147 // once http://crbug.com/171406 has been fixed.
149 AboutSigninInternalsFactory::GetForProfile(profile); 148 AboutSigninInternalsFactory::GetForProfile(profile);
150 149
151 const GURL sync_service_url = GetSyncServiceURL(
152 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
153
154 scoped_ptr<SigninManagerWrapper> signin_wrapper( 150 scoped_ptr<SigninManagerWrapper> signin_wrapper(
155 new SupervisedUserSigninManagerWrapper(profile, signin)); 151 new SupervisedUserSigninManagerWrapper(profile, signin));
156 std::string account_id = signin_wrapper->GetAccountIdToUse(); 152
157 OAuth2TokenService::ScopeSet scope_set;
158 scope_set.insert(signin_wrapper->GetSyncScopeToUse());
159 ProfileOAuth2TokenService* token_service = 153 ProfileOAuth2TokenService* token_service =
160 ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 154 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
161 net::URLRequestContextGetter* url_request_context_getter =
162 profile->GetRequestContext();
163 155
164 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync 156 // TODO(tim): Currently, AUTO/MANUAL settings refer to the *first* time sync
165 // is set up and *not* a browser restart for a manual-start platform (where 157 // is set up and *not* a browser restart for a manual-start platform (where
166 // sync has already been set up, and should be able to start without user 158 // sync has already been set up, and should be able to start without user
167 // intervention). We can get rid of the browser_default eventually, but 159 // intervention). We can get rid of the browser_default eventually, but
168 // need to take care that ProfileSyncService doesn't get tripped up between 160 // need to take care that ProfileSyncService doesn't get tripped up between
169 // those two cases. Bug 88109. 161 // those two cases. Bug 88109.
170 browser_sync::ProfileSyncServiceStartBehavior behavior = 162 browser_sync::ProfileSyncServiceStartBehavior behavior =
171 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START 163 browser_defaults::kSyncAutoStarts ? browser_sync::AUTO_START
172 : browser_sync::MANUAL_START; 164 : browser_sync::MANUAL_START;
173 scoped_ptr<sync_driver::SyncApiComponentFactory> sync_factory( 165 browser_sync::ChromeSyncClient* chrome_sync_client =
174 new ProfileSyncComponentsFactoryImpl( 166 new browser_sync::ChromeSyncClient(profile);
175 profile, base::CommandLine::ForCurrentProcess(), sync_service_url,
176 token_service, url_request_context_getter));
177 scoped_ptr<browser_sync::ChromeSyncClient> sync_client(
178 new browser_sync::ChromeSyncClient(profile, sync_factory.Pass()));
179 ProfileSyncService* pss = new ProfileSyncService( 167 ProfileSyncService* pss = new ProfileSyncService(
180 sync_client.Pass(), signin_wrapper.Pass(), token_service, 168 make_scoped_ptr(chrome_sync_client), signin_wrapper.Pass(), token_service,
181 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(), 169 behavior, base::Bind(&UpdateNetworkTime), profile->GetPath(),
182 profile->GetRequestContext(), profile->GetDebugName(), 170 profile->GetRequestContext(), profile->GetDebugName(),
183 chrome::GetChannel(), 171 chrome::GetChannel(),
184 content::BrowserThread::GetMessageLoopProxyForThread( 172 content::BrowserThread::GetMessageLoopProxyForThread(
185 content::BrowserThread::DB), 173 content::BrowserThread::DB),
186 content::BrowserThread::GetMessageLoopProxyForThread( 174 content::BrowserThread::GetMessageLoopProxyForThread(
187 content::BrowserThread::FILE), 175 content::BrowserThread::FILE),
188 content::BrowserThread::GetBlockingPool()); 176 content::BrowserThread::GetBlockingPool());
177
178 // Will also initialize the sync client.
189 pss->Initialize(); 179 pss->Initialize();
190 return pss; 180 return pss;
191 } 181 }
192 182
193 // static 183 // static
194 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) { 184 bool ProfileSyncServiceFactory::HasProfileSyncService(Profile* profile) {
195 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL; 185 return GetInstance()->GetServiceForBrowserContext(profile, false) != NULL;
196 } 186 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698