Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / browser / sync / profile_sync_components_factory_impl.cc
blob4ba88f48f082ee64f7b2c368b161e3b0a1bffcc2
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/bookmarks/bookmark_model_factory.h"
8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h"
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
10 #include "chrome/browser/history/history_service.h"
11 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/password_manager/password_store_factory.h"
13 #include "chrome/browser/pref_service_flags_storage.h"
14 #include "chrome/browser/prefs/pref_model_associator.h"
15 #include "chrome/browser/prefs/pref_service_syncable.h"
16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/search_engines/template_url_service.h"
18 #include "chrome/browser/search_engines/template_url_service_factory.h"
19 #include "chrome/browser/signin/signin_manager_factory.h"
20 #include "chrome/browser/sync/glue/autofill_data_type_controller.h"
21 #include "chrome/browser/sync/glue/autofill_profile_data_type_controller.h"
22 #include "chrome/browser/sync/glue/bookmark_change_processor.h"
23 #include "chrome/browser/sync/glue/bookmark_data_type_controller.h"
24 #include "chrome/browser/sync/glue/bookmark_model_associator.h"
25 #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h"
26 #include "chrome/browser/sync/glue/data_type_manager_impl.h"
27 #include "chrome/browser/sync/glue/extension_data_type_controller.h"
28 #include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
29 #include "chrome/browser/sync/glue/password_data_type_controller.h"
30 #include "chrome/browser/sync/glue/search_engine_data_type_controller.h"
31 #include "chrome/browser/sync/glue/shared_change_processor.h"
32 #include "chrome/browser/sync/glue/sync_backend_host.h"
33 #include "chrome/browser/sync/glue/sync_backend_host_impl.h"
34 #include "chrome/browser/sync/glue/theme_data_type_controller.h"
35 #include "chrome/browser/sync/glue/typed_url_change_processor.h"
36 #include "chrome/browser/sync/glue/typed_url_data_type_controller.h"
37 #include "chrome/browser/sync/glue/typed_url_model_associator.h"
38 #include "chrome/browser/sync/glue/ui_data_type_controller.h"
39 #include "chrome/browser/sync/profile_sync_components_factory_impl.h"
40 #include "chrome/browser/sync/profile_sync_service.h"
41 #include "chrome/browser/sync/profile_sync_service_factory.h"
42 #include "chrome/browser/sync/sessions/session_data_type_controller.h"
43 #include "chrome/browser/themes/theme_service.h"
44 #include "chrome/browser/themes/theme_service_factory.h"
45 #include "chrome/browser/themes/theme_syncable_service.h"
46 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
47 #include "chrome/browser/webdata/web_data_service_factory.h"
48 #include "chrome/common/chrome_switches.h"
49 #include "chrome/common/chrome_version_info.h"
50 #include "chrome/common/pref_names.h"
51 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h"
52 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
53 #include "components/dom_distiller/core/dom_distiller_service.h"
54 #include "components/password_manager/core/browser/password_store.h"
55 #include "components/signin/core/browser/signin_manager.h"
56 #include "components/sync_driver/data_type_manager_observer.h"
57 #include "components/sync_driver/generic_change_processor.h"
58 #include "components/sync_driver/proxy_data_type_controller.h"
59 #include "content/public/browser/browser_thread.h"
60 #include "extensions/browser/extension_system.h"
61 #include "sync/api/attachments/attachment_service.h"
62 #include "sync/api/attachments/fake_attachment_service.h"
63 #include "sync/api/attachments/fake_attachment_store.h"
64 #include "sync/api/syncable_service.h"
66 #if defined(ENABLE_EXTENSIONS)
67 #include "chrome/browser/extensions/api/storage/settings_sync_util.h"
68 #include "chrome/browser/extensions/extension_sync_service.h"
69 #endif
71 #if defined(ENABLE_APP_LIST)
72 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
73 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
74 #include "ui/app_list/app_list_switches.h"
75 #endif
77 #if defined(ENABLE_MANAGED_USERS)
78 #include "chrome/browser/managed_mode/managed_user_settings_service.h"
79 #include "chrome/browser/managed_mode/managed_user_settings_service_factory.h"
80 #include "chrome/browser/managed_mode/managed_user_shared_settings_service.h"
81 #include "chrome/browser/managed_mode/managed_user_shared_settings_service_factory.h"
82 #include "chrome/browser/managed_mode/managed_user_sync_service.h"
83 #include "chrome/browser/managed_mode/managed_user_sync_service_factory.h"
84 #endif
86 #if !defined(OS_ANDROID)
87 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h"
88 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service_factory.h"
89 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service.h"
90 #include "chrome/browser/notifications/sync_notifier/synced_notification_app_info_service_factory.h"
91 #endif
93 #if defined(ENABLE_SPELLCHECK)
94 #include "chrome/browser/spellchecker/spellcheck_factory.h"
95 #include "chrome/browser/spellchecker/spellcheck_service.h"
96 #endif
98 using browser_sync::AutofillDataTypeController;
99 using browser_sync::AutofillProfileDataTypeController;
100 using browser_sync::BookmarkChangeProcessor;
101 using browser_sync::BookmarkDataTypeController;
102 using browser_sync::BookmarkModelAssociator;
103 using browser_sync::ChromeReportUnrecoverableError;
104 using browser_sync::DataTypeController;
105 using browser_sync::DataTypeErrorHandler;
106 using browser_sync::DataTypeManager;
107 using browser_sync::DataTypeManagerImpl;
108 using browser_sync::DataTypeManagerObserver;
109 using browser_sync::ExtensionDataTypeController;
110 using browser_sync::ExtensionSettingDataTypeController;
111 using browser_sync::PasswordDataTypeController;
112 using browser_sync::ProxyDataTypeController;
113 using browser_sync::SearchEngineDataTypeController;
114 using browser_sync::SessionDataTypeController;
115 using browser_sync::SharedChangeProcessor;
116 using browser_sync::SyncBackendHost;
117 using browser_sync::ThemeDataTypeController;
118 using browser_sync::TypedUrlChangeProcessor;
119 using browser_sync::TypedUrlDataTypeController;
120 using browser_sync::TypedUrlModelAssociator;
121 using browser_sync::UIDataTypeController;
122 using content::BrowserThread;
124 namespace {
126 syncer::ModelTypeSet GetDisabledTypesFromCommandLine(
127 CommandLine* command_line) {
128 syncer::ModelTypeSet disabled_types;
129 std::string disabled_types_str =
130 command_line->GetSwitchValueASCII(switches::kDisableSyncTypes);
131 disabled_types = syncer::ModelTypeSetFromString(disabled_types_str);
132 return disabled_types;
135 } // namespace
137 ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
138 Profile* profile, CommandLine* command_line)
139 : profile_(profile),
140 command_line_(command_line),
141 extension_system_(extensions::ExtensionSystem::Get(profile)),
142 web_data_service_(
143 WebDataServiceFactory::GetAutofillWebDataForProfile(
144 profile_, Profile::EXPLICIT_ACCESS)) {
147 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {
150 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes(
151 ProfileSyncService* pss) {
152 syncer::ModelTypeSet disabled_types =
153 GetDisabledTypesFromCommandLine(command_line_);
154 // TODO(zea): pass an enabled_types set for types that are off by default.
155 RegisterCommonDataTypes(disabled_types, pss);
156 #if !defined(OS_ANDROID)
157 RegisterDesktopDataTypes(disabled_types, pss);
158 #endif
161 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes(
162 syncer::ModelTypeSet disabled_types,
163 ProfileSyncService* pss) {
164 // Autofill sync is enabled by default. Register unless explicitly
165 // disabled.
166 if (!disabled_types.Has(syncer::AUTOFILL)) {
167 pss->RegisterDataTypeController(
168 new AutofillDataTypeController(this, profile_, pss));
171 // Autofill profile sync is enabled by default. Register unless explicitly
172 // disabled.
173 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) {
174 pss->RegisterDataTypeController(
175 new AutofillProfileDataTypeController(this, profile_, pss));
178 // Bookmark sync is enabled by default. Register unless explicitly
179 // disabled.
180 if (!disabled_types.Has(syncer::BOOKMARKS)) {
181 pss->RegisterDataTypeController(
182 new BookmarkDataTypeController(this, profile_, pss));
185 // TypedUrl sync is enabled by default. Register unless explicitly disabled,
186 // or if saving history is disabled.
187 if (!profile_->GetPrefs()->GetBoolean(prefs::kSavingBrowserHistoryDisabled) &&
188 !disabled_types.Has(syncer::TYPED_URLS)) {
189 pss->RegisterDataTypeController(
190 new TypedUrlDataTypeController(this, profile_, pss));
193 // Delete directive sync is enabled by default. Register unless full history
194 // sync is disabled.
195 if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES)) {
196 pss->RegisterDataTypeController(
197 new UIDataTypeController(
198 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
199 base::Bind(&ChromeReportUnrecoverableError),
200 syncer::HISTORY_DELETE_DIRECTIVES,
201 this,
202 profile_,
203 pss));
206 // Session sync is enabled by default. Register unless explicitly disabled.
207 if (!disabled_types.Has(syncer::PROXY_TABS)) {
208 pss->RegisterDataTypeController(new ProxyDataTypeController(
209 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
210 syncer::PROXY_TABS));
211 pss->RegisterDataTypeController(
212 new SessionDataTypeController(this, profile_, pss));
215 // Favicon sync is enabled by default. Register unless explicitly disabled.
216 if (!disabled_types.Has(syncer::FAVICON_IMAGES) &&
217 !disabled_types.Has(syncer::FAVICON_TRACKING)) {
218 pss->RegisterDataTypeController(
219 new UIDataTypeController(
220 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
221 base::Bind(&ChromeReportUnrecoverableError),
222 syncer::FAVICON_IMAGES,
223 this,
224 profile_,
225 pss));
226 pss->RegisterDataTypeController(
227 new UIDataTypeController(
228 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
229 base::Bind(&ChromeReportUnrecoverableError),
230 syncer::FAVICON_TRACKING,
231 this,
232 profile_,
233 pss));
236 // Password sync is enabled by default. Register unless explicitly
237 // disabled.
238 if (!disabled_types.Has(syncer::PASSWORDS)) {
239 pss->RegisterDataTypeController(
240 new PasswordDataTypeController(this, profile_, pss));
243 // Article sync is disabled by default. Register only if explicitly enabled.
244 if (IsEnableSyncArticlesSet()) {
245 pss->RegisterDataTypeController(
246 new UIDataTypeController(
247 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
248 base::Bind(&ChromeReportUnrecoverableError),
249 syncer::ARTICLES,
250 this,
251 profile_,
252 pss));
255 #if defined(ENABLE_MANAGED_USERS)
256 if (profile_->IsManaged()) {
257 pss->RegisterDataTypeController(
258 new UIDataTypeController(
259 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
260 base::Bind(&ChromeReportUnrecoverableError),
261 syncer::MANAGED_USER_SETTINGS,
262 this,
263 profile_,
264 pss));
265 } else {
266 pss->RegisterDataTypeController(
267 new UIDataTypeController(
268 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
269 base::Bind(&ChromeReportUnrecoverableError),
270 syncer::MANAGED_USERS,
271 this,
272 profile_,
273 pss));
275 pss->RegisterDataTypeController(
276 new UIDataTypeController(
277 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
278 base::Bind(&ChromeReportUnrecoverableError),
279 syncer::MANAGED_USER_SHARED_SETTINGS,
280 this,
281 profile_,
282 pss));
283 #endif
286 void ProfileSyncComponentsFactoryImpl::RegisterDesktopDataTypes(
287 syncer::ModelTypeSet disabled_types,
288 ProfileSyncService* pss) {
289 // App sync is enabled by default. Register unless explicitly
290 // disabled.
291 if (!disabled_types.Has(syncer::APPS)) {
292 pss->RegisterDataTypeController(
293 new ExtensionDataTypeController(syncer::APPS, this, profile_, pss));
296 // Extension sync is enabled by default. Register unless explicitly
297 // disabled.
298 if (!disabled_types.Has(syncer::EXTENSIONS)) {
299 pss->RegisterDataTypeController(
300 new ExtensionDataTypeController(syncer::EXTENSIONS,
301 this, profile_, pss));
304 // Preference sync is enabled by default. Register unless explicitly
305 // disabled.
306 if (!disabled_types.Has(syncer::PREFERENCES)) {
307 pss->RegisterDataTypeController(
308 new UIDataTypeController(
309 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
310 base::Bind(&ChromeReportUnrecoverableError),
311 syncer::PREFERENCES,
312 this,
313 profile_,
314 pss));
318 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
319 pss->RegisterDataTypeController(
320 new UIDataTypeController(
321 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
322 base::Bind(&ChromeReportUnrecoverableError),
323 syncer::PRIORITY_PREFERENCES,
324 this,
325 profile_,
326 pss));
329 #if defined(ENABLE_THEMES)
330 // Theme sync is enabled by default. Register unless explicitly disabled.
331 if (!disabled_types.Has(syncer::THEMES)) {
332 pss->RegisterDataTypeController(
333 new ThemeDataTypeController(this, profile_, pss));
335 #endif
337 // Search Engine sync is enabled by default. Register unless explicitly
338 // disabled.
339 if (!disabled_types.Has(syncer::SEARCH_ENGINES)) {
340 pss->RegisterDataTypeController(
341 new SearchEngineDataTypeController(this, profile_, pss));
344 // Extension setting sync is enabled by default. Register unless explicitly
345 // disabled.
346 if (!disabled_types.Has(syncer::EXTENSION_SETTINGS)) {
347 pss->RegisterDataTypeController(
348 new ExtensionSettingDataTypeController(
349 syncer::EXTENSION_SETTINGS, this, profile_, pss));
352 // App setting sync is enabled by default. Register unless explicitly
353 // disabled.
354 if (!disabled_types.Has(syncer::APP_SETTINGS)) {
355 pss->RegisterDataTypeController(
356 new ExtensionSettingDataTypeController(
357 syncer::APP_SETTINGS, this, profile_, pss));
360 #if defined(ENABLE_APP_LIST)
361 if (app_list::switches::IsAppListSyncEnabled()) {
362 pss->RegisterDataTypeController(
363 new UIDataTypeController(
364 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
365 base::Bind(&ChromeReportUnrecoverableError),
366 syncer::APP_LIST,
367 this,
368 profile_,
369 pss));
371 #endif
373 // Synced Notifications are enabled by default.
374 if (!disabled_types.Has(syncer::SYNCED_NOTIFICATIONS)) {
375 pss->RegisterDataTypeController(
376 new UIDataTypeController(
377 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
378 base::Bind(&ChromeReportUnrecoverableError),
379 syncer::SYNCED_NOTIFICATIONS,
380 this,
381 profile_,
382 pss));
384 // Synced Notification App Infos are enabled by default on Dev and Canary
385 // only.
386 // TODO(petewil): Enable on stable when the feature is ready.
387 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel();
388 if (channel == chrome::VersionInfo::CHANNEL_UNKNOWN ||
389 channel == chrome::VersionInfo::CHANNEL_DEV ||
390 channel == chrome::VersionInfo::CHANNEL_CANARY) {
391 pss->RegisterDataTypeController(new UIDataTypeController(
392 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
393 base::Bind(&ChromeReportUnrecoverableError),
394 syncer::SYNCED_NOTIFICATION_APP_INFO,
395 this,
396 profile_,
397 pss));
401 #if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS)
402 // Dictionary sync is enabled by default.
403 if (!disabled_types.Has(syncer::DICTIONARY)) {
404 pss->RegisterDataTypeController(
405 new UIDataTypeController(
406 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
407 base::Bind(&ChromeReportUnrecoverableError),
408 syncer::DICTIONARY,
409 this,
410 profile_,
411 pss));
413 #endif
416 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
417 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
418 debug_info_listener,
419 const DataTypeController::TypeMap* controllers,
420 const browser_sync::DataTypeEncryptionHandler* encryption_handler,
421 SyncBackendHost* backend,
422 DataTypeManagerObserver* observer,
423 browser_sync::FailedDataTypesHandler* failed_data_types_handler) {
424 return new DataTypeManagerImpl(debug_info_listener,
425 controllers,
426 encryption_handler,
427 backend,
428 observer,
429 failed_data_types_handler);
432 browser_sync::SyncBackendHost*
433 ProfileSyncComponentsFactoryImpl::CreateSyncBackendHost(
434 const std::string& name,
435 Profile* profile,
436 const base::WeakPtr<sync_driver::SyncPrefs>& sync_prefs) {
437 return new browser_sync::SyncBackendHostImpl(name, profile, sync_prefs);
440 base::WeakPtr<syncer::SyncableService> ProfileSyncComponentsFactoryImpl::
441 GetSyncableServiceForType(syncer::ModelType type) {
442 if (!profile_) { // For tests.
443 return base::WeakPtr<syncer::SyncableService>();
445 switch (type) {
446 case syncer::PREFERENCES:
447 return PrefServiceSyncable::FromProfile(
448 profile_)->GetSyncableService(syncer::PREFERENCES)->AsWeakPtr();
449 case syncer::PRIORITY_PREFERENCES:
450 return PrefServiceSyncable::FromProfile(profile_)->GetSyncableService(
451 syncer::PRIORITY_PREFERENCES)->AsWeakPtr();
452 case syncer::AUTOFILL:
453 case syncer::AUTOFILL_PROFILE: {
454 if (!web_data_service_.get())
455 return base::WeakPtr<syncer::SyncableService>();
456 if (type == syncer::AUTOFILL) {
457 return AutocompleteSyncableService::FromWebDataService(
458 web_data_service_.get())->AsWeakPtr();
459 } else {
460 return autofill::AutofillProfileSyncableService::FromWebDataService(
461 web_data_service_.get())->AsWeakPtr();
464 case syncer::SEARCH_ENGINES:
465 return TemplateURLServiceFactory::GetForProfile(profile_)->AsWeakPtr();
466 #if defined(ENABLE_EXTENSIONS)
467 case syncer::APPS:
468 case syncer::EXTENSIONS:
469 return ExtensionSyncService::Get(profile_)->AsWeakPtr();
470 case syncer::APP_SETTINGS:
471 case syncer::EXTENSION_SETTINGS:
472 return extensions::settings_sync_util::GetSyncableService(profile_, type)
473 ->AsWeakPtr();
474 #endif
475 #if defined(ENABLE_APP_LIST)
476 case syncer::APP_LIST:
477 return app_list::AppListSyncableServiceFactory::GetForProfile(profile_)->
478 AsWeakPtr();
479 #endif
480 #if defined(ENABLE_THEMES)
481 case syncer::THEMES:
482 return ThemeServiceFactory::GetForProfile(profile_)->
483 GetThemeSyncableService()->AsWeakPtr();
484 #endif
485 case syncer::HISTORY_DELETE_DIRECTIVES: {
486 HistoryService* history =
487 HistoryServiceFactory::GetForProfile(
488 profile_, Profile::EXPLICIT_ACCESS);
489 return history ? history->AsWeakPtr() : base::WeakPtr<HistoryService>();
491 #if !defined(OS_ANDROID)
492 case syncer::SYNCED_NOTIFICATIONS: {
493 notifier::ChromeNotifierService* notifier_service =
494 notifier::ChromeNotifierServiceFactory::GetForProfile(
495 profile_, Profile::EXPLICIT_ACCESS);
496 return notifier_service ? notifier_service->AsWeakPtr()
497 : base::WeakPtr<syncer::SyncableService>();
500 case syncer::SYNCED_NOTIFICATION_APP_INFO: {
501 notifier::SyncedNotificationAppInfoService* app_info =
502 notifier::SyncedNotificationAppInfoServiceFactory::GetForProfile(
503 profile_, Profile::EXPLICIT_ACCESS);
504 return app_info ? app_info->AsWeakPtr()
505 : base::WeakPtr<syncer::SyncableService>();
507 #endif
508 #if defined(ENABLE_SPELLCHECK)
509 case syncer::DICTIONARY:
510 return SpellcheckServiceFactory::GetForContext(profile_)->
511 GetCustomDictionary()->AsWeakPtr();
512 #endif
513 case syncer::FAVICON_IMAGES:
514 case syncer::FAVICON_TRACKING: {
515 browser_sync::FaviconCache* favicons =
516 ProfileSyncServiceFactory::GetForProfile(profile_)->
517 GetFaviconCache();
518 return favicons ? favicons->AsWeakPtr()
519 : base::WeakPtr<syncer::SyncableService>();
521 #if defined(ENABLE_MANAGED_USERS)
522 case syncer::MANAGED_USER_SETTINGS:
523 return ManagedUserSettingsServiceFactory::GetForProfile(profile_)->
524 AsWeakPtr();
525 case syncer::MANAGED_USERS:
526 return ManagedUserSyncServiceFactory::GetForProfile(profile_)->
527 AsWeakPtr();
528 case syncer::MANAGED_USER_SHARED_SETTINGS:
529 return ManagedUserSharedSettingsServiceFactory::GetForBrowserContext(
530 profile_)->AsWeakPtr();
531 #endif
532 case syncer::ARTICLES: {
533 dom_distiller::DomDistillerService* service =
534 dom_distiller::DomDistillerServiceFactory::GetForBrowserContext(
535 profile_);
536 if (service)
537 return service->GetSyncableService()->AsWeakPtr();
538 return base::WeakPtr<syncer::SyncableService>();
540 case syncer::SESSIONS: {
541 return ProfileSyncServiceFactory::GetForProfile(profile_)->
542 GetSessionsSyncableService()->AsWeakPtr();
544 case syncer::PASSWORDS: {
545 #if defined(PASSWORD_MANAGER_ENABLE_SYNC)
546 password_manager::PasswordStore* password_store =
547 PasswordStoreFactory::GetForProfile(profile_,
548 Profile::EXPLICIT_ACCESS);
549 return password_store ? password_store->GetPasswordSyncableService()
550 : base::WeakPtr<syncer::SyncableService>();
551 #else
552 return base::WeakPtr<syncer::SyncableService>();
553 #endif
555 default:
556 // The following datatypes still need to be transitioned to the
557 // syncer::SyncableService API:
558 // Bookmarks
559 // Typed URLs
560 NOTREACHED();
561 return base::WeakPtr<syncer::SyncableService>();
565 scoped_ptr<syncer::AttachmentStore>
566 ProfileSyncComponentsFactoryImpl::CreateCustomAttachmentStoreForType(
567 syncer::ModelType type) {
568 scoped_ptr<syncer::AttachmentStore> store(
569 new syncer::FakeAttachmentStore(
570 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
571 return store.Pass();
574 ProfileSyncComponentsFactory::SyncComponents
575 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
576 ProfileSyncService* profile_sync_service,
577 DataTypeErrorHandler* error_handler) {
578 BookmarkModel* bookmark_model =
579 BookmarkModelFactory::GetForProfile(profile_sync_service->profile());
580 syncer::UserShare* user_share = profile_sync_service->GetUserShare();
581 // TODO(akalin): We may want to propagate this switch up eventually.
582 #if defined(OS_ANDROID)
583 const bool kExpectMobileBookmarksFolder = true;
584 #else
585 const bool kExpectMobileBookmarksFolder = false;
586 #endif
587 BookmarkModelAssociator* model_associator =
588 new BookmarkModelAssociator(bookmark_model,
589 profile_sync_service->profile(),
590 user_share,
591 error_handler,
592 kExpectMobileBookmarksFolder);
593 BookmarkChangeProcessor* change_processor =
594 new BookmarkChangeProcessor(profile_sync_service->profile(),
595 model_associator,
596 error_handler);
597 return SyncComponents(model_associator, change_processor);
600 ProfileSyncComponentsFactory::SyncComponents
601 ProfileSyncComponentsFactoryImpl::CreateTypedUrlSyncComponents(
602 ProfileSyncService* profile_sync_service,
603 history::HistoryBackend* history_backend,
604 browser_sync::DataTypeErrorHandler* error_handler) {
605 TypedUrlModelAssociator* model_associator =
606 new TypedUrlModelAssociator(profile_sync_service,
607 history_backend,
608 error_handler);
609 TypedUrlChangeProcessor* change_processor =
610 new TypedUrlChangeProcessor(profile_,
611 model_associator,
612 history_backend,
613 error_handler);
614 return SyncComponents(model_associator, change_processor);