Chromium Code Reviews| 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/browser/profile_sync_components_factory_impl.h " | 5 #include "components/browser_sync/browser/profile_sync_components_factory_impl.h " |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 syncer::ModelTypeSet disabled_types = | 135 syncer::ModelTypeSet disabled_types = |
| 136 GetDisabledTypesFromCommandLine(command_line_); | 136 GetDisabledTypesFromCommandLine(command_line_); |
| 137 syncer::ModelTypeSet enabled_types = | 137 syncer::ModelTypeSet enabled_types = |
| 138 GetEnabledTypesFromCommandLine(command_line_); | 138 GetEnabledTypesFromCommandLine(command_line_); |
| 139 RegisterCommonDataTypes(sync_service, disabled_types, enabled_types); | 139 RegisterCommonDataTypes(sync_service, disabled_types, enabled_types); |
| 140 if (!register_platform_types_method.is_null()) | 140 if (!register_platform_types_method.is_null()) |
| 141 register_platform_types_method.Run(sync_service, disabled_types, | 141 register_platform_types_method.Run(sync_service, disabled_types, |
| 142 enabled_types); | 142 enabled_types); |
| 143 } | 143 } |
| 144 | 144 |
| 145 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( | 145 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( |
|
skym
2016/09/12 19:57:50
This whole method makes me sad.
maxbogue
2016/09/13 03:44:54
SAME! It's so awkward and clunky. Should probs be
| |
| 146 sync_driver::SyncService* sync_service, | 146 sync_driver::SyncService* sync_service, |
| 147 syncer::ModelTypeSet disabled_types, | 147 syncer::ModelTypeSet disabled_types, |
| 148 syncer::ModelTypeSet enabled_types) { | 148 syncer::ModelTypeSet enabled_types) { |
| 149 base::Closure error_callback = | 149 base::Closure error_callback = |
| 150 base::Bind(&ChromeReportUnrecoverableError, channel_); | 150 base::Bind(&ChromeReportUnrecoverableError, channel_); |
| 151 | 151 |
| 152 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? | 152 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? |
| 153 if (channel_ == version_info::Channel::UNKNOWN && | 153 if (channel_ == version_info::Channel::UNKNOWN && |
| 154 command_line_.HasSwitch(switches::kSyncEnableUSSDeviceInfo)) { | 154 command_line_.HasSwitch(switches::kSyncEnableUSSDeviceInfo)) { |
| 155 sync_service->RegisterDataTypeController( | 155 sync_service->RegisterDataTypeController( |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 // disabled. | 254 // disabled. |
| 255 if (!disabled_types.Has(syncer::PASSWORDS)) { | 255 if (!disabled_types.Has(syncer::PASSWORDS)) { |
| 256 sync_service->RegisterDataTypeController( | 256 sync_service->RegisterDataTypeController( |
| 257 base::MakeUnique<PasswordDataTypeController>( | 257 base::MakeUnique<PasswordDataTypeController>( |
| 258 error_callback, sync_client_, | 258 error_callback, sync_client_, |
| 259 sync_client_->GetPasswordStateChangedCallback(), password_store_)); | 259 sync_client_->GetPasswordStateChangedCallback(), password_store_)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 if (!disabled_types.Has(syncer::PREFERENCES) && | 262 if (!disabled_types.Has(syncer::PREFERENCES) && |
| 263 base::FeatureList::IsEnabled(kSyncPreferencesFeature)) { | 263 base::FeatureList::IsEnabled(kSyncPreferencesFeature)) { |
| 264 sync_service->RegisterDataTypeController( | 264 if (!override_prefs_for_uss_test_) { |
| 265 base::MakeUnique<UIDataTypeController>(syncer::PREFERENCES, | 265 sync_service->RegisterDataTypeController( |
| 266 error_callback, sync_client_)); | 266 base::MakeUnique<UIDataTypeController>(syncer::PREFERENCES, |
| 267 error_callback, sync_client_)); | |
| 268 } else { | |
| 269 sync_service->RegisterDataTypeController( | |
| 270 base::MakeUnique<UIModelTypeController>( | |
| 271 syncer::PREFERENCES, error_callback, sync_client_)); | |
| 272 } | |
| 267 } | 273 } |
| 268 | 274 |
| 269 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { | 275 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { |
| 270 sync_service->RegisterDataTypeController( | 276 sync_service->RegisterDataTypeController( |
| 271 base::MakeUnique<UIDataTypeController>(syncer::PRIORITY_PREFERENCES, | 277 base::MakeUnique<UIDataTypeController>(syncer::PRIORITY_PREFERENCES, |
| 272 error_callback, sync_client_)); | 278 error_callback, sync_client_)); |
| 273 } | 279 } |
| 274 | 280 |
| 275 // Article sync is disabled by default. Register only if explicitly enabled. | 281 // Article sync is disabled by default. Register only if explicitly enabled. |
| 276 if (dom_distiller::IsEnableSyncArticlesSet()) { | 282 if (dom_distiller::IsEnableSyncArticlesSet()) { |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 const bool kExpectMobileBookmarksFolder = false; | 412 const bool kExpectMobileBookmarksFolder = false; |
| 407 #endif | 413 #endif |
| 408 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator( | 414 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator( |
| 409 bookmark_model, sync_service->GetSyncClient(), user_share, | 415 bookmark_model, sync_service->GetSyncClient(), user_share, |
| 410 error_handler->Copy(), kExpectMobileBookmarksFolder); | 416 error_handler->Copy(), kExpectMobileBookmarksFolder); |
| 411 BookmarkChangeProcessor* change_processor = | 417 BookmarkChangeProcessor* change_processor = |
| 412 new BookmarkChangeProcessor(sync_service->GetSyncClient(), | 418 new BookmarkChangeProcessor(sync_service->GetSyncClient(), |
| 413 model_associator, std::move(error_handler)); | 419 model_associator, std::move(error_handler)); |
| 414 return SyncComponents(model_associator, change_processor); | 420 return SyncComponents(model_associator, change_processor); |
| 415 } | 421 } |
| 422 | |
| 423 // static | |
| 424 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest() { | |
| 425 override_prefs_for_uss_test_ = true; | |
| 426 } | |
| 427 | |
| 428 bool ProfileSyncComponentsFactoryImpl::override_prefs_for_uss_test_ = false; | |
|
skym
2016/09/12 19:57:50
Why not do this assignment in the .h file?
maxbogue
2016/09/13 03:44:54
Can't :(
| |
| OLD | NEW |