OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "components/sync_driver/fake_sync_client.h" | |
6 | |
7 #include "base/bind.h" | |
8 #include "base/memory/ptr_util.h" | |
9 #include "components/sync/base/extensions_activity.h" | |
10 #include "components/sync_driver/fake_sync_service.h" | |
11 #include "components/sync_driver/sync_prefs.h" | |
12 | |
13 namespace sync_driver { | |
14 | |
15 namespace { | |
16 | |
17 void DummyRegisterPlatformTypesCallback(SyncService* sync_service, | |
18 syncer::ModelTypeSet, | |
19 syncer::ModelTypeSet) {} | |
20 | |
21 } // namespace | |
22 | |
23 FakeSyncClient::FakeSyncClient() | |
24 : model_type_service_(nullptr), | |
25 factory_(nullptr), | |
26 sync_service_(base::WrapUnique(new FakeSyncService())) { | |
27 // Register sync preferences and set them to "Sync everything" state. | |
28 sync_driver::SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); | |
29 sync_driver::SyncPrefs sync_prefs(GetPrefService()); | |
30 sync_prefs.SetFirstSetupComplete(); | |
31 sync_prefs.SetKeepEverythingSynced(true); | |
32 } | |
33 | |
34 FakeSyncClient::FakeSyncClient(SyncApiComponentFactory* factory) | |
35 : factory_(factory), | |
36 sync_service_(base::WrapUnique(new FakeSyncService())) { | |
37 sync_driver::SyncPrefs::RegisterProfilePrefs(pref_service_.registry()); | |
38 } | |
39 | |
40 FakeSyncClient::~FakeSyncClient() {} | |
41 | |
42 void FakeSyncClient::Initialize() {} | |
43 | |
44 SyncService* FakeSyncClient::GetSyncService() { | |
45 return sync_service_.get(); | |
46 } | |
47 | |
48 PrefService* FakeSyncClient::GetPrefService() { | |
49 return &pref_service_; | |
50 } | |
51 | |
52 bookmarks::BookmarkModel* FakeSyncClient::GetBookmarkModel() { | |
53 return nullptr; | |
54 } | |
55 | |
56 favicon::FaviconService* FakeSyncClient::GetFaviconService() { | |
57 return nullptr; | |
58 } | |
59 | |
60 history::HistoryService* FakeSyncClient::GetHistoryService() { | |
61 return nullptr; | |
62 } | |
63 | |
64 base::Closure FakeSyncClient::GetPasswordStateChangedCallback() { | |
65 return base::Bind(&base::DoNothing); | |
66 } | |
67 | |
68 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod | |
69 FakeSyncClient::GetRegisterPlatformTypesCallback() { | |
70 return base::Bind(&DummyRegisterPlatformTypesCallback); | |
71 } | |
72 | |
73 autofill::PersonalDataManager* FakeSyncClient::GetPersonalDataManager() { | |
74 return nullptr; | |
75 } | |
76 | |
77 BookmarkUndoService* FakeSyncClient::GetBookmarkUndoServiceIfExists() { | |
78 return nullptr; | |
79 } | |
80 | |
81 invalidation::InvalidationService* FakeSyncClient::GetInvalidationService() { | |
82 return nullptr; | |
83 } | |
84 | |
85 scoped_refptr<syncer::ExtensionsActivity> | |
86 FakeSyncClient::GetExtensionsActivity() { | |
87 return scoped_refptr<syncer::ExtensionsActivity>(); | |
88 } | |
89 | |
90 sync_sessions::SyncSessionsClient* FakeSyncClient::GetSyncSessionsClient() { | |
91 return nullptr; | |
92 } | |
93 | |
94 base::WeakPtr<syncer::SyncableService> | |
95 FakeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { | |
96 return base::WeakPtr<syncer::SyncableService>(); | |
97 } | |
98 | |
99 syncer_v2::ModelTypeService* FakeSyncClient::GetModelTypeServiceForType( | |
100 syncer::ModelType type) { | |
101 return model_type_service_; | |
102 } | |
103 | |
104 scoped_refptr<syncer::ModelSafeWorker> | |
105 FakeSyncClient::CreateModelWorkerForGroup( | |
106 syncer::ModelSafeGroup group, | |
107 syncer::WorkerLoopDestructionObserver* observer) { | |
108 return scoped_refptr<syncer::ModelSafeWorker>(); | |
109 } | |
110 | |
111 SyncApiComponentFactory* FakeSyncClient::GetSyncApiComponentFactory() { | |
112 return factory_; | |
113 } | |
114 | |
115 void FakeSyncClient::SetModelTypeService( | |
116 syncer_v2::ModelTypeService* model_type_service) { | |
117 model_type_service_ = model_type_service; | |
118 } | |
119 | |
120 } // namespace sync_driver | |
OLD | NEW |