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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 using browser_sync::BookmarkChangeProcessor; | 54 using browser_sync::BookmarkChangeProcessor; |
55 using browser_sync::BookmarkDataTypeController; | 55 using browser_sync::BookmarkDataTypeController; |
56 using browser_sync::BookmarkModelAssociator; | 56 using browser_sync::BookmarkModelAssociator; |
57 using browser_sync::ChromeReportUnrecoverableError; | 57 using browser_sync::ChromeReportUnrecoverableError; |
58 using browser_sync::HistoryDeleteDirectivesDataTypeController; | 58 using browser_sync::HistoryDeleteDirectivesDataTypeController; |
59 using browser_sync::PasswordDataTypeController; | 59 using browser_sync::PasswordDataTypeController; |
60 using browser_sync::SessionDataTypeController; | 60 using browser_sync::SessionDataTypeController; |
61 using browser_sync::SyncBackendHost; | 61 using browser_sync::SyncBackendHost; |
62 using browser_sync::TypedUrlDataTypeController; | 62 using browser_sync::TypedUrlDataTypeController; |
63 using sync_driver::DataTypeController; | 63 using sync_driver::DataTypeController; |
64 using syncer::DataTypeErrorHandler; | |
65 using sync_driver::DataTypeManager; | 64 using sync_driver::DataTypeManager; |
66 using sync_driver::DataTypeManagerImpl; | 65 using sync_driver::DataTypeManagerImpl; |
67 using sync_driver::DataTypeManagerObserver; | 66 using sync_driver::DataTypeManagerObserver; |
68 using sync_driver::DeviceInfoDataTypeController; | 67 using sync_driver::DeviceInfoDataTypeController; |
69 using sync_driver::ProxyDataTypeController; | 68 using sync_driver::ProxyDataTypeController; |
70 using sync_driver::UIDataTypeController; | 69 using sync_driver::UIDataTypeController; |
71 using sync_driver_v2::UIModelTypeController; | 70 using sync_driver_v2::UIModelTypeController; |
72 | 71 |
73 namespace { | 72 namespace { |
74 | 73 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( | 145 void ProfileSyncComponentsFactoryImpl::RegisterCommonDataTypes( |
147 sync_driver::SyncService* sync_service, | 146 sync_driver::SyncService* sync_service, |
148 syncer::ModelTypeSet disabled_types, | 147 syncer::ModelTypeSet disabled_types, |
149 syncer::ModelTypeSet enabled_types) { | 148 syncer::ModelTypeSet enabled_types) { |
150 base::Closure error_callback = | 149 base::Closure error_callback = |
151 base::Bind(&ChromeReportUnrecoverableError, channel_); | 150 base::Bind(&ChromeReportUnrecoverableError, channel_); |
152 | 151 |
153 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? | 152 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? |
154 if (channel_ == version_info::Channel::UNKNOWN && | 153 if (channel_ == version_info::Channel::UNKNOWN && |
155 command_line_.HasSwitch(switches::kSyncEnableUSSDeviceInfo)) { | 154 command_line_.HasSwitch(switches::kSyncEnableUSSDeviceInfo)) { |
156 sync_service->RegisterDataTypeController(new UIModelTypeController( | 155 sync_service->RegisterDataTypeController( |
157 ui_thread_, error_callback, syncer::DEVICE_INFO, sync_client_)); | 156 base::MakeUnique<UIModelTypeController>(syncer::DEVICE_INFO, |
| 157 error_callback, sync_client_)); |
158 } else { | 158 } else { |
159 sync_service->RegisterDataTypeController(new DeviceInfoDataTypeController( | 159 sync_service->RegisterDataTypeController( |
160 ui_thread_, error_callback, sync_client_, | 160 base::MakeUnique<DeviceInfoDataTypeController>( |
161 sync_service->GetLocalDeviceInfoProvider())); | 161 error_callback, sync_client_, |
| 162 sync_service->GetLocalDeviceInfoProvider())); |
162 } | 163 } |
163 | 164 |
164 // Autofill sync is enabled by default. Register unless explicitly | 165 // Autofill sync is enabled by default. Register unless explicitly |
165 // disabled. | 166 // disabled. |
166 if (!disabled_types.Has(syncer::AUTOFILL)) { | 167 if (!disabled_types.Has(syncer::AUTOFILL)) { |
167 sync_service->RegisterDataTypeController( | 168 sync_service->RegisterDataTypeController( |
168 new AutofillDataTypeController(ui_thread_, db_thread_, error_callback, | 169 base::MakeUnique<AutofillDataTypeController>( |
169 sync_client_, web_data_service_)); | 170 db_thread_, error_callback, sync_client_, web_data_service_)); |
170 } | 171 } |
171 | 172 |
172 // Autofill profile sync is enabled by default. Register unless explicitly | 173 // Autofill profile sync is enabled by default. Register unless explicitly |
173 // disabled. | 174 // disabled. |
174 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { | 175 if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) { |
175 sync_service->RegisterDataTypeController( | 176 sync_service->RegisterDataTypeController( |
176 new AutofillProfileDataTypeController(ui_thread_, db_thread_, | 177 base::MakeUnique<AutofillProfileDataTypeController>( |
177 error_callback, sync_client_, | 178 db_thread_, error_callback, sync_client_, web_data_service_)); |
178 web_data_service_)); | |
179 } | 179 } |
180 | 180 |
181 // Wallet data sync is enabled by default, but behind a syncer experiment | 181 // Wallet data sync is enabled by default, but behind a syncer experiment |
182 // enforced by the datatype controller. Register unless explicitly disabled. | 182 // enforced by the datatype controller. Register unless explicitly disabled. |
183 bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); | 183 bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA); |
184 if (!wallet_disabled) { | 184 if (!wallet_disabled) { |
185 sync_service->RegisterDataTypeController( | 185 sync_service->RegisterDataTypeController( |
186 new browser_sync::AutofillWalletDataTypeController( | 186 base::MakeUnique<browser_sync::AutofillWalletDataTypeController>( |
187 ui_thread_, db_thread_, error_callback, sync_client_, | 187 syncer::AUTOFILL_WALLET_DATA, db_thread_, error_callback, |
188 syncer::AUTOFILL_WALLET_DATA, web_data_service_)); | 188 sync_client_, web_data_service_)); |
189 } | 189 } |
190 | 190 |
191 // Wallet metadata sync depends on Wallet data sync. Register if Wallet data | 191 // Wallet metadata sync depends on Wallet data sync. Register if Wallet data |
192 // is syncing and metadata sync is not explicitly disabled. | 192 // is syncing and metadata sync is not explicitly disabled. |
193 if (!wallet_disabled && | 193 if (!wallet_disabled && |
194 !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { | 194 !disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) { |
195 sync_service->RegisterDataTypeController( | 195 sync_service->RegisterDataTypeController( |
196 new browser_sync::AutofillWalletDataTypeController( | 196 base::MakeUnique<browser_sync::AutofillWalletDataTypeController>( |
197 ui_thread_, db_thread_, error_callback, sync_client_, | 197 syncer::AUTOFILL_WALLET_METADATA, db_thread_, error_callback, |
198 syncer::AUTOFILL_WALLET_METADATA, web_data_service_)); | 198 sync_client_, web_data_service_)); |
199 } | 199 } |
200 | 200 |
201 // Bookmark sync is enabled by default. Register unless explicitly | 201 // Bookmark sync is enabled by default. Register unless explicitly |
202 // disabled. | 202 // disabled. |
203 if (!disabled_types.Has(syncer::BOOKMARKS)) { | 203 if (!disabled_types.Has(syncer::BOOKMARKS)) { |
204 sync_service->RegisterDataTypeController(new BookmarkDataTypeController( | 204 sync_service->RegisterDataTypeController( |
205 ui_thread_, error_callback, sync_client_)); | 205 base::MakeUnique<BookmarkDataTypeController>(error_callback, |
| 206 sync_client_)); |
206 } | 207 } |
207 | 208 |
208 const bool history_disabled = | 209 const bool history_disabled = |
209 sync_client_->GetPrefService()->GetBoolean(history_disabled_pref_); | 210 sync_client_->GetPrefService()->GetBoolean(history_disabled_pref_); |
210 // TypedUrl sync is enabled by default. Register unless explicitly disabled, | 211 // TypedUrl sync is enabled by default. Register unless explicitly disabled, |
211 // or if saving history is disabled. | 212 // or if saving history is disabled. |
212 if (!disabled_types.Has(syncer::TYPED_URLS) && !history_disabled) { | 213 if (!disabled_types.Has(syncer::TYPED_URLS) && !history_disabled) { |
213 sync_service->RegisterDataTypeController(new TypedUrlDataTypeController( | 214 sync_service->RegisterDataTypeController( |
214 ui_thread_, error_callback, sync_client_, history_disabled_pref_)); | 215 base::MakeUnique<TypedUrlDataTypeController>( |
| 216 error_callback, sync_client_, history_disabled_pref_)); |
215 } | 217 } |
216 | 218 |
217 // Delete directive sync is enabled by default. Register unless full history | 219 // Delete directive sync is enabled by default. Register unless full history |
218 // sync is disabled. | 220 // sync is disabled. |
219 if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES) && | 221 if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES) && |
220 !history_disabled) { | 222 !history_disabled) { |
221 sync_service->RegisterDataTypeController( | 223 sync_service->RegisterDataTypeController( |
222 new HistoryDeleteDirectivesDataTypeController( | 224 base::MakeUnique<HistoryDeleteDirectivesDataTypeController>( |
223 ui_thread_, error_callback, sync_client_)); | 225 error_callback, sync_client_)); |
224 } | 226 } |
225 | 227 |
226 // Session sync is enabled by default. Register unless explicitly disabled. | 228 // Session sync is enabled by default. Register unless explicitly disabled. |
227 // This is also disabled if the browser history is disabled, because the | 229 // This is also disabled if the browser history is disabled, because the |
228 // tab sync data is added to the web history on the server. | 230 // tab sync data is added to the web history on the server. |
229 if (!disabled_types.Has(syncer::PROXY_TABS) && !history_disabled) { | 231 if (!disabled_types.Has(syncer::PROXY_TABS) && !history_disabled) { |
230 sync_service->RegisterDataTypeController( | 232 sync_service->RegisterDataTypeController( |
231 new ProxyDataTypeController(ui_thread_, syncer::PROXY_TABS)); | 233 base::MakeUnique<ProxyDataTypeController>(syncer::PROXY_TABS)); |
232 sync_service->RegisterDataTypeController(new SessionDataTypeController( | 234 sync_service->RegisterDataTypeController( |
233 ui_thread_, error_callback, sync_client_, | 235 base::MakeUnique<SessionDataTypeController>( |
234 sync_service->GetLocalDeviceInfoProvider(), history_disabled_pref_)); | 236 error_callback, sync_client_, |
| 237 sync_service->GetLocalDeviceInfoProvider(), |
| 238 history_disabled_pref_)); |
235 } | 239 } |
236 | 240 |
237 // Favicon sync is enabled by default. Register unless explicitly disabled. | 241 // Favicon sync is enabled by default. Register unless explicitly disabled. |
238 if (!disabled_types.Has(syncer::FAVICON_IMAGES) && | 242 if (!disabled_types.Has(syncer::FAVICON_IMAGES) && |
239 !disabled_types.Has(syncer::FAVICON_TRACKING) && !history_disabled) { | 243 !disabled_types.Has(syncer::FAVICON_TRACKING) && !history_disabled) { |
240 // crbug/384552. We disable error uploading for this data types for now. | 244 // crbug/384552. We disable error uploading for this data types for now. |
241 sync_service->RegisterDataTypeController(new UIDataTypeController( | 245 sync_service->RegisterDataTypeController( |
242 ui_thread_, base::Closure(), syncer::FAVICON_IMAGES, sync_client_)); | 246 base::MakeUnique<UIDataTypeController>(syncer::FAVICON_IMAGES, |
243 sync_service->RegisterDataTypeController(new UIDataTypeController( | 247 base::Closure(), sync_client_)); |
244 ui_thread_, base::Closure(), syncer::FAVICON_TRACKING, sync_client_)); | 248 sync_service->RegisterDataTypeController( |
| 249 base::MakeUnique<UIDataTypeController>(syncer::FAVICON_TRACKING, |
| 250 base::Closure(), sync_client_)); |
245 } | 251 } |
246 | 252 |
247 // Password sync is enabled by default. Register unless explicitly | 253 // Password sync is enabled by default. Register unless explicitly |
248 // disabled. | 254 // disabled. |
249 if (!disabled_types.Has(syncer::PASSWORDS)) { | 255 if (!disabled_types.Has(syncer::PASSWORDS)) { |
250 sync_service->RegisterDataTypeController(new PasswordDataTypeController( | 256 sync_service->RegisterDataTypeController( |
251 ui_thread_, error_callback, sync_client_, | 257 base::MakeUnique<PasswordDataTypeController>( |
252 sync_client_->GetPasswordStateChangedCallback(), password_store_)); | 258 error_callback, sync_client_, |
| 259 sync_client_->GetPasswordStateChangedCallback(), password_store_)); |
253 } | 260 } |
254 | 261 |
255 if (!disabled_types.Has(syncer::PREFERENCES) && | 262 if (!disabled_types.Has(syncer::PREFERENCES) && |
256 base::FeatureList::IsEnabled(kSyncPreferencesFeature)) { | 263 base::FeatureList::IsEnabled(kSyncPreferencesFeature)) { |
257 sync_service->RegisterDataTypeController(new UIDataTypeController( | 264 sync_service->RegisterDataTypeController( |
258 ui_thread_, error_callback, syncer::PREFERENCES, sync_client_)); | 265 base::MakeUnique<UIDataTypeController>(syncer::PREFERENCES, |
| 266 error_callback, sync_client_)); |
259 } | 267 } |
260 | 268 |
261 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { | 269 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { |
262 sync_service->RegisterDataTypeController( | 270 sync_service->RegisterDataTypeController( |
263 new UIDataTypeController(ui_thread_, error_callback, | 271 base::MakeUnique<UIDataTypeController>(syncer::PRIORITY_PREFERENCES, |
264 syncer::PRIORITY_PREFERENCES, sync_client_)); | 272 error_callback, sync_client_)); |
265 } | 273 } |
266 | 274 |
267 // Article sync is disabled by default. Register only if explicitly enabled. | 275 // Article sync is disabled by default. Register only if explicitly enabled. |
268 if (dom_distiller::IsEnableSyncArticlesSet()) { | 276 if (dom_distiller::IsEnableSyncArticlesSet()) { |
269 sync_service->RegisterDataTypeController(new UIDataTypeController( | 277 sync_service->RegisterDataTypeController( |
270 ui_thread_, error_callback, syncer::ARTICLES, sync_client_)); | 278 base::MakeUnique<UIDataTypeController>(syncer::ARTICLES, error_callback, |
| 279 sync_client_)); |
271 } | 280 } |
272 } | 281 } |
273 | 282 |
274 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( | 283 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( |
275 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& | 284 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& |
276 debug_info_listener, | 285 debug_info_listener, |
277 const DataTypeController::TypeMap* controllers, | 286 const DataTypeController::TypeMap* controllers, |
278 const sync_driver::DataTypeEncryptionHandler* encryption_handler, | 287 const sync_driver::DataTypeEncryptionHandler* encryption_handler, |
279 SyncBackendHost* backend, | 288 SyncBackendHost* backend, |
280 DataTypeManagerObserver* observer) { | 289 DataTypeManagerObserver* observer) { |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 new syncer::AttachmentServiceImpl( | 388 new syncer::AttachmentServiceImpl( |
380 std::move(attachment_store), std::move(attachment_uploader), | 389 std::move(attachment_store), std::move(attachment_uploader), |
381 std::move(attachment_downloader), delegate, initial_backoff_delay, | 390 std::move(attachment_downloader), delegate, initial_backoff_delay, |
382 max_backoff_delay)); | 391 max_backoff_delay)); |
383 return attachment_service; | 392 return attachment_service; |
384 } | 393 } |
385 | 394 |
386 sync_driver::SyncApiComponentFactory::SyncComponents | 395 sync_driver::SyncApiComponentFactory::SyncComponents |
387 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents( | 396 ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents( |
388 sync_driver::SyncService* sync_service, | 397 sync_driver::SyncService* sync_service, |
389 syncer::DataTypeErrorHandler* error_handler) { | 398 std::unique_ptr<syncer::DataTypeErrorHandler> error_handler) { |
390 BookmarkModel* bookmark_model = | 399 BookmarkModel* bookmark_model = |
391 sync_service->GetSyncClient()->GetBookmarkModel(); | 400 sync_service->GetSyncClient()->GetBookmarkModel(); |
392 syncer::UserShare* user_share = sync_service->GetUserShare(); | 401 syncer::UserShare* user_share = sync_service->GetUserShare(); |
393 // TODO(akalin): We may want to propagate this switch up eventually. | 402 // TODO(akalin): We may want to propagate this switch up eventually. |
394 #if defined(OS_ANDROID) || defined(OS_IOS) | 403 #if defined(OS_ANDROID) || defined(OS_IOS) |
395 const bool kExpectMobileBookmarksFolder = true; | 404 const bool kExpectMobileBookmarksFolder = true; |
396 #else | 405 #else |
397 const bool kExpectMobileBookmarksFolder = false; | 406 const bool kExpectMobileBookmarksFolder = false; |
398 #endif | 407 #endif |
399 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator( | 408 BookmarkModelAssociator* model_associator = new BookmarkModelAssociator( |
400 bookmark_model, sync_service->GetSyncClient(), user_share, error_handler, | 409 bookmark_model, sync_service->GetSyncClient(), user_share, |
401 kExpectMobileBookmarksFolder); | 410 error_handler->Copy(), kExpectMobileBookmarksFolder); |
402 BookmarkChangeProcessor* change_processor = new BookmarkChangeProcessor( | 411 BookmarkChangeProcessor* change_processor = |
403 sync_service->GetSyncClient(), model_associator, error_handler); | 412 new BookmarkChangeProcessor(sync_service->GetSyncClient(), |
| 413 model_associator, std::move(error_handler)); |
404 return SyncComponents(model_associator, change_processor); | 414 return SyncComponents(model_associator, change_processor); |
405 } | 415 } |
OLD | NEW |