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

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

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

Powered by Google App Engine
This is Rietveld 408576698