forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile_sync_components_factory_impl.cc
549 lines (502 loc) · 24.7 KB
/
profile_sync_components_factory_impl.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/browser_sync/profile_sync_components_factory_impl.h"
#include <utility>
#include "base/bind.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/payments/autofill_wallet_data_type_controller.h"
#include "components/autofill/core/browser/payments/autofill_wallet_model_type_controller.h"
#include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_profile_data_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_profile_model_type_controller.h"
#include "components/autofill/core/browser/webdata/autofill_profile_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_wallet_sync_bridge.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/browser_sync/browser_sync_client.h"
#include "components/history/core/browser/sync/history_delete_directives_data_type_controller.h"
#include "components/history/core/browser/sync/history_delete_directives_model_type_controller.h"
#include "components/history/core/browser/sync/typed_url_model_type_controller.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/browser/sync/password_data_type_controller.h"
#include "components/password_manager/core/browser/sync/password_model_type_controller.h"
#include "components/prefs/pref_service.h"
#include "components/reading_list/features/reading_list_switches.h"
#include "components/send_tab_to_self/send_tab_to_self_sync_service.h"
#include "components/sync/base/report_unrecoverable_error.h"
#include "components/sync/device_info/device_info_sync_service.h"
#include "components/sync/driver/async_directory_type_controller.h"
#include "components/sync/driver/data_type_manager_impl.h"
#include "components/sync/driver/glue/sync_engine_impl.h"
#include "components/sync/driver/model_type_controller.h"
#include "components/sync/driver/sync_driver_switches.h"
#include "components/sync/driver/syncable_service_based_model_type_controller.h"
#include "components/sync/engine/sync_engine.h"
#include "components/sync/model/model_type_store_service.h"
#include "components/sync/model_impl/forwarding_model_type_controller_delegate.h"
#include "components/sync/model_impl/proxy_model_type_controller_delegate.h"
#include "components/sync/user_events/user_event_model_type_controller.h"
#include "components/sync_bookmarks/bookmark_change_processor.h"
#include "components/sync_bookmarks/bookmark_data_type_controller.h"
#include "components/sync_bookmarks/bookmark_model_associator.h"
#include "components/sync_bookmarks/bookmark_sync_service.h"
#include "components/sync_sessions/proxy_tabs_data_type_controller.h"
#include "components/sync_sessions/session_model_type_controller.h"
#include "components/sync_sessions/session_sync_service.h"
using base::FeatureList;
using bookmarks::BookmarkModel;
using sync_bookmarks::BookmarkChangeProcessor;
using sync_bookmarks::BookmarkDataTypeController;
using sync_bookmarks::BookmarkModelAssociator;
using syncer::AsyncDirectoryTypeController;
using syncer::DataTypeController;
using syncer::DataTypeManager;
using syncer::DataTypeManagerImpl;
using syncer::DataTypeManagerObserver;
using syncer::ModelTypeController;
using syncer::SyncableServiceBasedModelTypeController;
namespace browser_sync {
namespace {
// These helper functions only wrap the factory functions of the bridges. This
// way, it simplifies life for the compiler which cannot directly cast
// "WeakPtr<ModelTypeSyncBridge> (AutofillWebDataService*)" to
// "WeakPtr<ModelTypeControllerDelegate> (AutofillWebDataService*)".
base::WeakPtr<syncer::ModelTypeControllerDelegate>
AutocompleteDelegateFromDataService(autofill::AutofillWebDataService* service) {
return autofill::AutocompleteSyncBridge::FromWebDataService(service)
->change_processor()
->GetControllerDelegate();
}
base::WeakPtr<syncer::ModelTypeControllerDelegate>
AutofillProfileDelegateFromDataService(
autofill::AutofillWebDataService* service) {
return autofill::AutofillProfileSyncBridge::FromWebDataService(service)
->change_processor()
->GetControllerDelegate();
}
base::WeakPtr<syncer::ModelTypeControllerDelegate>
AutofillWalletDelegateFromDataService(
autofill::AutofillWebDataService* service) {
return autofill::AutofillWalletSyncBridge::FromWebDataService(service)
->change_processor()
->GetControllerDelegate();
}
base::WeakPtr<syncer::ModelTypeControllerDelegate>
AutofillWalletMetadataDelegateFromDataService(
autofill::AutofillWebDataService* service) {
return autofill::AutofillWalletMetadataSyncBridge::FromWebDataService(service)
->change_processor()
->GetControllerDelegate();
}
} // namespace
ProfileSyncComponentsFactoryImpl::ProfileSyncComponentsFactoryImpl(
browser_sync::BrowserSyncClient* sync_client,
version_info::Channel channel,
const char* history_disabled_pref,
const scoped_refptr<base::SequencedTaskRunner>& ui_thread,
const scoped_refptr<base::SequencedTaskRunner>& db_thread,
const scoped_refptr<autofill::AutofillWebDataService>&
web_data_service_on_disk,
const scoped_refptr<autofill::AutofillWebDataService>&
web_data_service_in_memory,
const scoped_refptr<password_manager::PasswordStore>& password_store,
sync_bookmarks::BookmarkSyncService* bookmark_sync_service)
: sync_client_(sync_client),
channel_(channel),
history_disabled_pref_(history_disabled_pref),
ui_thread_(ui_thread),
db_thread_(db_thread),
web_data_service_on_disk_(web_data_service_on_disk),
web_data_service_in_memory_(web_data_service_in_memory),
password_store_(password_store),
bookmark_sync_service_(bookmark_sync_service) {
DCHECK(sync_client_);
}
ProfileSyncComponentsFactoryImpl::~ProfileSyncComponentsFactoryImpl() {}
syncer::DataTypeController::TypeVector
ProfileSyncComponentsFactoryImpl::CreateCommonDataTypeControllers(
syncer::ModelTypeSet disabled_types,
syncer::SyncService* sync_service) {
syncer::DataTypeController::TypeVector controllers;
const base::RepeatingClosure dump_stack =
base::BindRepeating(&syncer::ReportUnrecoverableError, channel_);
syncer::ModelTypeStoreService* model_type_store_service =
sync_client_->GetModelTypeStoreService();
DCHECK(model_type_store_service);
syncer::RepeatingModelTypeStoreFactory model_type_store_factory =
model_type_store_service->GetStoreFactory();
controllers.push_back(std::make_unique<ModelTypeController>(
syncer::DEVICE_INFO,
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
sync_client_->GetDeviceInfoSyncService()
->GetControllerDelegate()
.get())));
// These features are enabled only if there's a DB thread to post tasks to.
if (db_thread_) {
// Autocomplete sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::AUTOFILL)) {
controllers.push_back(std::make_unique<ModelTypeController>(
syncer::AUTOFILL,
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
db_thread_, base::BindRepeating(
&AutocompleteDelegateFromDataService,
base::RetainedRef(web_data_service_on_disk_)))));
}
// Autofill sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::AUTOFILL_PROFILE)) {
if (FeatureList::IsEnabled(switches::kSyncUSSAutofillProfile)) {
controllers.push_back(
std::make_unique<AutofillProfileModelTypeController>(
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
db_thread_,
base::BindRepeating(
&AutofillProfileDelegateFromDataService,
base::RetainedRef(web_data_service_on_disk_))),
sync_client_->GetPrefService(), sync_service));
} else {
controllers.push_back(
std::make_unique<AutofillProfileDataTypeController>(
db_thread_, dump_stack, sync_service, sync_client_,
base::BindRepeating(&BrowserSyncClient::GetPersonalDataManager,
base::Unretained(sync_client_)),
web_data_service_on_disk_));
}
}
// Wallet data sync is enabled by default, but behind a syncer experiment
// enforced by the datatype controller. Register unless explicitly disabled.
bool wallet_disabled = disabled_types.Has(syncer::AUTOFILL_WALLET_DATA);
if (!wallet_disabled) {
if (base::FeatureList::IsEnabled(switches::kSyncUSSAutofillWalletData)) {
controllers.push_back(
CreateWalletModelTypeControllerWithInMemorySupport(
syncer::AUTOFILL_WALLET_DATA,
base::BindRepeating(&AutofillWalletDelegateFromDataService),
sync_service));
} else {
controllers.push_back(
std::make_unique<AutofillWalletDataTypeController>(
syncer::AUTOFILL_WALLET_DATA, db_thread_, dump_stack,
sync_service, sync_client_,
base::BindRepeating(&BrowserSyncClient::GetPersonalDataManager,
base::Unretained(sync_client_)),
web_data_service_on_disk_));
}
}
// Wallet metadata sync depends on Wallet data sync. Register if Wallet data
// is syncing and metadata sync is not explicitly disabled.
if (!wallet_disabled &&
!disabled_types.Has(syncer::AUTOFILL_WALLET_METADATA)) {
if (base::FeatureList::IsEnabled(
switches::kSyncUSSAutofillWalletMetadata)) {
controllers.push_back(CreateWalletModelTypeController(
syncer::AUTOFILL_WALLET_METADATA,
base::BindRepeating(&AutofillWalletMetadataDelegateFromDataService),
sync_service));
} else {
controllers.push_back(
std::make_unique<AutofillWalletDataTypeController>(
syncer::AUTOFILL_WALLET_METADATA, db_thread_, dump_stack,
sync_service, sync_client_,
base::BindRepeating(&BrowserSyncClient::GetPersonalDataManager,
base::Unretained(sync_client_)),
web_data_service_on_disk_));
}
}
}
// Bookmark sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::BOOKMARKS)) {
if (FeatureList::IsEnabled(switches::kSyncUSSBookmarks)) {
controllers.push_back(std::make_unique<ModelTypeController>(
syncer::BOOKMARKS,
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
ui_thread_,
base::BindRepeating(&sync_bookmarks::BookmarkSyncService::
GetBookmarkSyncControllerDelegate,
base::Unretained(bookmark_sync_service_),
sync_client_->GetFaviconService()))));
} else {
controllers.push_back(std::make_unique<BookmarkDataTypeController>(
dump_stack, sync_service, sync_client_->GetBookmarkModel(),
sync_client_->GetHistoryService(), this));
}
}
// These features are enabled only if history is not disabled.
if (!sync_client_->GetPrefService()->GetBoolean(history_disabled_pref_)) {
// TypedUrl sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::TYPED_URLS)) {
// TypedURLModelTypeController uses a proxy delegate internally, as
// provided by HistoryService.
controllers.push_back(
std::make_unique<history::TypedURLModelTypeController>(
sync_client_->GetHistoryService(), sync_client_->GetPrefService(),
history_disabled_pref_));
}
// Delete directive sync is enabled by default.
if (!disabled_types.Has(syncer::HISTORY_DELETE_DIRECTIVES)) {
if (base::FeatureList::IsEnabled(
switches::kSyncPseudoUSSHistoryDeleteDirectives)) {
controllers.push_back(
std::make_unique<HistoryDeleteDirectivesModelTypeController>(
dump_stack, sync_service,
sync_client_->GetModelTypeStoreService(), sync_client_));
} else {
controllers.push_back(
std::make_unique<HistoryDeleteDirectivesDataTypeController>(
dump_stack, sync_service, sync_client_));
}
}
// Session sync is enabled by default. This is disabled if history is
// disabled because the tab sync data is added to the web history on the
// server.
if (!disabled_types.Has(syncer::PROXY_TABS)) {
controllers.push_back(
std::make_unique<sync_sessions::ProxyTabsDataTypeController>(
base::BindRepeating(
&sync_sessions::SessionSyncService::ProxyTabsStateChanged,
base::Unretained(sync_client_->GetSessionSyncService()))));
controllers.push_back(
std::make_unique<sync_sessions::SessionModelTypeController>(
sync_service, sync_client_->GetPrefService(),
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
sync_client_->GetSessionSyncService()
->GetControllerDelegate()
.get()),
history_disabled_pref_));
}
// Favicon sync is enabled by default. Register unless explicitly disabled.
if (!disabled_types.Has(syncer::FAVICON_IMAGES) &&
!disabled_types.Has(syncer::FAVICON_TRACKING)) {
if (base::FeatureList::IsEnabled(switches::kSyncPseudoUSSFavicons)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::FAVICON_IMAGES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::FAVICON_IMAGES),
dump_stack));
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::FAVICON_TRACKING,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::FAVICON_TRACKING),
dump_stack));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::FAVICON_IMAGES, base::RepeatingClosure(), sync_service,
sync_client_, syncer::GROUP_UI, ui_thread_));
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::FAVICON_TRACKING, base::RepeatingClosure(), sync_service,
sync_client_, syncer::GROUP_UI, ui_thread_));
}
}
}
// Password sync is enabled by default. Register unless explicitly
// disabled.
if (!disabled_types.Has(syncer::PASSWORDS)) {
if (base::FeatureList::IsEnabled(switches::kSyncUSSPasswords)) {
controllers.push_back(
std::make_unique<password_manager::PasswordModelTypeController>(
password_store_->CreateSyncControllerDelegate(), sync_service,
sync_client_->GetPasswordStateChangedCallback()));
} else {
controllers.push_back(std::make_unique<PasswordDataTypeController>(
dump_stack, sync_service, sync_client_,
sync_client_->GetPasswordStateChangedCallback(), password_store_));
}
}
if (!disabled_types.Has(syncer::PREFERENCES)) {
if (override_prefs_controller_to_uss_for_test_) {
controllers.push_back(CreateModelTypeControllerForModelRunningOnUIThread(
syncer::PREFERENCES));
} else if (base::FeatureList::IsEnabled(
switches::kSyncPseudoUSSPreferences)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::PREFERENCES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::PREFERENCES),
dump_stack));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::PREFERENCES, dump_stack, sync_service, sync_client_,
syncer::GROUP_UI, ui_thread_));
}
}
if (!disabled_types.Has(syncer::PRIORITY_PREFERENCES)) {
if (base::FeatureList::IsEnabled(
switches::kSyncPseudoUSSPriorityPreferences)) {
controllers.push_back(
std::make_unique<SyncableServiceBasedModelTypeController>(
syncer::PRIORITY_PREFERENCES,
sync_client_->GetModelTypeStoreService()->GetStoreFactory(),
base::BindOnce(&syncer::SyncClient::GetSyncableServiceForType,
base::Unretained(sync_client_),
syncer::PRIORITY_PREFERENCES),
dump_stack));
} else {
controllers.push_back(std::make_unique<AsyncDirectoryTypeController>(
syncer::PRIORITY_PREFERENCES, dump_stack, sync_service, sync_client_,
syncer::GROUP_UI, ui_thread_));
}
}
#if defined(OS_CHROMEOS)
if (!disabled_types.Has(syncer::PRINTERS)) {
controllers.push_back(
CreateModelTypeControllerForModelRunningOnUIThread(syncer::PRINTERS));
}
#endif
// Reading list sync is enabled by default only on iOS. Register unless
// Reading List or Reading List Sync is explicitly disabled.
if (!disabled_types.Has(syncer::READING_LIST) &&
reading_list::switches::IsReadingListEnabled()) {
controllers.push_back(CreateModelTypeControllerForModelRunningOnUIThread(
syncer::READING_LIST));
}
if (!disabled_types.Has(syncer::USER_EVENTS)) {
// TODO(crbug.com/867801): Switch to forwarding delegate.
controllers.push_back(
std::make_unique<syncer::UserEventModelTypeController>(
sync_service,
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
sync_client_
->GetControllerDelegateForModelType(syncer::USER_EVENTS)
.get())));
}
if (!disabled_types.Has(syncer::SEND_TAB_TO_SELF) &&
base::FeatureList::IsEnabled(switches::kSyncSendTabToSelf)) {
controllers.push_back(std::make_unique<syncer::ModelTypeController>(
syncer::SEND_TAB_TO_SELF,
std::make_unique<syncer::ForwardingModelTypeControllerDelegate>(
sync_client_->GetSendTabToSelfSyncService()
->GetControllerDelegate()
.get())));
}
// Forward both on-disk and in-memory storage modes to the same delegate,
// since behavior for USER_CONSENTS does not differ (they are always
// persisted).
// TODO(crbug.com/867801): Replace the proxy delegates below with a simpler
// forwarding delegate that involves no posting of tasks.
controllers.push_back(std::make_unique<ModelTypeController>(
syncer::USER_CONSENTS,
/*delegate_on_disk=*/
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
ui_thread_, base::BindRepeating(&browser_sync::BrowserSyncClient::
GetControllerDelegateForModelType,
base::Unretained(sync_client_),
syncer::USER_CONSENTS)),
/*delegate_in_memory=*/
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
ui_thread_, base::BindRepeating(&browser_sync::BrowserSyncClient::
GetControllerDelegateForModelType,
base::Unretained(sync_client_),
syncer::USER_CONSENTS))));
return controllers;
}
std::unique_ptr<DataTypeManager>
ProfileSyncComponentsFactoryImpl::CreateDataTypeManager(
syncer::ModelTypeSet initial_types,
const syncer::WeakHandle<syncer::DataTypeDebugInfoListener>&
debug_info_listener,
const DataTypeController::TypeMap* controllers,
const syncer::DataTypeEncryptionHandler* encryption_handler,
syncer::ModelTypeConfigurer* configurer,
DataTypeManagerObserver* observer) {
return std::make_unique<DataTypeManagerImpl>(
initial_types, debug_info_listener, controllers, encryption_handler,
configurer, observer);
}
std::unique_ptr<syncer::SyncEngine>
ProfileSyncComponentsFactoryImpl::CreateSyncEngine(
const std::string& name,
invalidation::InvalidationService* invalidator,
const base::WeakPtr<syncer::SyncPrefs>& sync_prefs) {
return std::make_unique<syncer::SyncEngineImpl>(
name, invalidator, sync_prefs,
sync_client_->GetModelTypeStoreService()->GetSyncDataPath());
}
syncer::SyncApiComponentFactory::SyncComponents
ProfileSyncComponentsFactoryImpl::CreateBookmarkSyncComponents(
std::unique_ptr<syncer::DataTypeErrorHandler> error_handler,
syncer::UserShare* user_share) {
BookmarkModel* bookmark_model = sync_client_->GetBookmarkModel();
// TODO(akalin): We may want to propagate this switch up eventually.
#if defined(OS_ANDROID) || defined(OS_IOS)
const bool kExpectMobileBookmarksFolder = true;
#else
const bool kExpectMobileBookmarksFolder = false;
#endif
auto model_associator = std::make_unique<BookmarkModelAssociator>(
bookmark_model, sync_client_->GetBookmarkUndoService(),
sync_client_->GetFaviconService(), user_share, error_handler->Copy(),
kExpectMobileBookmarksFolder);
SyncComponents components;
components.change_processor = std::make_unique<BookmarkChangeProcessor>(
model_associator.get(), std::move(error_handler));
components.model_associator = std::move(model_associator);
return components;
}
// static
void ProfileSyncComponentsFactoryImpl::OverridePrefsForUssTest(bool use_uss) {
override_prefs_controller_to_uss_for_test_ = use_uss;
}
bool ProfileSyncComponentsFactoryImpl::
override_prefs_controller_to_uss_for_test_ = false;
std::unique_ptr<ModelTypeController> ProfileSyncComponentsFactoryImpl::
CreateModelTypeControllerForModelRunningOnUIThread(syncer::ModelType type) {
// TODO(crbug.com/867801): Replace the proxy delegate below with a simpler
// forwarding delegate that involves no posting of tasks.
return std::make_unique<ModelTypeController>(
type, std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
ui_thread_,
base::BindRepeating(&browser_sync::BrowserSyncClient::
GetControllerDelegateForModelType,
base::Unretained(sync_client_), type)));
}
std::unique_ptr<ModelTypeController>
ProfileSyncComponentsFactoryImpl::CreateWalletModelTypeController(
syncer::ModelType type,
const base::RepeatingCallback<
base::WeakPtr<syncer::ModelTypeControllerDelegate>(
autofill::AutofillWebDataService*)>& delegate_from_web_data,
syncer::SyncService* sync_service) {
return std::make_unique<AutofillWalletModelTypeController>(
type,
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
db_thread_,
base::BindRepeating(delegate_from_web_data,
base::RetainedRef(web_data_service_on_disk_))),
sync_client_->GetPrefService(), sync_service);
}
std::unique_ptr<ModelTypeController> ProfileSyncComponentsFactoryImpl::
CreateWalletModelTypeControllerWithInMemorySupport(
syncer::ModelType type,
const base::RepeatingCallback<
base::WeakPtr<syncer::ModelTypeControllerDelegate>(
autofill::AutofillWebDataService*)>& delegate_from_web_data,
syncer::SyncService* sync_service) {
return std::make_unique<AutofillWalletModelTypeController>(
type, /*delegate_on_disk=*/
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
db_thread_,
base::BindRepeating(delegate_from_web_data,
base::RetainedRef(web_data_service_on_disk_))),
/*delegate_in_memory=*/
std::make_unique<syncer::ProxyModelTypeControllerDelegate>(
db_thread_,
base::BindRepeating(delegate_from_web_data,
base::RetainedRef(web_data_service_in_memory_))),
sync_client_->GetPrefService(), sync_service);
}
} // namespace browser_sync