Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/browser/autofill/personal_data_manager_factory.h" | 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 10 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
| 11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 11 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 12 #include "chrome/browser/favicon/favicon_service_factory.h" | 12 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
| 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 14 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
| 15 #include "chrome/browser/password_manager/password_store_factory.h" | 15 #include "chrome/browser/password_manager/password_store_factory.h" |
| 16 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 16 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/search_engines/template_url_service_factory.h" | 18 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 19 #include "chrome/browser/sync/glue/sync_start_util.h" | 19 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 20 #include "chrome/browser/sync/glue/theme_data_type_controller.h" | |
| 20 #include "chrome/browser/sync/profile_sync_service_factory.h" | 21 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 21 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 22 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
| 22 #include "chrome/browser/themes/theme_service.h" | 23 #include "chrome/browser/themes/theme_service.h" |
| 23 #include "chrome/browser/themes/theme_service_factory.h" | 24 #include "chrome/browser/themes/theme_service_factory.h" |
| 24 #include "chrome/browser/themes/theme_syncable_service.h" | 25 #include "chrome/browser/themes/theme_syncable_service.h" |
| 25 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" | 26 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
| 26 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 27 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 27 #include "chrome/browser/web_data_service_factory.h" | 28 #include "chrome/browser/web_data_service_factory.h" |
| 29 #include "chrome/common/channel_info.h" | |
| 28 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 29 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h" | 31 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service .h" |
| 30 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" | 32 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser vice.h" |
| 31 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h" | 33 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync able_service.h" |
| 32 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h" | 34 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv ice.h" |
| 33 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 35 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 34 #include "components/browser_sync/browser/profile_sync_service.h" | 36 #include "components/browser_sync/browser/profile_sync_service.h" |
| 35 #include "components/dom_distiller/core/dom_distiller_service.h" | 37 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 36 #include "components/history/core/browser/history_model_worker.h" | 38 #include "components/history/core/browser/history_model_worker.h" |
| 37 #include "components/history/core/browser/history_service.h" | 39 #include "components/history/core/browser/history_service.h" |
| 38 #include "components/invalidation/impl/profile_invalidation_provider.h" | 40 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 39 #include "components/password_manager/core/browser/password_store.h" | 41 #include "components/password_manager/core/browser/password_store.h" |
| 40 #include "components/password_manager/sync/browser/password_model_worker.h" | 42 #include "components/password_manager/sync/browser/password_model_worker.h" |
| 43 #include "components/search_engines/search_engine_data_type_controller.h" | |
| 41 #include "components/sync_driver/glue/browser_thread_model_worker.h" | 44 #include "components/sync_driver/glue/browser_thread_model_worker.h" |
| 45 #include "components/sync_driver/glue/chrome_report_unrecoverable_error.h" | |
| 42 #include "components/sync_driver/glue/ui_model_worker.h" | 46 #include "components/sync_driver/glue/ui_model_worker.h" |
| 43 #include "components/sync_driver/sync_api_component_factory.h" | 47 #include "components/sync_driver/sync_api_component_factory.h" |
| 48 #include "components/sync_driver/ui_data_type_controller.h" | |
| 44 #include "components/sync_sessions/sync_sessions_client.h" | 49 #include "components/sync_sessions/sync_sessions_client.h" |
| 45 #include "components/syncable_prefs/pref_service_syncable.h" | 50 #include "components/syncable_prefs/pref_service_syncable.h" |
| 46 #include "content/public/browser/browser_thread.h" | 51 #include "content/public/browser/browser_thread.h" |
| 47 #include "sync/internal_api/public/engine/passive_model_worker.h" | 52 #include "sync/internal_api/public/engine/passive_model_worker.h" |
| 48 | 53 |
| 49 #if defined(ENABLE_APP_LIST) | 54 #if defined(ENABLE_APP_LIST) |
| 50 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 55 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 51 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 56 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 52 #include "ui/app_list/app_list_switches.h" | 57 #include "ui/app_list/app_list_switches.h" |
| 53 #endif | 58 #endif |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 80 #if defined(OS_ANDROID) | 85 #if defined(OS_ANDROID) |
| 81 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h" | 86 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h" |
| 82 #endif | 87 #endif |
| 83 | 88 |
| 84 #if defined(OS_CHROMEOS) | 89 #if defined(OS_CHROMEOS) |
| 85 #include "components/wifi_sync/wifi_credential_syncable_service.h" | 90 #include "components/wifi_sync/wifi_credential_syncable_service.h" |
| 86 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" | 91 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" |
| 87 #endif | 92 #endif |
| 88 | 93 |
| 89 using content::BrowserThread; | 94 using content::BrowserThread; |
| 95 #if defined(ENABLE_EXTENSIONS) | |
| 96 using browser_sync::ExtensionDataTypeController; | |
| 97 using browser_sync::ExtensionSettingDataTypeController; | |
| 98 #endif | |
| 99 using browser_sync::SearchEngineDataTypeController; | |
| 100 using sync_driver::UIDataTypeController; | |
| 90 | 101 |
| 91 namespace browser_sync { | 102 namespace browser_sync { |
| 92 | 103 |
| 93 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class | 104 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class |
| 94 // due to possible multiple inheritance issues, wherein ChromeSyncClient might | 105 // due to possible multiple inheritance issues, wherein ChromeSyncClient might |
| 95 // inherit from other interfaces with same methods. | 106 // inherit from other interfaces with same methods. |
| 96 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { | 107 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { |
| 97 public: | 108 public: |
| 98 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { | 109 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { |
| 99 window_delegates_getter_.reset( | 110 window_delegates_getter_.reset( |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 PasswordStoreFactory::GetForProfile(profile_, | 445 PasswordStoreFactory::GetForProfile(profile_, |
| 435 ServiceAccessType::EXPLICIT_ACCESS); | 446 ServiceAccessType::EXPLICIT_ACCESS); |
| 436 password->RemoveLoginsSyncedBetween(start, end); | 447 password->RemoveLoginsSyncedBetween(start, end); |
| 437 } | 448 } |
| 438 | 449 |
| 439 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting( | 450 void ChromeSyncClient::SetBrowsingDataRemoverObserverForTesting( |
| 440 BrowsingDataRemover::Observer* observer) { | 451 BrowsingDataRemover::Observer* observer) { |
| 441 browsing_data_remover_observer_ = observer; | 452 browsing_data_remover_observer_ = observer; |
| 442 } | 453 } |
| 443 | 454 |
| 455 // Static. | |
| 456 void ChromeSyncClient::RegisterDesktopDataTypes( | |
|
blundell
2015/11/10 15:24:24
Why not just have this be an instance method and t
Nicolas Zea
2015/11/11 00:06:20
Originally, the SyncAPIComponentFactory itself was
| |
| 457 Profile* profile, | |
| 458 syncer::ModelTypeSet disabled_types, | |
| 459 syncer::ModelTypeSet enabled_types, | |
| 460 sync_driver::SyncClient* sync_client) { | |
| 461 sync_driver::SyncService* sync_service = sync_client->GetSyncService(); | |
| 462 base::Closure error_callback = | |
| 463 base::Bind(&ChromeReportUnrecoverableError, chrome::GetChannel()); | |
| 464 const scoped_refptr<base::SingleThreadTaskRunner> ui_thread = | |
| 465 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI); | |
| 466 | |
| 467 #if defined(ENABLE_EXTENSIONS) | |
| 468 // App sync is enabled by default. Register unless explicitly | |
| 469 // disabled. | |
| 470 if (!disabled_types.Has(syncer::APPS)) { | |
| 471 sync_service->RegisterDataTypeController(new ExtensionDataTypeController( | |
| 472 syncer::APPS, error_callback, sync_client, profile)); | |
| 473 } | |
| 474 | |
| 475 // Extension sync is enabled by default. Register unless explicitly | |
| 476 // disabled. | |
| 477 if (!disabled_types.Has(syncer::EXTENSIONS)) { | |
| 478 sync_service->RegisterDataTypeController(new ExtensionDataTypeController( | |
| 479 syncer::EXTENSIONS, error_callback, sync_client, profile)); | |
| 480 } | |
| 481 #endif | |
| 482 | |
| 483 // Preference sync is enabled by default. Register unless explicitly | |
| 484 // disabled. | |
| 485 if (!disabled_types.Has(syncer::PREFERENCES)) { | |
| 486 sync_service->RegisterDataTypeController(new UIDataTypeController( | |
| 487 ui_thread, error_callback, syncer::PREFERENCES, sync_client)); | |
| 488 } | |
| 489 | |
| 490 #if defined(ENABLE_THEMES) | |
| 491 // Theme sync is enabled by default. Register unless explicitly disabled. | |
| 492 if (!disabled_types.Has(syncer::THEMES)) { | |
| 493 sync_service->RegisterDataTypeController( | |
| 494 new ThemeDataTypeController(error_callback, sync_client, profile)); | |
| 495 } | |
| 496 #endif | |
| 497 | |
| 498 // Search Engine sync is enabled by default. Register unless explicitly | |
| 499 // disabled. | |
| 500 if (!disabled_types.Has(syncer::SEARCH_ENGINES)) { | |
| 501 sync_service->RegisterDataTypeController(new SearchEngineDataTypeController( | |
| 502 ui_thread, error_callback, sync_client, | |
| 503 TemplateURLServiceFactory::GetForProfile(profile))); | |
| 504 } | |
| 505 | |
| 506 #if defined(ENABLE_EXTENSIONS) | |
| 507 // Extension setting sync is enabled by default. Register unless explicitly | |
| 508 // disabled. | |
| 509 if (!disabled_types.Has(syncer::EXTENSION_SETTINGS)) { | |
| 510 sync_service->RegisterDataTypeController( | |
| 511 new ExtensionSettingDataTypeController( | |
| 512 syncer::EXTENSION_SETTINGS, error_callback, sync_client, profile)); | |
| 513 } | |
| 514 | |
| 515 // App setting sync is enabled by default. Register unless explicitly | |
| 516 // disabled. | |
| 517 if (!disabled_types.Has(syncer::APP_SETTINGS)) { | |
| 518 sync_service->RegisterDataTypeController( | |
| 519 new ExtensionSettingDataTypeController( | |
| 520 syncer::APP_SETTINGS, error_callback, sync_client, profile)); | |
| 521 } | |
| 522 #endif | |
| 523 | |
| 524 #if defined(ENABLE_APP_LIST) | |
| 525 if (app_list::switches::IsAppListSyncEnabled()) { | |
| 526 sync_service->RegisterDataTypeController(new UIDataTypeController( | |
| 527 ui_thread, error_callback, syncer::APP_LIST, sync_client)); | |
| 528 } | |
| 529 #endif | |
| 530 | |
| 531 #if defined(OS_LINUX) || defined(OS_WIN) || defined(OS_CHROMEOS) | |
| 532 // Dictionary sync is enabled by default. | |
| 533 if (!disabled_types.Has(syncer::DICTIONARY)) { | |
| 534 sync_service->RegisterDataTypeController(new UIDataTypeController( | |
| 535 ui_thread, error_callback, syncer::DICTIONARY, sync_client)); | |
| 536 } | |
| 537 #endif | |
| 538 | |
| 539 #if defined(ENABLE_SUPERVISED_USERS) | |
| 540 sync_service->RegisterDataTypeController( | |
| 541 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS, | |
| 542 error_callback, sync_client, | |
| 543 profile)); | |
| 544 sync_service->RegisterDataTypeController( | |
| 545 new SupervisedUserSyncDataTypeController( | |
| 546 syncer::SUPERVISED_USER_WHITELISTS, error_callback, sync_client, | |
| 547 profile)); | |
| 548 sync_service->RegisterDataTypeController( | |
| 549 new SupervisedUserSyncDataTypeController( | |
| 550 syncer::SUPERVISED_USERS, error_callback, sync_client, profile)); | |
| 551 sync_service->RegisterDataTypeController( | |
| 552 new SupervisedUserSyncDataTypeController( | |
| 553 syncer::SUPERVISED_USER_SHARED_SETTINGS, error_callback, sync_client, | |
| 554 profile)); | |
| 555 #endif | |
| 556 | |
| 557 #if defined(OS_CHROMEOS) | |
| 558 if (command_line_->HasSwitch(switches::kEnableWifiCredentialSync) && | |
| 559 !disabled_types.Has(syncer::WIFI_CREDENTIALS)) { | |
| 560 sync_service->RegisterDataTypeController(new UIDataTypeController( | |
| 561 ui_thread, error_callback, syncer::WIFI_CREDENTIALS, sync_client)); | |
| 562 } | |
| 563 #endif | |
| 564 } | |
| 565 | |
| 566 // Static. | |
| 567 void ChromeSyncClient::RegisterAndroidDataTypes( | |
| 568 Profile* profile, | |
| 569 syncer::ModelTypeSet disabled_types, | |
| 570 syncer::ModelTypeSet enabled_types, | |
| 571 sync_driver::SyncClient* sync_client) { | |
| 572 sync_driver::SyncService* sync_service = sync_client->GetSyncService(); | |
| 573 base::Closure error_callback = | |
| 574 base::Bind(&ChromeReportUnrecoverableError, chrome::GetChannel()); | |
| 575 #if defined(ENABLE_SUPERVISED_USERS) | |
| 576 sync_service->RegisterDataTypeController( | |
| 577 new SupervisedUserSyncDataTypeController(syncer::SUPERVISED_USER_SETTINGS, | |
| 578 error_callback, sync_client, | |
| 579 profile)); | |
| 580 sync_service->RegisterDataTypeController( | |
| 581 new SupervisedUserSyncDataTypeController( | |
| 582 syncer::SUPERVISED_USER_WHITELISTS, error_callback, sync_client, | |
| 583 profile)); | |
| 584 #endif | |
| 585 } | |
| 586 | |
| 444 } // namespace browser_sync | 587 } // namespace browser_sync |
| OLD | NEW |