NaCl: Update revision in DEPS, r12770 -> r12773
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_components_factory_impl.cc
blob0a6bc5d45b024b2afd34867f7ec6caa2b33d6b0f
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "build/build_config.h"
7 #include "chrome/browser/about_flags.h"
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
9 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
12 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
13 #include "chrome/browser/extensions/extension_service.h"
14 #include "chrome/browser/extensions/extension_sync_service.h"
15 #include "chrome/browser/history/history_service.h"
16 #include "chrome/browser/history/history_service_factory.h"
17 #include "chrome/browser/pref_service_flags_storage.h"
18 #include "chrome/browser/prefs/pref_model_associator.h"
19 #include "chrome/browser/prefs/pref_service_syncable.h"
20 #include "chrome/browser/profiles/profile.h"
21 #include "chrome/browser/search_engines/template_url_service.h"
22 #include "chrome/browser/search_engines/template_url_service_factory.h"
23 #include "chrome/browser/signin/signin_manager.h"
24 #include "chrome/browser/signin/signin_manager_factory.h"
25 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
26 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
27 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
28 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
29 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
30 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
31 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
32 #include "chrome/browser/sync/glue/extension_data_type_controller.h"
33 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
34 #include "chrome/browser/sync/glue/generic_change_processor.h"
35 #include "chrome/browser/sync/glue/password_change_processor.h"
36 #include "chrome/browser/sync/glue/password_data_type_controller.h"
37 #include "chrome/browser/sync/glue/password_model_associator.h"
38 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
39 #include "chrome/browser/sync/glue/session_change_processor.h"
40 #include "chrome/browser/sync/glue/session_data_type_controller.h"
41 #include "chrome/browser/sync/glue/session_model_associator.h"
42 #include "chrome/browser/sync/glue/shared_change_processor.h"
43 #include "chrome/browser/sync/glue/sync_backend_host.h"
44 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
45 #include "chrome/browser/sync/glue/theme_data_type_controller.h"
46 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
47 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
48 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
49 #include "chrome/browser/sync/glue/ui_data_type_controller.h"
50 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
51 #include "chrome/browser/sync/profile_sync_service.h"
52 #include "chrome/browser/sync/profile_sync_service_factory.h"
53 #include "chrome/browser/sync/sessions2/session_data_type_controller2.h"
54 #include "chrome/browser/themes/theme_service.h"
55 #include "chrome/browser/themes/theme_service_factory.h"
56 #include "chrome/browser/themes/theme_syncable_service.h"
57 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
58 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
59 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
60 #include "chrome/browser/webdata/web_data_service_factory.h"
61 #include "chrome/common/chrome_switches.h"
62 #include "chrome/common/pref_names.h"
63 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h"
64 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
65 #include "components/dom_distiller/core/dom_distiller_service.h"
66 #include "components/sync_driver/data_type_manager_observer.h"
67 #include "components/sync_driver/proxy_data_type_controller.h"
68 #include "content/public/browser/browser_thread.h"
69 #include "extensions/browser/extension_system.h"
70 #include "sync/api/syncable_service.h"
72 #if defined(ENABLE_MANAGED_USERS)
73 #include "chrome/browser/managed_mode/managed_user_settings_service.h"
74 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
75 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
76 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
77 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
78 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
79 #endif
81 #if !defined(OS_ANDROID)
82 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
83 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
84 #endif
86 #if defined(ENABLE_SPELLCHECK)
87 #include "chrome/browser/spellchecker/spellcheck_factory.h"
88 #include "chrome/browser/spellchecker/spellcheck_service.h"
89 #endif
91 using browser_sync::AutofillDataTypeController;
92 using browser_sync::AutofillProfileDataTypeController;
93 using browser_sync::BookmarkChangeProcessor;
94 using browser_sync::BookmarkDataTypeController;
95 using browser_sync::BookmarkModelAssociator;
96 using browser_sync::ChromeReportUnrecoverableError;
97 using browser_sync::DataTypeController;
98 using browser_sync::DataTypeErrorHandler;
99 using browser_sync::DataTypeManager;
100 using browser_sync::DataTypeManagerImpl;
101 using browser_sync::DataTypeManagerObserver;
102 using browser_sync::ExtensionDataTypeController;
103 using browser_sync::ExtensionSettingDataTypeController;
104 using browser_sync::GenericChangeProcessor;
105 using browser_sync::PasswordChangeProcessor;
106 using browser_sync::PasswordDataTypeController;
107 using browser_sync::PasswordModelAssociator;
108 using browser_sync::ProxyDataTypeController;
109 using browser_sync::SearchEngineDataTypeController;
110 using browser_sync::SessionChangeProcessor;
111 using browser_sync::SessionDataTypeController;
112 using browser_sync::SessionDataTypeController2;
113 using browser_sync::SessionModelAssociator;
114 using browser_sync::SharedChangeProcessor;
115 using browser_sync::SyncBackendHost;
116 using browser_sync::ThemeDataTypeController;
117 using browser_sync::TypedUrlChangeProcessor;
118 using browser_sync::TypedUrlDataTypeController;
119 using browser_sync::TypedUrlModelAssociator;
120 using browser_sync::UIDataTypeController;
121 using content::BrowserThread;
123 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
124 Profile* profile, CommandLine* command_line)
125 : profile_(profile),
126 command_line_(command_line),
127 extension_system_(extensions::ExtensionSystem::Get(profile)),
128 web_data_service_(
129 WebDataServiceFactory::GetAutofillWebDataForProfile(
130 profile_, Profile::EXPLICIT_ACCESS)) {
133 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
136 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
137 ProfileSyncService* pss) {
138 RegisterCommonDataTypes(pss);
139 #if !defined(OS_ANDROID)
140 RegisterDesktopDataTypes(pss);
141 #endif
144 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
145 ProfileSyncService* pss) {
146 // Autofill sync is enabled by default. Register unless explicitly
147 // disabled.
148 if (!command_line_->HasSwitch(switches::kDisableSyncAutofill)) {
149 pss->RegisterDataTypeController(
150 new AutofillDataTypeController(this, profile_, pss));
153 // Autofill profile sync is enabled by default. Register unless explicitly
154 // disabled.
155 if (!command_line_->HasSwitch(switches::kDisableSyncAutofillProfile)) {
156 pss->RegisterDataTypeController(
157 new AutofillProfileDataTypeController(this, profile_, pss));
160 // Bookmark sync is enabled by default. Register unless explicitly
161 // disabled.
162 if (!command_line_->HasSwitch(switches::kDisableSyncBookmarks)) {
163 pss->RegisterDataTypeController(
164 new BookmarkDataTypeController(this, profile_, pss));
167 // TypedUrl sync is enabled by default. Register unless explicitly disabled,
168 // or if saving history is disabled.
169 if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
170 !command_line_->HasSwitch(switches::kDisableSyncTypedUrls)) {
171 pss->RegisterDataTypeController(
172 new TypedUrlDataTypeController(this, profile_, pss));
175 // Delete directive sync is enabled by default. Register unless full history
176 // sync is disabled.
177 if (!command_line_->HasSwitch(switches::kHistoryDisableFullHistorySync)) {
178 pss->RegisterDataTypeController(
179 new UIDataTypeController(
180 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
181 base::Bind(&ChromeReportUnrecoverableError),
182 syncer::HISTORY_DELETE_DIRECTIVES,
183 this,
184 profile_,
185 pss));
188 // Session sync is enabled by default. Register unless explicitly disabled.
189 if (!command_line_->HasSwitch(switches::kDisableSyncTabs)) {
190 pss->RegisterDataTypeController(new ProxyDataTypeController(
191 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
192 syncer::PROXY_TABS));
193 if (command_line_->HasSwitch(switches::kDisableSyncSessionsV2)) {
194 pss->RegisterDataTypeController(
195 new SessionDataTypeController(this, profile_, pss));
196 } else {
197 pss->RegisterDataTypeController(
198 new SessionDataTypeController2(this, profile_, pss));
202 // Favicon sync is enabled by default. Register unless explicitly disabled.
203 if (!command_line_->HasSwitch(switches::kDisableSyncFavicons)) {
204 pss->RegisterDataTypeController(
205 new UIDataTypeController(
206 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
207 base::Bind(&ChromeReportUnrecoverableError),
208 syncer::FAVICON_IMAGES,
209 this,
210 profile_,
211 pss));
212 pss->RegisterDataTypeController(
213 new UIDataTypeController(
214 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
215 base::Bind(&ChromeReportUnrecoverableError),
216 syncer::FAVICON_TRACKING,
217 this,
218 profile_,
219 pss));
222 // Password sync is enabled by default. Register unless explicitly
223 // disabled.
224 if (!command_line_->HasSwitch(switches::kDisableSyncPasswords)) {
225 pss->RegisterDataTypeController(
226 new PasswordDataTypeController(this, profile_, pss));
228 ExtensionService* extension_service = extension_system_->extension_service();
229 if (extension_service) {
230 if (IsBookmarksExtensionInstalled(
231 extension_service->extensions()->GetIDs())) {
232 OptInIntoBookmarksExperiment();
235 // Article sync is disabled by default. Register only if explicitly enabled.
236 if (IsEnableSyncArticlesSet()) {
237 pss->RegisterDataTypeController(
238 new UIDataTypeController(
239 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
240 base::Bind(&ChromeReportUnrecoverableError),
241 syncer::ARTICLES,
242 this,
243 profile_,
244 pss));
247 #if defined(ENABLE_MANAGED_USERS)
248 if (profile_->IsManaged()) {
249 pss->RegisterDataTypeController(
250 new UIDataTypeController(
251 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
252 base::Bind(&ChromeReportUnrecoverableError),
253 syncer::MANAGED_USER_SETTINGS,
254 this,
255 profile_,
256 pss));
257 } else {
258 pss->RegisterDataTypeController(
259 new UIDataTypeController(
260 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
261 base::Bind(&ChromeReportUnrecoverableError),
262 syncer::MANAGED_USERS,
263 this,
264 profile_,
265 pss));
267 pss->RegisterDataTypeController(
268 new UIDataTypeController(
269 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
270 base::Bind(&ChromeReportUnrecoverableError),
271 syncer::MANAGED_USER_SHARED_SETTINGS,
272 this,
273 profile_,
274 pss));
275 #endif
278 void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
279 ProfileSyncService* pss) {
280 // App sync is enabled by default. Register unless explicitly
281 // disabled.
282 if (!command_line_->HasSwitch(switches::kDisableSyncApps)) {
283 pss->RegisterDataTypeController(
284 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss));
287 // Extension sync is enabled by default. Register unless explicitly
288 // disabled.
289 if (!command_line_->HasSwitch(switches::kDisableSyncExtensions)) {
290 pss->RegisterDataTypeController(
291 new ExtensionDataTypeController(syncer::EXTENSIONS,
292 this, profile_, pss));
295 // Preference sync is enabled by default. Register unless explicitly
296 // disabled.
297 if (!command_line_->HasSwitch(switches::kDisableSyncPreferences)) {
298 pss->RegisterDataTypeController(
299 new UIDataTypeController(
300 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
301 base::Bind(&ChromeReportUnrecoverableError),
302 syncer::PREFERENCES,
303 this,
304 profile_,
305 pss));
309 if (!command_line_->HasSwitch(switches::kDisableSyncPriorityPreferences)) {
310 pss->RegisterDataTypeController(
311 new UIDataTypeController(
312 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
313 base::Bind(&ChromeReportUnrecoverableError),
314 syncer::PRIORITY_PREFERENCES,
315 this,
316 profile_,
317 pss));
320 #if defined(ENABLE_THEMES)
321 // Theme sync is enabled by default. Register unless explicitly disabled.
322 if (!command_line_->HasSwitch(switches::kDisableSyncThemes)) {
323 pss->RegisterDataTypeController(
324 new ThemeDataTypeController(this, profile_, pss));
326 #endif
328 // Search Engine sync is enabled by default. Register unless explicitly
329 // disabled.
330 if (!command_line_->HasSwitch(switches::kDisableSyncSearchEngines)) {
331 pss->RegisterDataTypeController(
332 new SearchEngineDataTypeController(this, profile_, pss));
335 // Extension setting sync is enabled by default. Register unless explicitly
336 // disabled.
337 if (!command_line_->HasSwitch(switches::kDisableSyncExtensionSettings)) {
338 pss->RegisterDataTypeController(
339 new ExtensionSettingDataTypeController(
340 syncer::EXTENSION_SETTINGS, this, profile_, pss));
343 // App setting sync is enabled by default. Register unless explicitly
344 // disabled.
345 if (!command_line_->HasSwitch(switches::kDisableSyncAppSettings)) {
346 pss->RegisterDataTypeController(
347 new ExtensionSettingDataTypeController(
348 syncer::APP_SETTINGS, this, profile_, pss));
351 #if defined(ENABLE_APP_LIST)
352 // App List sync is disabled by default. Register only if enabled.
353 if (command_line_->HasSwitch(switches::kEnableSyncAppList)) {
354 pss->RegisterDataTypeController(
355 new UIDataTypeController(
356 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
357 base::Bind(&ChromeReportUnrecoverableError),
358 syncer::APP_LIST,
359 this,
360 profile_,
361 pss));
363 #endif
365 // Synced Notifications are enabled by default.
366 pss->RegisterDataTypeController(
367 new UIDataTypeController(
368 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
369 base::Bind(&ChromeReportUnrecoverableError),
370 syncer::SYNCED_NOTIFICATIONS,
371 this,
372 profile_,
373 pss));
375 // TODO(petewil): Enable the data type controller once we have a handler.
377 #if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS)
378 // Dictionary sync is enabled by default.
379 if (!command_line_->HasSwitch(switches::kDisableSyncDictionary)) {
380 pss->RegisterDataTypeController(
381 new UIDataTypeController(
382 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
383 base::Bind(&ChromeReportUnrecoverableError),
384 syncer::DICTIONARY,
385 this,
386 profile_,
387 pss));
389 #endif
392 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
393 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
394 debug_info_listener,
395 const DataTypeController::TypeMap* controllers,
396 const browser_sync::DataTypeEncryptionHandler* encryption_handler,
397 SyncBackendHost* backend,
398 DataTypeManagerObserver* observer,
399 browser_sync::FailedDataTypesHandler* failed_data_types_handler) {
400 return new DataTypeManagerImpl(debug_info_listener,
401 controllers,
402 encryption_handler,
403 backend,
404 observer,
405 failed_data_types_handler);
408 browser_sync::SyncBackendHost*
409 ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost(
410 const std::string& name,
411 Profile* profile,
412 const base::WeakPtr<browser_sync::SyncPrefs>& sync_prefs) {
413 return new browser_sync::SyncBackendHostImpl(name, profile, sync_prefs);
416 browser_sync::GenericChangeProcessor*
417 ProfileSyncComponentsFactoryImpl::CreateGenericChangeProcessor(
418 ProfileSyncService* profile_sync_service,
419 browser_sync::DataTypeErrorHandler* error_handler,
420 const base::WeakPtr<syncer::SyncableService>& local_service,
421 const base::WeakPtr<syncer::SyncMergeResult>& merge_result) {
422 syncer::UserShare* user_share = profile_sync_service->GetUserShare();
423 return new GenericChangeProcessor(error_handler,
424 local_service,
425 merge_result,
426 user_share);
429 browser_sync::SharedChangeProcessor* ProfileSyncComponentsFactoryImpl::
430 CreateSharedChangeProcessor() {
431 return new SharedChangeProcessor();
434 base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
435 GetSyncableServiceForType(syncer::ModelType type) {
436 if (!profile_) { // For tests.
437 return base::WeakPtr<syncer::SyncableService>();
439 switch (type) {
440 case syncer::PREFERENCES:
441 return PrefServiceSyncable::FromProfile(
442 profile_)->GetSyncableService(syncer::PREFERENCES)->AsWeakPtr();
443 case syncer::PRIORITY_PREFERENCES:
444 return PrefServiceSyncable::FromProfile(profile_)->GetSyncableService(
445 syncer::PRIORITY_PREFERENCES)->AsWeakPtr();
446 case syncer::AUTOFILL:
447 case syncer::AUTOFILL_PROFILE: {
448 if (!web_data_service_.get())
449 return base::WeakPtr<syncer::SyncableService>();
450 if (type == syncer::AUTOFILL) {
451 return AutocompleteSyncableService::FromWebDataService(
452 web_data_service_.get())->AsWeakPtr();
453 } else {
454 return autofill::AutofillProfileSyncableService::FromWebDataService(
455 web_data_service_.get())->AsWeakPtr();
458 case syncer::APPS:
459 case syncer::EXTENSIONS:
460 return ExtensionSyncService::Get(profile_)->AsWeakPtr();
461 case syncer::SEARCH_ENGINES:
462 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
463 case syncer::APP_SETTINGS:
464 case syncer::EXTENSION_SETTINGS:
465 return extension_system_->extension_service()->settings_frontend()->
466 GetBackendForSync(type)->AsWeakPtr();
467 #if defined(ENABLE_APP_LIST)
468 case syncer::APP_LIST:
469 return app_list::AppListSyncableServiceFactory::GetForProfile(profile_)->
470 AsWeakPtr();
471 #endif
472 #if defined(ENABLE_THEMES)
473 case syncer::THEMES:
474 return ThemeServiceFactory::GetForProfile(profile_)->
475 GetThemeSyncableService()->AsWeakPtr();
476 #endif
477 case syncer::HISTORY_DELETE_DIRECTIVES: {
478 HistoryService* history =
479 HistoryServiceFactory::GetForProfile(
480 profile_, Profile::EXPLICIT_ACCESS);
481 return history ? history->AsWeakPtr() : base::WeakPtr<HistoryService>();
483 #if !defined(OS_ANDROID)
484 case syncer::SYNCED_NOTIFICATIONS: {
485 notifier::ChromeNotifierService* notifier_service =
486 notifier::ChromeNotifierServiceFactory::GetForProfile(
487 profile_, Profile::EXPLICIT_ACCESS);
488 return notifier_service ? notifier_service->AsWeakPtr()
489 : base::WeakPtr<syncer::SyncableService>();
491 #endif
492 #if defined(ENABLE_SPELLCHECK)
493 case syncer::DICTIONARY:
494 return SpellcheckServiceFactory::GetForContext(profile_)->
495 GetCustomDictionary()->AsWeakPtr();
496 #endif
497 case syncer::FAVICON_IMAGES:
498 case syncer::FAVICON_TRACKING: {
499 browser_sync::FaviconCache* favicons =
500 ProfileSyncServiceFactory::GetForProfile(profile_)->
501 GetFaviconCache();
502 return favicons ? favicons->AsWeakPtr()
503 : base::WeakPtr<syncer::SyncableService>();
505 #if defined(ENABLE_MANAGED_USERS)
506 case syncer::MANAGED_USER_SETTINGS:
507 return ManagedUserSettingsServiceFactory::GetForProfile(profile_)->
508 AsWeakPtr();
509 case syncer::MANAGED_USERS:
510 return ManagedUserSyncServiceFactory::GetForProfile(profile_)->
511 AsWeakPtr();
512 case syncer::MANAGED_USER_SHARED_SETTINGS:
513 return ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
514 profile_)->AsWeakPtr();
515 #endif
516 case syncer::ARTICLES: {
517 dom_distiller::DomDistillerService* service =
518 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
519 profile_);
520 if (service)
521 return service->GetSyncableService()->AsWeakPtr();
522 return base::WeakPtr<syncer::SyncableService>();
524 case syncer::SESSIONS: {
525 DCHECK(!command_line_->HasSwitch(switches::kDisableSyncSessionsV2));
526 return ProfileSyncServiceFactory::GetForProfile(profile_)->
527 GetSessionsSyncableService()->AsWeakPtr();
529 default:
530 // The following datatypes still need to be transitioned to the
531 // syncer::SyncableService API:
532 // Bookmarks
533 // Passwords
534 // Typed URLs
535 NOTREACHED();
536 return base::WeakPtr<syncer::SyncableService>();
540 ProfileSyncComponentsFactory::SyncComponents
541 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
542 ProfileSyncService* profile_sync_service,
543 DataTypeErrorHandler* error_handler) {
544 BookmarkModel* bookmark_model =
545 BookmarkModelFactory::GetForProfile(profile_sync_service->profile());
546 syncer::UserShare* user_share = profile_sync_service->GetUserShare();
547 // TODO(akalin): We may want to propagate this switch up eventually.
548 #if defined(OS_ANDROID)
549 const bool kExpectMobileBookmarksFolder = true;
550 #else
551 const bool kExpectMobileBookmarksFolder = false;
552 #endif
553 BookmarkModelAssociator* model_associator =
554 new BookmarkModelAssociator(bookmark_model,
555 profile_sync_service->profile(),
556 user_share,
557 error_handler,
558 kExpectMobileBookmarksFolder);
559 BookmarkChangeProcessor* change_processor =
560 new BookmarkChangeProcessor(model_associator,
561 error_handler);
562 return SyncComponents(model_associator, change_processor);
565 ProfileSyncComponentsFactory::SyncComponents
566 ProfileSyncComponentsFactoryImpl::CreatePasswordSyncComponents(
567 ProfileSyncService* profile_sync_service,
568 PasswordStore* password_store,
569 DataTypeErrorHandler* error_handler) {
570 PasswordModelAssociator* model_associator =
571 new PasswordModelAssociator(profile_sync_service,
572 password_store,
573 error_handler);
574 PasswordChangeProcessor* change_processor =
575 new PasswordChangeProcessor(model_associator,
576 password_store,
577 error_handler);
578 return SyncComponents(model_associator, change_processor);
581 ProfileSyncComponentsFactory::SyncComponents
582 ProfileSyncComponentsFactoryImpl::CreateTypedUrlSyncComponents(
583 ProfileSyncService* profile_sync_service,
584 history::HistoryBackend* history_backend,
585 browser_sync::DataTypeErrorHandler* error_handler) {
586 TypedUrlModelAssociator* model_associator =
587 new TypedUrlModelAssociator(profile_sync_service,
588 history_backend,
589 error_handler);
590 TypedUrlChangeProcessor* change_processor =
591 new TypedUrlChangeProcessor(profile_,
592 model_associator,
593 history_backend,
594 error_handler);
595 return SyncComponents(model_associator, change_processor);
598 ProfileSyncComponentsFactory::SyncComponents
599 ProfileSyncComponentsFactoryImpl::CreateSessionSyncComponents(
600 ProfileSyncService* profile_sync_service,
601 DataTypeErrorHandler* error_handler) {
602 SessionModelAssociator* model_associator =
603 new SessionModelAssociator(profile_sync_service, error_handler);
604 SessionChangeProcessor* change_processor =
605 new SessionChangeProcessor(error_handler, model_associator);
606 return SyncComponents(model_associator, change_processor);