OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 "chrome/browser/sync/chrome_sync_client.h" | 5 #include "chrome/browser/sync/chrome_sync_client.h" |
6 | 6 |
7 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 7 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
10 #include "chrome/browser/favicon/favicon_service_factory.h" | 10 #include "chrome/browser/favicon/favicon_service_factory.h" |
11 #include "chrome/browser/history/history_service_factory.h" | 11 #include "chrome/browser/history/history_service_factory.h" |
12 #include "chrome/browser/password_manager/password_store_factory.h" | 12 #include "chrome/browser/password_manager/password_store_factory.h" |
13 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 13 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/search_engines/template_url_service_factory.h" | 15 #include "chrome/browser/search_engines/template_url_service_factory.h" |
16 #include "chrome/browser/sync/profile_sync_service.h" | 16 #include "chrome/browser/sync/profile_sync_service.h" |
17 #include "chrome/browser/sync/profile_sync_service_factory.h" | 17 #include "chrome/browser/sync/profile_sync_service_factory.h" |
18 #include "chrome/browser/themes/theme_service.h" | 18 #include "chrome/browser/themes/theme_service.h" |
19 #include "chrome/browser/themes/theme_service_factory.h" | 19 #include "chrome/browser/themes/theme_service_factory.h" |
20 #include "chrome/browser/themes/theme_syncable_service.h" | 20 #include "chrome/browser/themes/theme_syncable_service.h" |
| 21 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
21 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 22 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
22 #include "chrome/browser/web_data_service_factory.h" | 23 #include "chrome/browser/web_data_service_factory.h" |
| 24 #include "chrome/common/url_constants.h" |
23 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 25 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
24 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 26 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
25 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" | 27 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" |
26 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" | 28 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" |
27 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 29 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
28 #include "components/dom_distiller/core/dom_distiller_service.h" | 30 #include "components/dom_distiller/core/dom_distiller_service.h" |
29 #include "components/history/core/browser/history_service.h" | 31 #include "components/history/core/browser/history_service.h" |
30 #include "components/password_manager/core/browser/password_store.h" | 32 #include "components/password_manager/core/browser/password_store.h" |
31 #include "components/sync_driver/sync_api_component_factory.h" | 33 #include "components/sync_driver/sync_api_component_factory.h" |
| 34 #include "components/sync_sessions/sync_sessions_client.h" |
32 #include "components/syncable_prefs/pref_service_syncable.h" | 35 #include "components/syncable_prefs/pref_service_syncable.h" |
33 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 37 #include "content/public/common/url_constants.h" |
34 | 38 |
35 #if defined(ENABLE_APP_LIST) | 39 #if defined(ENABLE_APP_LIST) |
36 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 40 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
37 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 41 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
38 #include "ui/app_list/app_list_switches.h" | 42 #include "ui/app_list/app_list_switches.h" |
39 #endif | 43 #endif |
40 | 44 |
41 #if defined(ENABLE_EXTENSIONS) | 45 #if defined(ENABLE_EXTENSIONS) |
42 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" | 46 #include "chrome/browser/extensions/api/storage/settings_sync_util.h" |
43 #include "chrome/browser/extensions/extension_sync_service.h" | 47 #include "chrome/browser/extensions/extension_sync_service.h" |
(...skipping 12 matching lines...) Expand all Loading... |
56 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 60 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
57 #include "chrome/browser/supervised_user/supervised_user_sync_data_type_controll
er.h" | 61 #include "chrome/browser/supervised_user/supervised_user_sync_data_type_controll
er.h" |
58 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" | 62 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" |
59 #endif | 63 #endif |
60 | 64 |
61 #if defined(ENABLE_SPELLCHECK) | 65 #if defined(ENABLE_SPELLCHECK) |
62 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 66 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
63 #include "chrome/browser/spellchecker/spellcheck_service.h" | 67 #include "chrome/browser/spellchecker/spellcheck_service.h" |
64 #endif | 68 #endif |
65 | 69 |
| 70 #if defined(OS_ANDROID) |
| 71 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h" |
| 72 #endif |
| 73 |
66 #if defined(OS_CHROMEOS) | 74 #if defined(OS_CHROMEOS) |
67 #include "components/wifi_sync/wifi_credential_syncable_service.h" | 75 #include "components/wifi_sync/wifi_credential_syncable_service.h" |
68 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" | 76 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" |
69 #endif | 77 #endif |
70 | 78 |
71 namespace browser_sync { | 79 namespace browser_sync { |
72 | 80 |
| 81 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class |
| 82 // due to possible multiple inheritance issues, wherein ChromeSyncClient might |
| 83 // inherit from other interfaces with same methods. |
| 84 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { |
| 85 public: |
| 86 explicit SyncSessionsClientImpl(Profile* profile) { |
| 87 window_delegates_getter_.reset( |
| 88 #if defined(OS_ANDROID) |
| 89 // Android doesn't have multi-profile support, so no need to pass the |
| 90 // profile in. |
| 91 new browser_sync::SyncedWindowDelegatesGetterAndroid()); |
| 92 #else |
| 93 new browser_sync::BrowserSyncedWindowDelegatesGetter(profile)); |
| 94 #endif |
| 95 } |
| 96 ~SyncSessionsClientImpl() override {} |
| 97 |
| 98 // SyncSessionsClient implementation. |
| 99 bool ShouldSyncURL(const GURL& url) const override { |
| 100 if (url == GURL(chrome::kChromeUIHistoryURL)) { |
| 101 // The history page is treated specially as we want it to trigger syncable |
| 102 // events for UI purposes. |
| 103 return true; |
| 104 } |
| 105 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) && |
| 106 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile(); |
| 107 } |
| 108 |
| 109 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() override { |
| 110 return window_delegates_getter_.get(); |
| 111 } |
| 112 |
| 113 private: |
| 114 scoped_ptr<SyncedWindowDelegatesGetter> window_delegates_getter_; |
| 115 |
| 116 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl); |
| 117 }; |
| 118 |
73 ChromeSyncClient::ChromeSyncClient( | 119 ChromeSyncClient::ChromeSyncClient( |
74 Profile* profile, | 120 Profile* profile, |
75 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory) | 121 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory) |
76 : profile_(profile), component_factory_(component_factory.Pass()) {} | 122 : profile_(profile), |
| 123 component_factory_(component_factory.Pass()), |
| 124 sync_sessions_client_(new SyncSessionsClientImpl(profile)) {} |
77 ChromeSyncClient::~ChromeSyncClient() { | 125 ChromeSyncClient::~ChromeSyncClient() { |
78 } | 126 } |
79 | 127 |
80 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { | 128 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { |
81 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 129 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
82 sync_service_ = sync_service; | 130 sync_service_ = sync_service; |
83 web_data_service_ = GetWebDataService(); | 131 web_data_service_ = GetWebDataService(); |
84 password_store_ = GetPasswordStore(); | 132 password_store_ = GetPasswordStore(); |
85 component_factory_->RegisterDataTypes(this); | 133 component_factory_->RegisterDataTypes(this); |
86 } | 134 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 ChromeSyncClient::GetWebDataService() { | 178 ChromeSyncClient::GetWebDataService() { |
131 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 179 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
132 return WebDataServiceFactory::GetAutofillWebDataForProfile( | 180 return WebDataServiceFactory::GetAutofillWebDataForProfile( |
133 profile_, ServiceAccessType::EXPLICIT_ACCESS); | 181 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
134 } | 182 } |
135 | 183 |
136 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { | 184 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { |
137 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); | 185 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); |
138 } | 186 } |
139 | 187 |
| 188 sync_sessions::SyncSessionsClient* ChromeSyncClient::GetSyncSessionsClient() { |
| 189 return sync_sessions_client_.get(); |
| 190 } |
| 191 |
140 base::WeakPtr<syncer::SyncableService> | 192 base::WeakPtr<syncer::SyncableService> |
141 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { | 193 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { |
142 if (!profile_) { // For tests. | 194 if (!profile_) { // For tests. |
143 return base::WeakPtr<syncer::SyncableService>(); | 195 return base::WeakPtr<syncer::SyncableService>(); |
144 } | 196 } |
145 switch (type) { | 197 switch (type) { |
146 case syncer::DEVICE_INFO: | 198 case syncer::DEVICE_INFO: |
147 return ProfileSyncServiceFactory::GetForProfile(profile_) | 199 return ProfileSyncServiceFactory::GetForProfile(profile_) |
148 ->GetDeviceInfoSyncableService() | 200 ->GetDeviceInfoSyncableService() |
149 ->AsWeakPtr(); | 201 ->AsWeakPtr(); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 return base::WeakPtr<syncer::SyncableService>(); | 313 return base::WeakPtr<syncer::SyncableService>(); |
262 } | 314 } |
263 } | 315 } |
264 | 316 |
265 sync_driver::SyncApiComponentFactory* | 317 sync_driver::SyncApiComponentFactory* |
266 ChromeSyncClient::GetSyncApiComponentFactory() { | 318 ChromeSyncClient::GetSyncApiComponentFactory() { |
267 return component_factory_.get(); | 319 return component_factory_.get(); |
268 } | 320 } |
269 | 321 |
270 } // namespace browser_sync | 322 } // namespace browser_sync |
OLD | NEW |