| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 8 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
| 11 #include "chrome/browser/favicon/favicon_service_factory.h" | 11 #include "chrome/browser/favicon/favicon_service_factory.h" |
| 12 #include "chrome/browser/history/history_service_factory.h" | 12 #include "chrome/browser/history/history_service_factory.h" |
| 13 #include "chrome/browser/password_manager/password_store_factory.h" | 13 #include "chrome/browser/password_manager/password_store_factory.h" |
| 14 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 14 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 17 #include "chrome/browser/sync/profile_sync_service.h" | 17 #include "chrome/browser/sync/profile_sync_service.h" |
| 18 #include "chrome/browser/sync/profile_sync_service_factory.h" | 18 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 19 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
| 20 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
| 21 #include "chrome/browser/themes/theme_syncable_service.h" | 21 #include "chrome/browser/themes/theme_syncable_service.h" |
| 22 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
| 22 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 23 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
| 23 #include "chrome/browser/web_data_service_factory.h" | 24 #include "chrome/browser/web_data_service_factory.h" |
| 25 #include "chrome/common/url_constants.h" |
| 24 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 26 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
| 25 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 27 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
| 26 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" | 28 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" |
| 27 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" | 29 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" |
| 28 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 30 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 29 #include "components/dom_distiller/core/dom_distiller_service.h" | 31 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 30 #include "components/history/core/browser/history_model_worker.h" | 32 #include "components/history/core/browser/history_model_worker.h" |
| 31 #include "components/history/core/browser/history_service.h" | 33 #include "components/history/core/browser/history_service.h" |
| 32 #include "components/password_manager/core/browser/password_store.h" | 34 #include "components/password_manager/core/browser/password_store.h" |
| 33 #include "components/password_manager/sync/browser/password_model_worker.h" | 35 #include "components/password_manager/sync/browser/password_model_worker.h" |
| 34 #include "components/sync_driver/glue/browser_thread_model_worker.h" | 36 #include "components/sync_driver/glue/browser_thread_model_worker.h" |
| 35 #include "components/sync_driver/glue/ui_model_worker.h" | 37 #include "components/sync_driver/glue/ui_model_worker.h" |
| 36 #include "components/sync_driver/sync_api_component_factory.h" | 38 #include "components/sync_driver/sync_api_component_factory.h" |
| 39 #include "components/sync_sessions/sync_sessions_client.h" |
| 37 #include "components/syncable_prefs/pref_service_syncable.h" | 40 #include "components/syncable_prefs/pref_service_syncable.h" |
| 38 #include "content/public/browser/browser_thread.h" | 41 #include "content/public/browser/browser_thread.h" |
| 39 #include "sync/internal_api/public/engine/passive_model_worker.h" | 42 #include "sync/internal_api/public/engine/passive_model_worker.h" |
| 40 | 43 |
| 41 #if defined(ENABLE_APP_LIST) | 44 #if defined(ENABLE_APP_LIST) |
| 42 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 45 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 43 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" | 46 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" |
| 44 #include "ui/app_list/app_list_switches.h" | 47 #include "ui/app_list/app_list_switches.h" |
| 45 #endif | 48 #endif |
| 46 | 49 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 62 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" | 65 #include "chrome/browser/supervised_user/supervised_user_settings_service_factor
y.h" |
| 63 #include "chrome/browser/supervised_user/supervised_user_sync_data_type_controll
er.h" | 66 #include "chrome/browser/supervised_user/supervised_user_sync_data_type_controll
er.h" |
| 64 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" | 67 #include "chrome/browser/supervised_user/supervised_user_whitelist_service.h" |
| 65 #endif | 68 #endif |
| 66 | 69 |
| 67 #if defined(ENABLE_SPELLCHECK) | 70 #if defined(ENABLE_SPELLCHECK) |
| 68 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 71 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 69 #include "chrome/browser/spellchecker/spellcheck_service.h" | 72 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 70 #endif | 73 #endif |
| 71 | 74 |
| 75 #if defined(OS_ANDROID) |
| 76 #include "chrome/browser/sync/glue/synced_window_delegates_getter_android.h" |
| 77 #endif |
| 78 |
| 72 #if defined(OS_CHROMEOS) | 79 #if defined(OS_CHROMEOS) |
| 73 #include "components/wifi_sync/wifi_credential_syncable_service.h" | 80 #include "components/wifi_sync/wifi_credential_syncable_service.h" |
| 74 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" | 81 #include "components/wifi_sync/wifi_credential_syncable_service_factory.h" |
| 75 #endif | 82 #endif |
| 76 | 83 |
| 77 using content::BrowserThread; | 84 using content::BrowserThread; |
| 78 | 85 |
| 79 namespace browser_sync { | 86 namespace browser_sync { |
| 80 | 87 |
| 88 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class |
| 89 // due to possible multiple inheritance issues, wherein ChromeSyncClient might |
| 90 // inherit from other interfaces with same methods. |
| 91 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { |
| 92 public: |
| 93 explicit SyncSessionsClientImpl(Profile* profile) { |
| 94 window_delegates_getter_.reset( |
| 95 #if defined(OS_ANDROID) |
| 96 // Android doesn't have multi-profile support, so no need to pass the |
| 97 // profile in. |
| 98 new browser_sync::SyncedWindowDelegatesGetterAndroid()); |
| 99 #else |
| 100 new browser_sync::BrowserSyncedWindowDelegatesGetter(profile)); |
| 101 #endif |
| 102 } |
| 103 ~SyncSessionsClientImpl() override {} |
| 104 |
| 105 // SyncSessionsClient implementation. |
| 106 bool ShouldSyncURL(const GURL& url) const override { |
| 107 if (url == GURL(chrome::kChromeUIHistoryURL)) { |
| 108 // The history page is treated specially as we want it to trigger syncable |
| 109 // events for UI purposes. |
| 110 return true; |
| 111 } |
| 112 return url.is_valid() && !url.SchemeIs(content::kChromeUIScheme) && |
| 113 !url.SchemeIs(chrome::kChromeNativeScheme) && !url.SchemeIsFile(); |
| 114 } |
| 115 |
| 116 SyncedWindowDelegatesGetter* GetSyncedWindowDelegatesGetter() override { |
| 117 return window_delegates_getter_.get(); |
| 118 } |
| 119 |
| 120 private: |
| 121 scoped_ptr<SyncedWindowDelegatesGetter> window_delegates_getter_; |
| 122 |
| 123 DISALLOW_COPY_AND_ASSIGN(SyncSessionsClientImpl); |
| 124 }; |
| 125 |
| 81 ChromeSyncClient::ChromeSyncClient( | 126 ChromeSyncClient::ChromeSyncClient( |
| 82 Profile* profile, | 127 Profile* profile, |
| 83 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory) | 128 scoped_ptr<sync_driver::SyncApiComponentFactory> component_factory) |
| 84 : profile_(profile), component_factory_(component_factory.Pass()) {} | 129 : profile_(profile), |
| 130 component_factory_(component_factory.Pass()), |
| 131 sync_sessions_client_(new SyncSessionsClientImpl(profile)) {} |
| 85 ChromeSyncClient::~ChromeSyncClient() { | 132 ChromeSyncClient::~ChromeSyncClient() { |
| 86 } | 133 } |
| 87 | 134 |
| 88 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { | 135 void ChromeSyncClient::Initialize(sync_driver::SyncService* sync_service) { |
| 89 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 136 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 90 sync_service_ = sync_service; | 137 sync_service_ = sync_service; |
| 91 web_data_service_ = GetWebDataService(); | 138 web_data_service_ = GetWebDataService(); |
| 92 password_store_ = GetPasswordStore(); | 139 password_store_ = GetPasswordStore(); |
| 93 component_factory_->RegisterDataTypes(this); | 140 component_factory_->RegisterDataTypes(this); |
| 94 } | 141 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 196 |
| 150 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { | 197 BookmarkUndoService* ChromeSyncClient::GetBookmarkUndoServiceIfExists() { |
| 151 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); | 198 return BookmarkUndoServiceFactory::GetForProfileIfExists(profile_); |
| 152 } | 199 } |
| 153 | 200 |
| 154 scoped_refptr<syncer::ExtensionsActivity> | 201 scoped_refptr<syncer::ExtensionsActivity> |
| 155 ChromeSyncClient::GetExtensionsActivity() { | 202 ChromeSyncClient::GetExtensionsActivity() { |
| 156 return extensions_activity_monitor_.GetExtensionsActivity(); | 203 return extensions_activity_monitor_.GetExtensionsActivity(); |
| 157 } | 204 } |
| 158 | 205 |
| 206 sync_sessions::SyncSessionsClient* ChromeSyncClient::GetSyncSessionsClient() { |
| 207 return sync_sessions_client_.get(); |
| 208 } |
| 209 |
| 159 base::WeakPtr<syncer::SyncableService> | 210 base::WeakPtr<syncer::SyncableService> |
| 160 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { | 211 ChromeSyncClient::GetSyncableServiceForType(syncer::ModelType type) { |
| 161 if (!profile_) { // For tests. | 212 if (!profile_) { // For tests. |
| 162 return base::WeakPtr<syncer::SyncableService>(); | 213 return base::WeakPtr<syncer::SyncableService>(); |
| 163 } | 214 } |
| 164 switch (type) { | 215 switch (type) { |
| 165 case syncer::DEVICE_INFO: | 216 case syncer::DEVICE_INFO: |
| 166 return ProfileSyncServiceFactory::GetForProfile(profile_) | 217 return ProfileSyncServiceFactory::GetForProfile(profile_) |
| 167 ->GetDeviceInfoSyncableService() | 218 ->GetDeviceInfoSyncableService() |
| 168 ->AsWeakPtr(); | 219 ->AsWeakPtr(); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 return nullptr; | 372 return nullptr; |
| 322 } | 373 } |
| 323 } | 374 } |
| 324 | 375 |
| 325 sync_driver::SyncApiComponentFactory* | 376 sync_driver::SyncApiComponentFactory* |
| 326 ChromeSyncClient::GetSyncApiComponentFactory() { | 377 ChromeSyncClient::GetSyncApiComponentFactory() { |
| 327 return component_factory_.get(); | 378 return component_factory_.get(); |
| 328 } | 379 } |
| 329 | 380 |
| 330 } // namespace browser_sync | 381 } // namespace browser_sync |
| OLD | NEW |