#include "chrome/browser/sync/chrome_sync_client.h"
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/path_service.h"
#include "base/syslog_logging.h"
#include "base/task/sequenced_task_runner.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#include "chrome/browser/commerce/product_specifications/product_specifications_service_factory.h"
#include "chrome/browser/consent_auditor/consent_auditor_factory.h"
#include "chrome/browser/data_sharing/data_sharing_service_factory.h"
#include "chrome/browser/favicon/favicon_service_factory.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
#include "chrome/browser/metrics/variations/google_groups_manager_factory.h"
#include "chrome/browser/password_manager/account_password_store_factory.h"
#include "chrome/browser/password_manager/password_receiver_service_factory.h"
#include "chrome/browser/password_manager/password_sender_service_factory.h"
#include "chrome/browser/password_manager/profile_password_store_factory.h"
#include "chrome/browser/plus_addresses/plus_address_setting_service_factory.h"
#include "chrome/browser/power_bookmarks/power_bookmark_service_factory.h"
#include "chrome/browser/prefs/pref_service_syncable_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_key.h"
#include "chrome/browser/reading_list/reading_list_model_factory.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/security_events/security_event_recorder.h"
#include "chrome/browser/security_events/security_event_recorder_factory.h"
#include "chrome/browser/sharing/sharing_message_bridge_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h"
#include "chrome/browser/sync/account_bookmark_sync_service_factory.h"
#include "chrome/browser/sync/data_type_store_service_factory.h"
#include "chrome/browser/sync/device_info_sync_service_factory.h"
#include "chrome/browser/sync/local_or_syncable_bookmark_sync_service_factory.h"
#include "chrome/browser/sync/send_tab_to_self_sync_service_factory.h"
#include "chrome/browser/sync/session_sync_service_factory.h"
#include "chrome/browser/sync/sync_invalidations_service_factory.h"
#include "chrome/browser/sync/user_event_service_factory.h"
#include "chrome/browser/tab_group_sync/feature_utils.h"
#include "chrome/browser/tab_group_sync/tab_group_sync_service_factory.h"
#include "chrome/browser/tab_group_sync/tab_group_trial.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/themes/theme_syncable_service.h"
#include "chrome/browser/trusted_vault/trusted_vault_service_factory.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/webdata_services/web_data_service_factory.h"
#include "chrome/common/buildflags.h"
#include "chrome/common/channel_info.h"
#include "chrome/common/chrome_paths.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browser_sync/common_controller_builder.h"
#include "components/browser_sync/sync_engine_factory_impl.h"
#include "components/consent_auditor/consent_auditor.h"
#include "components/data_sharing/public/features.h"
#include "components/desks_storage/core/desk_sync_service.h"
#include "components/history/core/browser/history_service.h"
#include "components/password_manager/core/browser/password_store/password_store_interface.h"
#include "components/password_manager/core/browser/sharing/password_receiver_service.h"
#include "components/password_manager/core/browser/sharing/password_sender_service.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/plus_addresses/settings/plus_address_setting_service.h"
#include "components/plus_addresses/webdata/plus_address_webdata_service.h"
#include "components/prefs/pref_service.h"
#include "components/saved_tab_groups/features.h"
#include "components/saved_tab_groups/tab_group_sync_service.h"
#include "components/search_engines/template_url_service.h"
#include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
#include "components/sharing_message/sharing_message_bridge.h"
#include "components/sharing_message/sharing_message_data_type_controller.h"
#include "components/spellcheck/spellcheck_buildflags.h"
#include "components/supervised_user/core/browser/supervised_user_settings_service.h"
#include "components/sync/base/data_type.h"
#include "components/sync/base/features.h"
#include "components/sync/base/pref_names.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/model/data_type_controller_delegate.h"
#include "components/sync/model/data_type_store.h"
#include "components/sync/model/data_type_store_service.h"
#include "components/sync/model/forwarding_data_type_controller_delegate.h"
#include "components/sync/service/data_type_controller.h"
#include "components/sync/service/sync_engine_factory.h"
#include "components/sync/service/syncable_service_based_data_type_controller.h"
#include "components/sync/service/trusted_vault_synthetic_field_trial.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"
#include "components/sync_device_info/device_info_sync_service.h"
#include "components/sync_preferences/pref_service_syncable.h"
#include "components/sync_sessions/session_sync_service.h"
#include "components/sync_user_events/user_event_service.h"
#include "components/trusted_vault/trusted_vault_service.h"
#include "content/public/browser/browser_thread.h"
#include "extensions/buildflags/buildflags.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/api/storage/settings_sync_util.h"
#include "chrome/browser/extensions/extension_sync_service.h"
#include "chrome/browser/sync/glue/extension_data_type_controller.h"
#include "chrome/browser/sync/glue/extension_setting_data_type_controller.h"
#include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/browser/web_applications/web_app_sync_bridge.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#endif
#if BUILDFLAG(ENABLE_SPELLCHECK)
#include "chrome/browser/spellchecker/spellcheck_factory.h"
#include "chrome/browser/spellchecker/spellcheck_service.h"
#include "components/spellcheck/browser/pref_names.h"
#endif
#if BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || \
BUILDFLAG(IS_WIN)
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_keyed_service.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_service_factory.h"
#elif BUILDFLAG(IS_ANDROID)
#include "components/saved_tab_groups/features.h"
#endif
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/webauthn/passkey_model_factory.h"
#include "components/webauthn/core/browser/passkey_model.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/arc/arc_util.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "chrome/browser/ash/app_list/app_list_syncable_service.h"
#include "chrome/browser/ash/app_list/app_list_syncable_service_factory.h"
#include "chrome/browser/ash/app_list/arc/arc_package_sync_data_type_controller.h"
#include "chrome/browser/ash/app_list/arc/arc_package_syncable_service.h"
#include "chrome/browser/ash/arc/arc_util.h"
#include "chrome/browser/ash/crosapi/browser_util.h"
#include "chrome/browser/ash/floating_sso/floating_sso_service.h"
#include "chrome/browser/ash/floating_sso/floating_sso_service_factory.h"
#include "chrome/browser/ash/printing/oauth2/authorization_zones_manager.h"
#include "chrome/browser/ash/printing/oauth2/authorization_zones_manager_factory.h"
#include "chrome/browser/ash/printing/printers_sync_bridge.h"
#include "chrome/browser/ash/printing/synced_printers_manager.h"
#include "chrome/browser/ash/printing/synced_printers_manager_factory.h"
#include "chrome/browser/sync/desk_sync_service_factory.h"
#include "chrome/browser/sync/wifi_configuration_sync_service_factory.h"
#include "chromeos/ash/components/sync_wifi/wifi_configuration_sync_service.h"
#endif
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/android/webapk/webapk_sync_service.h"
#include "components/browser_sync/sync_client_utils.h"
#endif
BrowserThread;
namespace browser_sync {
namespace {
bool trusted_vault_synthetic_field_trial_registered = …;
#if BUILDFLAG(IS_WIN)
constexpr base::FilePath::CharType kLoopbackServerBackendFilename[] =
FILE_PATH_LITERAL("profile.pb");
#endif
base::WeakPtr<syncer::SyncableService> GetWeakPtrOrNull(
syncer::SyncableService* service) { … }
base::RepeatingClosure GetDumpStackClosure() { … }
bool ShouldSyncBrowserTypes() { … }
syncer::DataTypeSet GetDisabledCommonDataTypes() { … }
#if BUILDFLAG(ENABLE_EXTENSIONS)
bool IsAppSyncEnabled(Profile* profile) { … }
bool ShouldSyncAppsTypesInTransportMode() { … }
#endif
syncer::DataTypeControllerDelegate* GetSavedTabGroupControllerDelegate(
Profile* profile) { … }
syncer::DataTypeControllerDelegate* GetSharedTabGroupControllerDelegate(
Profile* profile) { … }
}
ChromeSyncClient::ChromeSyncClient(Profile* profile)
: … { … }
ChromeSyncClient::~ChromeSyncClient() = default;
PrefService* ChromeSyncClient::GetPrefService() { … }
signin::IdentityManager* ChromeSyncClient::GetIdentityManager() { … }
base::FilePath ChromeSyncClient::GetLocalSyncBackendFolder() { … }
#if BUILDFLAG(IS_ANDROID)
void ChromeSyncClient::GetLocalDataDescriptions(
syncer::DataTypeSet types,
base::OnceCallback<void(
std::map<syncer::DataType, syncer::LocalDataDescription>)> callback) {
types.RemoveAll(
local_data_migration_helper_->GetTypesWithOngoingMigrations());
local_data_query_helper_->Run(types, std::move(callback));
}
void ChromeSyncClient::TriggerLocalDataMigration(syncer::DataTypeSet types) {
local_data_migration_helper_->Run(types);
}
#endif
syncer::DataTypeController::TypeVector
ChromeSyncClient::CreateDataTypeControllers(syncer::SyncService* sync_service) { … }
trusted_vault::TrustedVaultClient* ChromeSyncClient::GetTrustedVaultClient() { … }
syncer::SyncInvalidationsService*
ChromeSyncClient::GetSyncInvalidationsService() { … }
scoped_refptr<syncer::ExtensionsActivity>
ChromeSyncClient::GetExtensionsActivity() { … }
syncer::DataTypeStoreService* ChromeSyncClient::GetDataTypeStoreService() { … }
base::WeakPtr<syncer::SyncableService>
ChromeSyncClient::GetSyncableServiceForType(syncer::DataType type) { … }
syncer::SyncEngineFactory* ChromeSyncClient::GetSyncEngineFactory() { … }
bool ChromeSyncClient::IsCustomPassphraseAllowed() { … }
bool ChromeSyncClient::IsPasswordSyncAllowed() { … }
void ChromeSyncClient::SetPasswordSyncAllowedChangeCb(
const base::RepeatingClosure& cb) { … }
void ChromeSyncClient::RegisterTrustedVaultAutoUpgradeSyntheticFieldTrial(
const syncer::TrustedVaultAutoUpgradeSyntheticFieldTrialGroup& group) { … }
#if BUILDFLAG(ENABLE_EXTENSIONS)
std::unique_ptr<syncer::DataTypeController>
ChromeSyncClient::CreateAppsDataTypeController() { … }
std::unique_ptr<syncer::DataTypeController>
ChromeSyncClient::CreateAppSettingsDataTypeController(
syncer::SyncService* sync_service) { … }
std::unique_ptr<syncer::DataTypeController>
ChromeSyncClient::CreateWebAppsDataTypeController() { … }
#endif
}