| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "components/browser_sync/profile_sync_components_factory_impl.h" | 5 #include "components/browser_sync/profile_sync_components_factory_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/debug/dump_without_crashing.h" | |
| 10 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
| 11 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 12 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 13 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 14 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" | 13 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" |
| 15 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" | 14 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" | 15 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" |
| 17 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 16 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 18 #include "components/autofill/core/common/autofill_pref_names.h" | 17 #include "components/autofill/core/common/autofill_pref_names.h" |
| 19 #include "components/autofill/core/common/autofill_switches.h" | 18 #include "components/autofill/core/common/autofill_switches.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 syncer::ModelTypeSet disabled_types, | 134 syncer::ModelTypeSet disabled_types, |
| 136 syncer::ModelTypeSet enabled_types) { | 135 syncer::ModelTypeSet enabled_types) { |
| 137 base::Closure error_callback = | 136 base::Closure error_callback = |
| 138 base::Bind(&syncer::ReportUnrecoverableError, channel_); | 137 base::Bind(&syncer::ReportUnrecoverableError, channel_); |
| 139 | 138 |
| 140 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? | 139 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? |
| 141 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { | 140 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { |
| 142 // Use an error callback that always uploads a stacktrace if it can to help | 141 // Use an error callback that always uploads a stacktrace if it can to help |
| 143 // get USS as stable as possible. | 142 // get USS as stable as possible. |
| 144 sync_service->RegisterDataTypeController( | 143 sync_service->RegisterDataTypeController( |
| 145 base::MakeUnique<ModelTypeController>( | 144 base::MakeUnique<ModelTypeController>(syncer::DEVICE_INFO, sync_client_, |
| 146 syncer::DEVICE_INFO, | 145 ui_thread_)); |
| 147 base::Bind(base::IgnoreResult(&base::debug::DumpWithoutCrashing)), | |
| 148 sync_client_, ui_thread_)); | |
| 149 } else { | 146 } else { |
| 150 sync_service->RegisterDataTypeController( | 147 sync_service->RegisterDataTypeController( |
| 151 base::MakeUnique<DeviceInfoDataTypeController>( | 148 base::MakeUnique<DeviceInfoDataTypeController>( |
| 152 error_callback, sync_client_, | 149 error_callback, sync_client_, |
| 153 sync_service->GetLocalDeviceInfoProvider())); | 150 sync_service->GetLocalDeviceInfoProvider())); |
| 154 } | 151 } |
| 155 | 152 |
| 156 // Autocomplete sync is enabled by default. Register unless explicitly | 153 // Autocomplete sync is enabled by default. Register unless explicitly |
| 157 // disabled. | 154 // disabled. |
| 158 if (!disabled_types.Has(syncer::AUTOFILL)) { | 155 if (!disabled_types.Has(syncer::AUTOFILL)) { |
| 159 if (base::FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { | 156 if (base::FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { |
| 160 sync_service->RegisterDataTypeController( | 157 sync_service->RegisterDataTypeController( |
| 161 base::MakeUnique<ModelTypeController>( | 158 base::MakeUnique<ModelTypeController>(syncer::AUTOFILL, sync_client_, |
| 162 syncer::AUTOFILL, | 159 db_thread_)); |
| 163 base::Bind(base::IgnoreResult(&base::debug::DumpWithoutCrashing)), | |
| 164 sync_client_, db_thread_)); | |
| 165 } else { | 160 } else { |
| 166 sync_service->RegisterDataTypeController( | 161 sync_service->RegisterDataTypeController( |
| 167 base::MakeUnique<AutofillDataTypeController>( | 162 base::MakeUnique<AutofillDataTypeController>( |
| 168 db_thread_, error_callback, sync_client_, web_data_service_)); | 163 db_thread_, error_callback, sync_client_, web_data_service_)); |
| 169 } | 164 } |
| 170 } | 165 } |
| 171 | 166 |
| 172 // Autofill sync is enabled by default. Register unless explicitly | 167 // Autofill sync is enabled by default. Register unless explicitly |
| 173 // disabled. | 168 // disabled. |
| 174 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { | 169 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 256 } |
| 262 | 257 |
| 263 if (!disabled_types.Has(syncer::PREFERENCES)) { | 258 if (!disabled_types.Has(syncer::PREFERENCES)) { |
| 264 if (!override_prefs_controller_to_uss_for_test_) { | 259 if (!override_prefs_controller_to_uss_for_test_) { |
| 265 sync_service->RegisterDataTypeController( | 260 sync_service->RegisterDataTypeController( |
| 266 base::MakeUnique<AsyncDirectoryTypeController>( | 261 base::MakeUnique<AsyncDirectoryTypeController>( |
| 267 syncer::PREFERENCES, error_callback, sync_client_, | 262 syncer::PREFERENCES, error_callback, sync_client_, |
| 268 syncer::GROUP_UI, ui_thread_)); | 263 syncer::GROUP_UI, ui_thread_)); |
| 269 } else { | 264 } else { |
| 270 sync_service->RegisterDataTypeController( | 265 sync_service->RegisterDataTypeController( |
| 271 base::MakeUnique<ModelTypeController>( | 266 base::MakeUnique<ModelTypeController>(syncer::PREFERENCES, |
| 272 syncer::PREFERENCES, error_callback, sync_client_, ui_thread_)); | 267 sync_client_, ui_thread_)); |
| 273 } | 268 } |
| 274 } | 269 } |
| 275 | 270 |
| 276 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { | 271 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { |
| 277 sync_service->RegisterDataTypeController( | 272 sync_service->RegisterDataTypeController( |
| 278 base::MakeUnique<AsyncDirectoryTypeController>( | 273 base::MakeUnique<AsyncDirectoryTypeController>( |
| 279 syncer::PRIORITY_PREFERENCES, error_callback, sync_client_, | 274 syncer::PRIORITY_PREFERENCES, error_callback, sync_client_, |
| 280 syncer::GROUP_UI, ui_thread_)); | 275 syncer::GROUP_UI, ui_thread_)); |
| 281 } | 276 } |
| 282 | 277 |
| 283 // Article sync is disabled by default. Register only if explicitly enabled. | 278 // Article sync is disabled by default. Register only if explicitly enabled. |
| 284 if (dom_distiller::IsEnableSyncArticlesSet()) { | 279 if (dom_distiller::IsEnableSyncArticlesSet()) { |
| 285 sync_service->RegisterDataTypeController( | 280 sync_service->RegisterDataTypeController( |
| 286 base::MakeUnique<AsyncDirectoryTypeController>( | 281 base::MakeUnique<AsyncDirectoryTypeController>( |
| 287 syncer::ARTICLES, error_callback, sync_client_, syncer::GROUP_UI, | 282 syncer::ARTICLES, error_callback, sync_client_, syncer::GROUP_UI, |
| 288 ui_thread_)); | 283 ui_thread_)); |
| 289 } | 284 } |
| 290 | 285 |
| 291 // Reading list sync is enabled by default only on iOS. Register unless | 286 // Reading list sync is enabled by default only on iOS. Register unless |
| 292 // Reading List or Reading List Sync is explicitly disabled. | 287 // Reading List or Reading List Sync is explicitly disabled. |
| 293 if (!disabled_types.Has(syncer::READING_LIST) && | 288 if (!disabled_types.Has(syncer::READING_LIST) && |
| 294 reading_list::switches::IsReadingListEnabled()) { | 289 reading_list::switches::IsReadingListEnabled()) { |
| 295 sync_service->RegisterDataTypeController( | 290 sync_service->RegisterDataTypeController( |
| 296 base::MakeUnique<ModelTypeController>( | 291 base::MakeUnique<ModelTypeController>(syncer::READING_LIST, |
| 297 syncer::READING_LIST, error_callback, sync_client_, ui_thread_)); | 292 sync_client_, ui_thread_)); |
| 298 } | 293 } |
| 299 } | 294 } |
| 300 | 295 |
| 301 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( | 296 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( |
| 302 syncer::ModelTypeSet initial_types, | 297 syncer::ModelTypeSet initial_types, |
| 303 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 298 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
| 304 debug_info_listener, | 299 debug_info_listener, |
| 305 const DataTypeController::TypeMap* controllers, | 300 const DataTypeController::TypeMap* controllers, |
| 306 const syncer::DataTypeEncryptionHandler* encryption_handler, | 301 const syncer::DataTypeEncryptionHandler* encryption_handler, |
| 307 syncer::ModelTypeConfigurer* configurer, | 302 syncer::ModelTypeConfigurer* configurer, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 428 |
| 434 // static | 429 // static |
| 435 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { | 430 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { |
| 436 override_prefs_controller_to_uss_for_test_ = use_uss; | 431 override_prefs_controller_to_uss_for_test_ = use_uss; |
| 437 } | 432 } |
| 438 | 433 |
| 439 bool ProfileSyncComponentsFactoryImpl:: | 434 bool ProfileSyncComponentsFactoryImpl:: |
| 440 override_prefs_controller_to_uss_for_test_ = false; | 435 override_prefs_controller_to_uss_for_test_ = false; |
| 441 | 436 |
| 442 } // namespace browser_sync | 437 } // namespace browser_sync |
| OLD | NEW |