Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: components/browser_sync/profile_sync_components_factory_impl.cc

Issue 2511703004: [Sync] Remove UIDataTypeController (Closed)
Patch Set: Rebase. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 9 #include "base/debug/dump_without_crashing.h"
10 #include "base/feature_list.h" 10 #include "base/feature_list.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/threading/thread_task_runner_handle.h"
14 #include "build/build_config.h" 13 #include "build/build_config.h"
15 #include "components/autofill/core/browser/autofill_wallet_data_type_controller. h" 14 #include "components/autofill/core/browser/autofill_wallet_data_type_controller. h"
16 #include "components/autofill/core/browser/webdata/autofill_data_type_controller .h" 15 #include "components/autofill/core/browser/webdata/autofill_data_type_controller .h"
17 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co ntroller.h" 16 #include "components/autofill/core/browser/webdata/autofill_profile_data_type_co ntroller.h"
18 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 17 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
19 #include "components/autofill/core/common/autofill_pref_names.h" 18 #include "components/autofill/core/common/autofill_pref_names.h"
20 #include "components/autofill/core/common/autofill_switches.h" 19 #include "components/autofill/core/common/autofill_switches.h"
21 #include "components/browser_sync/browser_sync_switches.h" 20 #include "components/browser_sync/browser_sync_switches.h"
22 #include "components/browser_sync/profile_sync_service.h" 21 #include "components/browser_sync/profile_sync_service.h"
23 #include "components/dom_distiller/core/dom_distiller_features.h" 22 #include "components/dom_distiller/core/dom_distiller_features.h"
24 #include "components/history/core/browser/history_delete_directives_data_type_co ntroller.h" 23 #include "components/history/core/browser/history_delete_directives_data_type_co ntroller.h"
25 #include "components/history/core/browser/typed_url_data_type_controller.h" 24 #include "components/history/core/browser/typed_url_data_type_controller.h"
26 #include "components/password_manager/core/browser/password_store.h" 25 #include "components/password_manager/core/browser/password_store.h"
27 #include "components/password_manager/sync/browser/password_data_type_controller .h" 26 #include "components/password_manager/sync/browser/password_data_type_controller .h"
28 #include "components/prefs/pref_service.h" 27 #include "components/prefs/pref_service.h"
29 #include "components/reading_list/core/reading_list_switches.h" 28 #include "components/reading_list/core/reading_list_switches.h"
30 #include "components/sync/base/report_unrecoverable_error.h" 29 #include "components/sync/base/report_unrecoverable_error.h"
31 #include "components/sync/device_info/device_info_data_type_controller.h" 30 #include "components/sync/device_info/device_info_data_type_controller.h"
32 #include "components/sync/device_info/local_device_info_provider_impl.h" 31 #include "components/sync/device_info/local_device_info_provider_impl.h"
33 #include "components/sync/driver/data_type_manager_impl.h" 32 #include "components/sync/driver/data_type_manager_impl.h"
34 #include "components/sync/driver/glue/sync_backend_host.h" 33 #include "components/sync/driver/glue/sync_backend_host.h"
35 #include "components/sync/driver/glue/sync_backend_host_impl.h" 34 #include "components/sync/driver/glue/sync_backend_host_impl.h"
36 #include "components/sync/driver/model_type_controller.h" 35 #include "components/sync/driver/model_type_controller.h"
36 #include "components/sync/driver/non_ui_data_type_controller.h"
37 #include "components/sync/driver/proxy_data_type_controller.h" 37 #include "components/sync/driver/proxy_data_type_controller.h"
38 #include "components/sync/driver/sync_client.h" 38 #include "components/sync/driver/sync_client.h"
39 #include "components/sync/driver/sync_driver_switches.h" 39 #include "components/sync/driver/sync_driver_switches.h"
40 #include "components/sync/driver/ui_data_type_controller.h"
41 #include "components/sync/engine/attachments/attachment_downloader.h" 40 #include "components/sync/engine/attachments/attachment_downloader.h"
42 #include "components/sync/engine/attachments/attachment_uploader.h" 41 #include "components/sync/engine/attachments/attachment_uploader.h"
43 #include "components/sync/model/attachments/attachment_service.h" 42 #include "components/sync/model/attachments/attachment_service.h"
44 #include "components/sync_bookmarks/bookmark_change_processor.h" 43 #include "components/sync_bookmarks/bookmark_change_processor.h"
45 #include "components/sync_bookmarks/bookmark_data_type_controller.h" 44 #include "components/sync_bookmarks/bookmark_data_type_controller.h"
46 #include "components/sync_bookmarks/bookmark_model_associator.h" 45 #include "components/sync_bookmarks/bookmark_model_associator.h"
47 #include "components/sync_sessions/session_data_type_controller.h" 46 #include "components/sync_sessions/session_data_type_controller.h"
48 #include "google_apis/gaia/oauth2_token_service.h" 47 #include "google_apis/gaia/oauth2_token_service.h"
49 #include "google_apis/gaia/oauth2_token_service_request.h" 48 #include "google_apis/gaia/oauth2_token_service_request.h"
50 #include "net/url_request/url_request_context_getter.h" 49 #include "net/url_request/url_request_context_getter.h"
51 50
52 using bookmarks::BookmarkModel; 51 using bookmarks::BookmarkModel;
53 using sync_bookmarks::BookmarkChangeProcessor; 52 using sync_bookmarks::BookmarkChangeProcessor;
54 using sync_bookmarks::BookmarkDataTypeController; 53 using sync_bookmarks::BookmarkDataTypeController;
55 using sync_bookmarks::BookmarkModelAssociator; 54 using sync_bookmarks::BookmarkModelAssociator;
56 using syncer::DataTypeController; 55 using syncer::DataTypeController;
57 using syncer::DataTypeManager; 56 using syncer::DataTypeManager;
58 using syncer::DataTypeManagerImpl; 57 using syncer::DataTypeManagerImpl;
59 using syncer::DataTypeManagerObserver; 58 using syncer::DataTypeManagerObserver;
60 using syncer::DeviceInfoDataTypeController; 59 using syncer::DeviceInfoDataTypeController;
61 using syncer::ProxyDataTypeController; 60 using syncer::ProxyDataTypeController;
62 using syncer::UIDataTypeController;
63 using syncer::ModelTypeController; 61 using syncer::ModelTypeController;
62 using syncer::NonUIDataTypeController;
64 using sync_sessions::SessionDataTypeController; 63 using sync_sessions::SessionDataTypeController;
65 64
66 namespace browser_sync { 65 namespace browser_sync {
67 66
68 namespace { 67 namespace {
69 68
70 syncer::ModelTypeSet GetDisabledTypesFromCommandLine( 69 syncer::ModelTypeSet GetDisabledTypesFromCommandLine(
71 const base::CommandLine& command_line) { 70 const base::CommandLine& command_line) {
72 syncer::ModelTypeSet disabled_types; 71 syncer::ModelTypeSet disabled_types;
73 std::string disabled_types_str = 72 std::string disabled_types_str =
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 base::Closure error_callback = 137 base::Closure error_callback =
139 base::Bind(&syncer::ReportUnrecoverableError, channel_); 138 base::Bind(&syncer::ReportUnrecoverableError, channel_);
140 139
141 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes? 140 // TODO(stanisc): can DEVICE_INFO be one of disabled datatypes?
142 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) { 141 if (base::FeatureList::IsEnabled(switches::kSyncUSSDeviceInfo)) {
143 // Use an error callback that always uploads a stacktrace if it can to help 142 // Use an error callback that always uploads a stacktrace if it can to help
144 // get USS as stable as possible. 143 // get USS as stable as possible.
145 sync_service->RegisterDataTypeController( 144 sync_service->RegisterDataTypeController(
146 base::MakeUnique<ModelTypeController>( 145 base::MakeUnique<ModelTypeController>(
147 syncer::DEVICE_INFO, base::Bind(&base::debug::DumpWithoutCrashing), 146 syncer::DEVICE_INFO, base::Bind(&base::debug::DumpWithoutCrashing),
148 sync_client_, base::ThreadTaskRunnerHandle::Get())); 147 sync_client_, ui_thread_));
149 } else { 148 } else {
150 sync_service->RegisterDataTypeController( 149 sync_service->RegisterDataTypeController(
151 base::MakeUnique<DeviceInfoDataTypeController>( 150 base::MakeUnique<DeviceInfoDataTypeController>(
152 error_callback, sync_client_, 151 error_callback, sync_client_,
153 sync_service->GetLocalDeviceInfoProvider())); 152 sync_service->GetLocalDeviceInfoProvider()));
154 } 153 }
155 154
156 // Autofill sync is enabled by default. Register unless explicitly 155 // Autofill sync is enabled by default. Register unless explicitly
157 // disabled. 156 // disabled.
158 if (!disabled_types.Has(syncer::AUTOFILL)) { 157 if (!disabled_types.Has(syncer::AUTOFILL)) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 error_callback, sync_client_, 226 error_callback, sync_client_,
228 sync_service->GetLocalDeviceInfoProvider(), 227 sync_service->GetLocalDeviceInfoProvider(),
229 history_disabled_pref_)); 228 history_disabled_pref_));
230 } 229 }
231 230
232 // Favicon sync is enabled by default. Register unless explicitly disabled. 231 // Favicon sync is enabled by default. Register unless explicitly disabled.
233 if (!disabled_types.Has(syncer::FAVICON_IMAGES) && 232 if (!disabled_types.Has(syncer::FAVICON_IMAGES) &&
234 !disabled_types.Has(syncer::FAVICON_TRACKING) && !history_disabled) { 233 !disabled_types.Has(syncer::FAVICON_TRACKING) && !history_disabled) {
235 // crbug/384552. We disable error uploading for this data types for now. 234 // crbug/384552. We disable error uploading for this data types for now.
236 sync_service->RegisterDataTypeController( 235 sync_service->RegisterDataTypeController(
237 base::MakeUnique<UIDataTypeController>(syncer::FAVICON_IMAGES, 236 base::MakeUnique<NonUIDataTypeController>(
238 base::Closure(), sync_client_)); 237 syncer::FAVICON_IMAGES, base::Closure(), sync_client_,
238 syncer::GROUP_UI, ui_thread_));
239 sync_service->RegisterDataTypeController( 239 sync_service->RegisterDataTypeController(
240 base::MakeUnique<UIDataTypeController>(syncer::FAVICON_TRACKING, 240 base::MakeUnique<NonUIDataTypeController>(
241 base::Closure(), sync_client_)); 241 syncer::FAVICON_TRACKING, base::Closure(), sync_client_,
242 syncer::GROUP_UI, ui_thread_));
242 } 243 }
243 244
244 // Password sync is enabled by default. Register unless explicitly 245 // Password sync is enabled by default. Register unless explicitly
245 // disabled. 246 // disabled.
246 if (!disabled_types.Has(syncer::PASSWORDS)) { 247 if (!disabled_types.Has(syncer::PASSWORDS)) {
247 sync_service->RegisterDataTypeController( 248 sync_service->RegisterDataTypeController(
248 base::MakeUnique<PasswordDataTypeController>( 249 base::MakeUnique<PasswordDataTypeController>(
249 error_callback, sync_client_, 250 error_callback, sync_client_,
250 sync_client_->GetPasswordStateChangedCallback(), password_store_)); 251 sync_client_->GetPasswordStateChangedCallback(), password_store_));
251 } 252 }
252 253
253 if (!disabled_types.Has(syncer::PREFERENCES)) { 254 if (!disabled_types.Has(syncer::PREFERENCES)) {
254 if (!override_prefs_controller_to_uss_for_test_) { 255 if (!override_prefs_controller_to_uss_for_test_) {
255 sync_service->RegisterDataTypeController( 256 sync_service->RegisterDataTypeController(
256 base::MakeUnique<UIDataTypeController>(syncer::PREFERENCES, 257 base::MakeUnique<NonUIDataTypeController>(
257 error_callback, sync_client_)); 258 syncer::PREFERENCES, error_callback, sync_client_,
259 syncer::GROUP_UI, ui_thread_));
258 } else { 260 } else {
259 sync_service->RegisterDataTypeController( 261 sync_service->RegisterDataTypeController(
260 base::MakeUnique<ModelTypeController>( 262 base::MakeUnique<ModelTypeController>(
261 syncer::PREFERENCES, error_callback, sync_client_, 263 syncer::PREFERENCES, error_callback, sync_client_, ui_thread_));
262 base::ThreadTaskRunnerHandle::Get()));
263 } 264 }
264 } 265 }
265 266
266 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) { 267 if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
267 sync_service->RegisterDataTypeController( 268 sync_service->RegisterDataTypeController(
268 base::MakeUnique<UIDataTypeController>(syncer::PRIORITY_PREFERENCES, 269 base::MakeUnique<NonUIDataTypeController>(
269 error_callback, sync_client_)); 270 syncer::PRIORITY_PREFERENCES, error_callback, sync_client_,
271 syncer::GROUP_UI, ui_thread_));
270 } 272 }
271 273
272 // Article sync is disabled by default. Register only if explicitly enabled. 274 // Article sync is disabled by default. Register only if explicitly enabled.
273 if (dom_distiller::IsEnableSyncArticlesSet()) { 275 if (dom_distiller::IsEnableSyncArticlesSet()) {
274 sync_service->RegisterDataTypeController( 276 sync_service->RegisterDataTypeController(
275 base::MakeUnique<UIDataTypeController>(syncer::ARTICLES, error_callback, 277 base::MakeUnique<NonUIDataTypeController>(
276 sync_client_)); 278 syncer::ARTICLES, error_callback, sync_client_, syncer::GROUP_UI,
279 ui_thread_));
277 } 280 }
278 281
279 // Reading list sync is enabled by default only on iOS. Register unless 282 // Reading list sync is enabled by default only on iOS. Register unless
280 // Reading List or Reading List Sync is explicitly disabled. 283 // Reading List or Reading List Sync is explicitly disabled.
281 if (!disabled_types.Has(syncer::READING_LIST) && 284 if (!disabled_types.Has(syncer::READING_LIST) &&
282 reading_list::switches::IsReadingListEnabled()) { 285 reading_list::switches::IsReadingListEnabled()) {
283 sync_service->RegisterDataTypeController( 286 sync_service->RegisterDataTypeController(
284 base::MakeUnique<ModelTypeController>( 287 base::MakeUnique<ModelTypeController>(
285 syncer::READING_LIST, error_callback, sync_client_, 288 syncer::READING_LIST, error_callback, sync_client_, ui_thread_));
286 base::ThreadTaskRunnerHandle::Get()));
287 } 289 }
288 } 290 }
289 291
290 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager( 292 DataTypeManager* ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
291 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>& 293 const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
292 debug_info_listener, 294 debug_info_listener,
293 const DataTypeController::TypeMap* controllers, 295 const DataTypeController::TypeMap* controllers,
294 const syncer::DataTypeEncryptionHandler* encryption_handler, 296 const syncer::DataTypeEncryptionHandler* encryption_handler,
295 syncer::SyncBackendHost* backend, 297 syncer::SyncBackendHost* backend,
296 DataTypeManagerObserver* observer) { 298 DataTypeManagerObserver* observer) {
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 423
422 // static 424 // static
423 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) { 425 void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) {
424 override_prefs_controller_to_uss_for_test_ = use_uss; 426 override_prefs_controller_to_uss_for_test_ = use_uss;
425 } 427 }
426 428
427 bool ProfileSyncComponentsFactoryImpl:: 429 bool ProfileSyncComponentsFactoryImpl::
428 override_prefs_controller_to_uss_for_test_ = false; 430 override_prefs_controller_to_uss_for_test_ = false;
429 431
430 } // namespace browser_sync 432 } // namespace browser_sync
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698