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

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

Issue 1460723004: [Sync] Remove the last datatype-specific deps from sync_driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delete outdated comment. Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chrome_sync_client.h" 5 #include "chrome/browser/sync/chrome_sync_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "chrome/browser/autofill/personal_data_manager_factory.h" 9 #include "chrome/browser/autofill/personal_data_manager_factory.h"
10 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 10 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 : profile_(profile), 175 : profile_(profile),
176 sync_sessions_client_(new SyncSessionsClientImpl(profile)), 176 sync_sessions_client_(new SyncSessionsClientImpl(profile)),
177 browsing_data_remover_observer_(NULL), 177 browsing_data_remover_observer_(NULL),
178 weak_ptr_factory_(this) {} 178 weak_ptr_factory_(this) {}
179 179
180 ChromeSyncClient::~ChromeSyncClient() { 180 ChromeSyncClient::~ChromeSyncClient() {
181 } 181 }
182 182
183 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { 183 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) {
184 DCHECK_CURRENTLY_ON(BrowserThread::UI); 184 DCHECK_CURRENTLY_ON(BrowserThread::UI);
185
186 web_data_service_ = WebDataServiceFactory::GetAutofillWebDataForProfile(
187 profile_, ServiceAccessType::EXPLICIT_ACCESS);
188 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here?
189 password_store_ = PasswordStoreFactory::GetForProfile(
190 profile_, ServiceAccessType::EXPLICIT_ACCESS);
191
185 // Component factory may already be set in tests. 192 // Component factory may already be set in tests.
186 if (!GetSyncApiComponentFactory()) { 193 if (!GetSyncApiComponentFactory()) {
187 const GURL sync_service_url = GetSyncServiceURL( 194 const GURL sync_service_url = GetSyncServiceURL(
188 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel()); 195 *base::CommandLine::ForCurrentProcess(), chrome::GetChannel());
189 ProfileOAuth2TokenService* token_service = 196 ProfileOAuth2TokenService* token_service =
190 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_); 197 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_);
191 net::URLRequestContextGetter* url_request_context_getter = 198 net::URLRequestContextGetter* url_request_context_getter =
192 profile_->GetRequestContext(); 199 profile_->GetRequestContext();
193 200
194 component_factory_.reset(new ProfileSyncComponentsFactoryImpl( 201 component_factory_.reset(new ProfileSyncComponentsFactoryImpl(
195 this, chrome::GetChannel(), chrome::GetVersionString(), 202 this, chrome::GetChannel(), chrome::GetVersionString(),
196 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, 203 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET,
197 *base::CommandLine::ForCurrentProcess(), 204 *base::CommandLine::ForCurrentProcess(),
198 prefs::kSavingBrowserHistoryDisabled, sync_service_url, 205 prefs::kSavingBrowserHistoryDisabled, sync_service_url,
199 content::BrowserThread::GetMessageLoopProxyForThread( 206 content::BrowserThread::GetMessageLoopProxyForThread(
200 content::BrowserThread::UI), 207 content::BrowserThread::UI),
201 content::BrowserThread::GetMessageLoopProxyForThread( 208 content::BrowserThread::GetMessageLoopProxyForThread(
202 content::BrowserThread::DB), 209 content::BrowserThread::DB),
203 token_service, url_request_context_getter)); 210 token_service, url_request_context_getter, web_data_service_,
211 password_store_));
204 } 212 }
205 sync_service_ = sync_service; 213 sync_service_ = sync_service;
206 web_data_service_ = GetWebDataService();
207 password_store_ = GetPasswordStore();
208 } 214 }
209 215
210 sync_driver::SyncService* ChromeSyncClient::GetSyncService() { 216 sync_driver::SyncService* ChromeSyncClient::GetSyncService() {
211 // TODO(zea): bring back this DCHECK after Typed URLs are converted to 217 // TODO(zea): bring back this DCHECK after Typed URLs are converted to
212 // SyncableService. 218 // SyncableService.
213 // DCHECK_CURRENTLY_ON(BrowserThread::UI); 219 // DCHECK_CURRENTLY_ON(BrowserThread::UI);
214 return sync_service_; 220 return sync_service_;
215 } 221 }
216 222
217 PrefService* ChromeSyncClient::GetPrefService() { 223 PrefService* ChromeSyncClient::GetPrefService() {
(...skipping 16 matching lines...) Expand all
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); 240 DCHECK_CURRENTLY_ON(BrowserThread::UI);
235 return HistoryServiceFactory::GetForProfile( 241 return HistoryServiceFactory::GetForProfile(
236 profile_, ServiceAccessType::EXPLICIT_ACCESS); 242 profile_, ServiceAccessType::EXPLICIT_ACCESS);
237 } 243 }
238 244
239 autofill::PersonalDataManager* ChromeSyncClient::GetPersonalDataManager() { 245 autofill::PersonalDataManager* ChromeSyncClient::GetPersonalDataManager() {
240 DCHECK_CURRENTLY_ON(BrowserThread::UI); 246 DCHECK_CURRENTLY_ON(BrowserThread::UI);
241 return autofill::PersonalDataManagerFactory::GetForProfile(profile_); 247 return autofill::PersonalDataManagerFactory::GetForProfile(profile_);
242 } 248 }
243 249
244 scoped_refptr<password_manager::PasswordStore>
245 ChromeSyncClient::GetPasswordStore() {
246 DCHECK_CURRENTLY_ON(BrowserThread::UI);
247 return PasswordStoreFactory::GetForProfile(
248 profile_, ServiceAccessType::EXPLICIT_ACCESS);
249 }
250
251 sync_driver::ClearBrowsingDataCallback 250 sync_driver::ClearBrowsingDataCallback
252 ChromeSyncClient::GetClearBrowsingDataCallback() { 251 ChromeSyncClient::GetClearBrowsingDataCallback() {
253 return base::Bind(&ChromeSyncClient::ClearBrowsingData, 252 return base::Bind(&ChromeSyncClient::ClearBrowsingData,
254 base::Unretained(this)); 253 base::Unretained(this));
255 } 254 }
256 255
257 base::Closure ChromeSyncClient::GetPasswordStateChangedCallback() { 256 base::Closure ChromeSyncClient::GetPasswordStateChangedCallback() {
258 return base::Bind( 257 return base::Bind(
259 &PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged, 258 &PasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged,
260 base::Unretained(profile_)); 259 base::Unretained(profile_));
261 } 260 }
262 261
263 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod 262 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod
264 ChromeSyncClient::GetRegisterPlatformTypesCallback() { 263 ChromeSyncClient::GetRegisterPlatformTypesCallback() {
265 return base::Bind( 264 return base::Bind(
266 #if BUILDFLAG(ANDROID_JAVA_UI) 265 #if BUILDFLAG(ANDROID_JAVA_UI)
267 &ChromeSyncClient::RegisterAndroidDataTypes, 266 &ChromeSyncClient::RegisterAndroidDataTypes,
268 #else 267 #else
269 &ChromeSyncClient::RegisterDesktopDataTypes, 268 &ChromeSyncClient::RegisterDesktopDataTypes,
270 #endif // BUILDFLAG(ANDROID_JAVA_UI) 269 #endif // BUILDFLAG(ANDROID_JAVA_UI)
271 weak_ptr_factory_.GetWeakPtr()); 270 weak_ptr_factory_.GetWeakPtr());
272 } 271 }
273 272
274 scoped_refptr<autofill::AutofillWebDataService>
275 ChromeSyncClient::GetWebDataService() {
276 DCHECK_CURRENTLY_ON(BrowserThread::UI);
277 return WebDataServiceFactory::GetAutofillWebDataForProfile(
278 profile_, ServiceAccessType::EXPLICIT_ACCESS);
279 }
280
281 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { 273 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() {
282 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); 274 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_);
283 } 275 }
284 276
285 invalidation::InvalidationService* ChromeSyncClient::GetInvalidationService() { 277 invalidation::InvalidationService* ChromeSyncClient::GetInvalidationService() {
286 invalidation::ProfileInvalidationProvider* provider = 278 invalidation::ProfileInvalidationProvider* provider =
287 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile_); 279 invalidation::ProfileInvalidationProviderFactory::GetForProfile(profile_);
288 if (provider) 280 if (provider)
289 return provider->GetInvalidationService(); 281 return provider->GetInvalidationService();
290 return nullptr; 282 return nullptr;
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 case syncer::GROUP_HISTORY: { 439 case syncer::GROUP_HISTORY: {
448 history::HistoryService* history_service = GetHistoryService(); 440 history::HistoryService* history_service = GetHistoryService();
449 if (!history_service) 441 if (!history_service)
450 return nullptr; 442 return nullptr;
451 return new HistoryModelWorker( 443 return new HistoryModelWorker(
452 history_service->AsWeakPtr(), 444 history_service->AsWeakPtr(),
453 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), 445 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
454 observer); 446 observer);
455 } 447 }
456 case syncer::GROUP_PASSWORD: { 448 case syncer::GROUP_PASSWORD: {
457 scoped_refptr<password_manager::PasswordStore> password_store = 449 if (!password_store_.get())
458 GetPasswordStore();
459 if (!password_store.get())
460 return nullptr; 450 return nullptr;
461 return new PasswordModelWorker(password_store, observer); 451 return new PasswordModelWorker(password_store_, observer);
462 } 452 }
463 default: 453 default:
464 return nullptr; 454 return nullptr;
465 } 455 }
466 } 456 }
467 457
468 sync_driver::SyncApiComponentFactory* 458 sync_driver::SyncApiComponentFactory*
469 ChromeSyncClient::GetSyncApiComponentFactory() { 459 ChromeSyncClient::GetSyncApiComponentFactory() {
470 return component_factory_.get(); 460 return component_factory_.get();
471 } 461 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 sync_service->RegisterDataTypeController( 601 sync_service->RegisterDataTypeController(
612 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS, 602 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS,
613 error_callback, this, profile_)); 603 error_callback, this, profile_));
614 sync_service->RegisterDataTypeController( 604 sync_service->RegisterDataTypeController(
615 new SupervisedUserSyncDataTypeController( 605 new SupervisedUserSyncDataTypeController(
616 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); 606 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_));
617 #endif 607 #endif
618 } 608 }
619 609
620 } // namespace browser_sync 610 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/chrome_sync_client.h ('k') | chrome/browser/sync/profile_sync_service_autofill_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698