| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" | 11 #include "components/autofill/core/browser/autofill_wallet_data_type_controller.
h" |
| 12 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" | 12 #include "components/autofill/core/browser/webdata/autofill_data_type_controller
.h" |
| 13 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" | 13 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co
ntroller.h" |
| 14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 14 #include "components/autofill/core/common/autofill_pref_names.h" | 15 #include "components/autofill/core/common/autofill_pref_names.h" |
| 15 #include "components/autofill/core/common/autofill_switches.h" | 16 #include "components/autofill/core/common/autofill_switches.h" |
| 16 #include "components/browser_sync/browser/profile_sync_service.h" | 17 #include "components/browser_sync/browser/profile_sync_service.h" |
| 17 #include "components/browser_sync/common/browser_sync_switches.h" | 18 #include "components/browser_sync/common/browser_sync_switches.h" |
| 18 #include "components/dom_distiller/core/dom_distiller_features.h" | 19 #include "components/dom_distiller/core/dom_distiller_features.h" |
| 19 #include "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" | 20 #include "components/history/core/browser/history_delete_directives_data_type_co
ntroller.h" |
| 20 #include "components/history/core/browser/typed_url_change_processor.h" | 21 #include "components/history/core/browser/typed_url_change_processor.h" |
| 21 #include "components/history/core/browser/typed_url_data_type_controller.h" | 22 #include "components/history/core/browser/typed_url_data_type_controller.h" |
| 22 #include "components/history/core/browser/typed_url_model_associator.h" | 23 #include "components/history/core/browser/typed_url_model_associator.h" |
| 24 #include "components/password_manager/core/browser/password_store.h" |
| 23 #include "components/password_manager/sync/browser/password_data_type_controller
.h" | 25 #include "components/password_manager/sync/browser/password_data_type_controller
.h" |
| 24 #include "components/sync_bookmarks/bookmark_change_processor.h" | 26 #include "components/sync_bookmarks/bookmark_change_processor.h" |
| 25 #include "components/sync_bookmarks/bookmark_data_type_controller.h" | 27 #include "components/sync_bookmarks/bookmark_data_type_controller.h" |
| 26 #include "components/sync_bookmarks/bookmark_model_associator.h" | 28 #include "components/sync_bookmarks/bookmark_model_associator.h" |
| 27 #include "components/sync_driver/data_type_manager_impl.h" | 29 #include "components/sync_driver/data_type_manager_impl.h" |
| 28 #include "components/sync_driver/device_info_data_type_controller.h" | 30 #include "components/sync_driver/device_info_data_type_controller.h" |
| 29 #include "components/sync_driver/glue/chrome_report_unrecoverable_error.h" | 31 #include "components/sync_driver/glue/chrome_report_unrecoverable_error.h" |
| 30 #include "components/sync_driver/glue/sync_backend_host.h" | 32 #include "components/sync_driver/glue/sync_backend_host.h" |
| 31 #include "components/sync_driver/glue/sync_backend_host_impl.h" | 33 #include "components/sync_driver/glue/sync_backend_host_impl.h" |
| 32 #include "components/sync_driver/local_device_info_provider_impl.h" | 34 #include "components/sync_driver/local_device_info_provider_impl.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 sync_driver::SyncClient* sync_client, | 90 sync_driver::SyncClient* sync_client, |
| 89 version_info::Channel channel, | 91 version_info::Channel channel, |
| 90 const std::string& version, | 92 const std::string& version, |
| 91 bool is_tablet, | 93 bool is_tablet, |
| 92 const base::CommandLine& command_line, | 94 const base::CommandLine& command_line, |
| 93 const char* history_disabled_pref, | 95 const char* history_disabled_pref, |
| 94 const GURL& sync_service_url, | 96 const GURL& sync_service_url, |
| 95 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 97 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 96 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 98 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 97 OAuth2TokenService* token_service, | 99 OAuth2TokenService* token_service, |
| 98 net::URLRequestContextGetter* url_request_context_getter) | 100 net::URLRequestContextGetter* url_request_context_getter, |
| 101 const scoped_refptr<autofill::AutofillWebDataService>& web_data_service, |
| 102 const scoped_refptr<password_manager::PasswordStore>& password_store) |
| 99 : sync_client_(sync_client), | 103 : sync_client_(sync_client), |
| 100 channel_(channel), | 104 channel_(channel), |
| 101 version_(version), | 105 version_(version), |
| 102 is_tablet_(is_tablet), | 106 is_tablet_(is_tablet), |
| 103 command_line_(command_line), | 107 command_line_(command_line), |
| 104 history_disabled_pref_(history_disabled_pref), | 108 history_disabled_pref_(history_disabled_pref), |
| 105 sync_service_url_(sync_service_url), | 109 sync_service_url_(sync_service_url), |
| 106 ui_thread_(ui_thread), | 110 ui_thread_(ui_thread), |
| 107 db_thread_(db_thread), | 111 db_thread_(db_thread), |
| 108 token_service_(token_service), | 112 token_service_(token_service), |
| 109 url_request_context_getter_(url_request_context_getter), | 113 url_request_context_getter_(url_request_context_getter), |
| 114 web_data_service_(web_data_service), |
| 115 password_store_(password_store), |
| 110 weak_factory_(this) { | 116 weak_factory_(this) { |
| 111 DCHECK(token_service_); | 117 DCHECK(token_service_); |
| 112 DCHECK(url_request_context_getter_); | 118 DCHECK(url_request_context_getter_); |
| 113 } | 119 } |
| 114 | 120 |
| 115 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {} | 121 ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {} |
| 116 | 122 |
| 117 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( | 123 void ProfileSyncComponentsFactoryImpl::RegisterDataTypes( |
| 118 const RegisterDataTypesMethod& register_platform_types_method) { | 124 const RegisterDataTypesMethod& register_platform_types_method) { |
| 119 syncer::ModelTypeSet disabled_types = | 125 syncer::ModelTypeSet disabled_types = |
| (...skipping 13 matching lines...) Expand all Loading... |
| 133 base::Bind(&ChromeReportUnrecoverableError, channel_); | 139 base::Bind(&ChromeReportUnrecoverableError, channel_); |
| 134 | 140 |
| 135 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? | 141 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? |
| 136 sync_service->RegisterDataTypeController(new DeviceInfoDataTypeController( | 142 sync_service->RegisterDataTypeController(new DeviceInfoDataTypeController( |
| 137 ui_thread_, error_callback, sync_client_, | 143 ui_thread_, error_callback, sync_client_, |
| 138 sync_service->GetLocalDeviceInfoProvider())); | 144 sync_service->GetLocalDeviceInfoProvider())); |
| 139 | 145 |
| 140 // Autofill sync is enabled by default. Register unless explicitly | 146 // Autofill sync is enabled by default. Register unless explicitly |
| 141 // disabled. | 147 // disabled. |
| 142 if (!disabled_types.Has(syncer::AUTOFILL)) { | 148 if (!disabled_types.Has(syncer::AUTOFILL)) { |
| 143 sync_service->RegisterDataTypeController(new AutofillDataTypeController( | 149 sync_service->RegisterDataTypeController( |
| 144 ui_thread_, db_thread_, error_callback, sync_client_)); | 150 new AutofillDataTypeController(ui_thread_, db_thread_, error_callback, |
| 151 sync_client_, web_data_service_)); |
| 145 } | 152 } |
| 146 | 153 |
| 147 // Autofill profile sync is enabled by default. Register unless explicitly | 154 // Autofill profile sync is enabled by default. Register unless explicitly |
| 148 // disabled. | 155 // disabled. |
| 149 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { | 156 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { |
| 150 sync_service->RegisterDataTypeController( | 157 sync_service->RegisterDataTypeController( |
| 151 new AutofillProfileDataTypeController(ui_thread_, db_thread_, | 158 new AutofillProfileDataTypeController(ui_thread_, db_thread_, |
| 152 error_callback, sync_client_)); | 159 error_callback, sync_client_, |
| 160 web_data_service_)); |
| 153 } | 161 } |
| 154 | 162 |
| 155 // Wallet data sync is enabled by default, but behind a syncer experiment | 163 // Wallet data sync is enabled by default, but behind a syncer experiment |
| 156 // enforced by the datatype controller. Register unless explicitly disabled. | 164 // enforced by the datatype controller. Register unless explicitly disabled. |
| 157 bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); | 165 bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); |
| 158 if (!wallet_disabled) { | 166 if (!wallet_disabled) { |
| 159 sync_service->RegisterDataTypeController( | 167 sync_service->RegisterDataTypeController( |
| 160 new browser_sync::AutofillWalletDataTypeController( | 168 new browser_sync::AutofillWalletDataTypeController( |
| 161 ui_thread_, db_thread_, error_callback, sync_client_, | 169 ui_thread_, db_thread_, error_callback, sync_client_, |
| 162 syncer::AUTOFILL_WALLET_DATA)); | 170 syncer::AUTOFILL_WALLET_DATA, web_data_service_)); |
| 163 } | 171 } |
| 164 | 172 |
| 165 // Wallet metadata sync depends on Wallet data sync. Register if Wallet data | 173 // Wallet metadata sync depends on Wallet data sync. Register if Wallet data |
| 166 // is syncing and metadata sync is not explicitly disabled. | 174 // is syncing and metadata sync is not explicitly disabled. |
| 167 if (!wallet_disabled && | 175 if (!wallet_disabled && |
| 168 !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { | 176 !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { |
| 169 sync_service->RegisterDataTypeController( | 177 sync_service->RegisterDataTypeController( |
| 170 new browser_sync::AutofillWalletDataTypeController( | 178 new browser_sync::AutofillWalletDataTypeController( |
| 171 ui_thread_, db_thread_, error_callback, sync_client_, | 179 ui_thread_, db_thread_, error_callback, sync_client_, |
| 172 syncer::AUTOFILL_WALLET_METADATA)); | 180 syncer::AUTOFILL_WALLET_METADATA, web_data_service_)); |
| 173 } | 181 } |
| 174 | 182 |
| 175 // Bookmark sync is enabled by default. Register unless explicitly | 183 // Bookmark sync is enabled by default. Register unless explicitly |
| 176 // disabled. | 184 // disabled. |
| 177 if (!disabled_types.Has(syncer::BOOKMARKS)) { | 185 if (!disabled_types.Has(syncer::BOOKMARKS)) { |
| 178 sync_service->RegisterDataTypeController(new BookmarkDataTypeController( | 186 sync_service->RegisterDataTypeController(new BookmarkDataTypeController( |
| 179 ui_thread_, error_callback, sync_client_)); | 187 ui_thread_, error_callback, sync_client_)); |
| 180 } | 188 } |
| 181 | 189 |
| 182 const bool history_disabled = | 190 const bool history_disabled = |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ui_thread_, base::Closure(), syncer::FAVICON_IMAGES, sync_client_)); | 229 ui_thread_, base::Closure(), syncer::FAVICON_IMAGES, sync_client_)); |
| 222 sync_service->RegisterDataTypeController(new UIDataTypeController( | 230 sync_service->RegisterDataTypeController(new UIDataTypeController( |
| 223 ui_thread_, base::Closure(), syncer::FAVICON_TRACKING, sync_client_)); | 231 ui_thread_, base::Closure(), syncer::FAVICON_TRACKING, sync_client_)); |
| 224 } | 232 } |
| 225 | 233 |
| 226 // Password sync is enabled by default. Register unless explicitly | 234 // Password sync is enabled by default. Register unless explicitly |
| 227 // disabled. | 235 // disabled. |
| 228 if (!disabled_types.Has(syncer::PASSWORDS)) { | 236 if (!disabled_types.Has(syncer::PASSWORDS)) { |
| 229 sync_service->RegisterDataTypeController(new PasswordDataTypeController( | 237 sync_service->RegisterDataTypeController(new PasswordDataTypeController( |
| 230 ui_thread_, error_callback, sync_client_, | 238 ui_thread_, error_callback, sync_client_, |
| 231 sync_client_->GetPasswordStateChangedCallback())); | 239 sync_client_->GetPasswordStateChangedCallback(), password_store_)); |
| 232 } | 240 } |
| 233 | 241 |
| 234 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { | 242 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { |
| 235 sync_service->RegisterDataTypeController( | 243 sync_service->RegisterDataTypeController( |
| 236 new UIDataTypeController(ui_thread_, error_callback, | 244 new UIDataTypeController(ui_thread_, error_callback, |
| 237 syncer::PRIORITY_PREFERENCES, sync_client_)); | 245 syncer::PRIORITY_PREFERENCES, sync_client_)); |
| 238 } | 246 } |
| 239 | 247 |
| 240 // Article sync is disabled by default. Register only if explicitly enabled. | 248 // Article sync is disabled by default. Register only if explicitly enabled. |
| 241 if (dom_distiller::IsEnableSyncArticlesSet()) { | 249 if (dom_distiller::IsEnableSyncArticlesSet()) { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 387 | 395 |
| 388 // TODO(zea): Once TypedURLs are converted to SyncableService, remove | 396 // TODO(zea): Once TypedURLs are converted to SyncableService, remove |
| 389 // |sync_service_| member, and make GetSyncService require it be called on | 397 // |sync_service_| member, and make GetSyncService require it be called on |
| 390 // the UI thread. | 398 // the UI thread. |
| 391 TypedUrlModelAssociator* model_associator = | 399 TypedUrlModelAssociator* model_associator = |
| 392 new TypedUrlModelAssociator(sync_service, history_backend, error_handler); | 400 new TypedUrlModelAssociator(sync_service, history_backend, error_handler); |
| 393 TypedUrlChangeProcessor* change_processor = new TypedUrlChangeProcessor( | 401 TypedUrlChangeProcessor* change_processor = new TypedUrlChangeProcessor( |
| 394 model_associator, history_backend, error_handler, ui_thread_); | 402 model_associator, history_backend, error_handler, ui_thread_); |
| 395 return SyncComponents(model_associator, change_processor); | 403 return SyncComponents(model_associator, change_processor); |
| 396 } | 404 } |
| OLD | NEW |