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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/path_service.h" |
| 13 #include "base/syslog_logging.h" |
12 #include "build/build_config.h" | 14 #include "build/build_config.h" |
13 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 15 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 16 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
15 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 18 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
17 #include "chrome/browser/favicon/favicon_service_factory.h" | 19 #include "chrome/browser/favicon/favicon_service_factory.h" |
18 #include "chrome/browser/history/history_service_factory.h" | 20 #include "chrome/browser/history/history_service_factory.h" |
19 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" | 21 #include "chrome/browser/invalidation/profile_invalidation_provider_factory.h" |
20 #include "chrome/browser/password_manager/password_store_factory.h" | 22 #include "chrome/browser/password_manager/password_store_factory.h" |
21 #include "chrome/browser/prefs/pref_service_syncable_util.h" | 23 #include "chrome/browser/prefs/pref_service_syncable_util.h" |
22 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/search_engines/template_url_service_factory.h" | 26 #include "chrome/browser/search_engines/template_url_service_factory.h" |
25 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 27 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
26 #include "chrome/browser/sync/glue/sync_start_util.h" | 28 #include "chrome/browser/sync/glue/sync_start_util.h" |
27 #include "chrome/browser/sync/glue/theme_data_type_controller.h" | 29 #include "chrome/browser/sync/glue/theme_data_type_controller.h" |
28 #include "chrome/browser/sync/profile_sync_service_factory.h" | 30 #include "chrome/browser/sync/profile_sync_service_factory.h" |
29 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" | 31 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h" |
30 #include "chrome/browser/themes/theme_service.h" | 32 #include "chrome/browser/themes/theme_service.h" |
31 #include "chrome/browser/themes/theme_service_factory.h" | 33 #include "chrome/browser/themes/theme_service_factory.h" |
32 #include "chrome/browser/themes/theme_syncable_service.h" | 34 #include "chrome/browser/themes/theme_syncable_service.h" |
33 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" | 35 #include "chrome/browser/ui/sync/browser_synced_window_delegates_getter.h" |
34 #include "chrome/browser/undo/bookmark_undo_service_factory.h" | 36 #include "chrome/browser/undo/bookmark_undo_service_factory.h" |
35 #include "chrome/browser/web_data_service_factory.h" | 37 #include "chrome/browser/web_data_service_factory.h" |
36 #include "chrome/common/channel_info.h" | 38 #include "chrome/common/channel_info.h" |
| 39 #include "chrome/common/chrome_paths.h" |
37 #include "chrome/common/features.h" | 40 #include "chrome/common/features.h" |
38 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
39 #include "chrome/common/url_constants.h" | 42 #include "chrome/common/url_constants.h" |
40 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" | 43 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" |
41 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 44 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
42 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 45 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
43 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" | 46 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" |
44 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" | 47 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" |
45 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 48 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
46 #include "components/browser_sync/browser_sync_switches.h" | 49 #include "components/browser_sync/browser_sync_switches.h" |
47 #include "components/browser_sync/profile_sync_components_factory_impl.h" | 50 #include "components/browser_sync/profile_sync_components_factory_impl.h" |
48 #include "components/browser_sync/profile_sync_service.h" | 51 #include "components/browser_sync/profile_sync_service.h" |
49 #include "components/dom_distiller/core/dom_distiller_service.h" | 52 #include "components/dom_distiller/core/dom_distiller_service.h" |
50 #include "components/history/core/browser/history_model_worker.h" | 53 #include "components/history/core/browser/history_model_worker.h" |
51 #include "components/history/core/browser/history_service.h" | 54 #include "components/history/core/browser/history_service.h" |
52 #include "components/invalidation/impl/profile_invalidation_provider.h" | 55 #include "components/invalidation/impl/profile_invalidation_provider.h" |
53 #include "components/password_manager/core/browser/password_store.h" | 56 #include "components/password_manager/core/browser/password_store.h" |
54 #include "components/password_manager/sync/browser/password_model_worker.h" | 57 #include "components/password_manager/sync/browser/password_model_worker.h" |
55 #include "components/search_engines/search_engine_data_type_controller.h" | 58 #include "components/search_engines/search_engine_data_type_controller.h" |
56 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 59 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
57 #include "components/spellcheck/spellcheck_build_features.h" | 60 #include "components/spellcheck/spellcheck_build_features.h" |
| 61 #include "components/sync/base/pref_names.h" |
58 #include "components/sync/base/report_unrecoverable_error.h" | 62 #include "components/sync/base/report_unrecoverable_error.h" |
59 #include "components/sync/driver/async_directory_type_controller.h" | 63 #include "components/sync/driver/async_directory_type_controller.h" |
60 #include "components/sync/driver/sync_api_component_factory.h" | 64 #include "components/sync/driver/sync_api_component_factory.h" |
61 #include "components/sync/driver/sync_util.h" | 65 #include "components/sync/driver/sync_util.h" |
62 #include "components/sync/engine/browser_thread_model_worker.h" | 66 #include "components/sync/engine/browser_thread_model_worker.h" |
63 #include "components/sync/engine/passive_model_worker.h" | 67 #include "components/sync/engine/passive_model_worker.h" |
64 #include "components/sync/engine/ui_model_worker.h" | 68 #include "components/sync/engine/ui_model_worker.h" |
65 #include "components/sync_preferences/pref_service_syncable.h" | 69 #include "components/sync_preferences/pref_service_syncable.h" |
66 #include "components/sync_sessions/sync_sessions_client.h" | 70 #include "components/sync_sessions/sync_sessions_client.h" |
67 #include "content/public/browser/browser_thread.h" | 71 #include "content/public/browser/browser_thread.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 using content::BrowserThread; | 120 using content::BrowserThread; |
117 #if BUILDFLAG(ENABLE_EXTENSIONS) | 121 #if BUILDFLAG(ENABLE_EXTENSIONS) |
118 using browser_sync::ExtensionDataTypeController; | 122 using browser_sync::ExtensionDataTypeController; |
119 using browser_sync::ExtensionSettingDataTypeController; | 123 using browser_sync::ExtensionSettingDataTypeController; |
120 #endif | 124 #endif |
121 using browser_sync::SearchEngineDataTypeController; | 125 using browser_sync::SearchEngineDataTypeController; |
122 using syncer::AsyncDirectoryTypeController; | 126 using syncer::AsyncDirectoryTypeController; |
123 | 127 |
124 namespace browser_sync { | 128 namespace browser_sync { |
125 | 129 |
| 130 namespace { |
| 131 #if defined(OS_WIN) |
| 132 const base::FilePath::CharType kLoopbackServerBackendFilename[] = |
| 133 FILE_PATH_LITERAL("profile.pb"); |
| 134 #endif |
| 135 } // namespace |
| 136 |
126 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class | 137 // Chrome implementation of SyncSessionsClient. Needs to be in a separate class |
127 // due to possible multiple inheritance issues, wherein ChromeSyncClient might | 138 // due to possible multiple inheritance issues, wherein ChromeSyncClient might |
128 // inherit from other interfaces with same methods. | 139 // inherit from other interfaces with same methods. |
129 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { | 140 class SyncSessionsClientImpl : public sync_sessions::SyncSessionsClient { |
130 public: | 141 public: |
131 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { | 142 explicit SyncSessionsClientImpl(Profile* profile) : profile_(profile) { |
132 window_delegates_getter_.reset( | 143 window_delegates_getter_.reset( |
133 #if defined(OS_ANDROID) | 144 #if defined(OS_ANDROID) |
134 // Android doesn't have multi-profile support, so no need to pass the | 145 // Android doesn't have multi-profile support, so no need to pass the |
135 // profile in. | 146 // profile in. |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 syncer::SyncService* ChromeSyncClient::GetSyncService() { | 239 syncer::SyncService* ChromeSyncClient::GetSyncService() { |
229 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 240 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
230 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); | 241 return ProfileSyncServiceFactory::GetSyncServiceForBrowserContext(profile_); |
231 } | 242 } |
232 | 243 |
233 PrefService* ChromeSyncClient::GetPrefService() { | 244 PrefService* ChromeSyncClient::GetPrefService() { |
234 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 245 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
235 return profile_->GetPrefs(); | 246 return profile_->GetPrefs(); |
236 } | 247 } |
237 | 248 |
| 249 base::FilePath ChromeSyncClient::GetLocalSyncBackendFolder() { |
| 250 base::FilePath local_sync_backend_folder = |
| 251 GetPrefService()->GetFilePath(syncer::prefs::kLocalSyncBackendDir); |
| 252 |
| 253 #if defined(OS_WIN) |
| 254 if (local_sync_backend_folder.empty()) { |
| 255 if (!base::PathService::Get(chrome::DIR_ROAMING_USER_DATA, |
| 256 &local_sync_backend_folder)) { |
| 257 SYSLOG(WARNING) << "Local sync can not get the roaming profile folder."; |
| 258 return base::FilePath(); |
| 259 } |
| 260 } |
| 261 |
| 262 // This code as it is now will assume the same profile order is present on |
| 263 // all machines, which is not a given. It is to be defined if only the |
| 264 // Default profile should get this treatment or all profile as is the case |
| 265 // now. |
| 266 // TODO(pastarmovj): http://crbug.com/674928 Decide if only the Default one |
| 267 // should be considered roamed. For now the code assumes all profiles are |
| 268 // created in the same order on all machines. |
| 269 local_sync_backend_folder = |
| 270 local_sync_backend_folder.Append(profile_->GetPath().BaseName()); |
| 271 local_sync_backend_folder = |
| 272 local_sync_backend_folder.Append(kLoopbackServerBackendFilename); |
| 273 #endif // defined(OS_WIN) |
| 274 |
| 275 return local_sync_backend_folder; |
| 276 } |
| 277 |
238 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { | 278 bookmarks::BookmarkModel* ChromeSyncClient::GetBookmarkModel() { |
239 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 279 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
240 return BookmarkModelFactory::GetForBrowserContext(profile_); | 280 return BookmarkModelFactory::GetForBrowserContext(profile_); |
241 } | 281 } |
242 | 282 |
243 favicon::FaviconService* ChromeSyncClient::GetFaviconService() { | 283 favicon::FaviconService* ChromeSyncClient::GetFaviconService() { |
244 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 284 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
245 return FaviconServiceFactory::GetForProfile( | 285 return FaviconServiceFactory::GetForProfile( |
246 profile_, ServiceAccessType::IMPLICIT_ACCESS); | 286 profile_, ServiceAccessType::IMPLICIT_ACCESS); |
247 } | 287 } |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 sync_service->RegisterDataTypeController( | 692 sync_service->RegisterDataTypeController( |
653 base::MakeUnique<SupervisedUserSyncDataTypeController>( | 693 base::MakeUnique<SupervisedUserSyncDataTypeController>( |
654 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); | 694 syncer::SUPERVISED_USER_SETTINGS, error_callback, this, profile_)); |
655 sync_service->RegisterDataTypeController( | 695 sync_service->RegisterDataTypeController( |
656 base::MakeUnique<SupervisedUserSyncDataTypeController>( | 696 base::MakeUnique<SupervisedUserSyncDataTypeController>( |
657 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); | 697 syncer::SUPERVISED_USER_WHITELISTS, error_callback, this, profile_)); |
658 #endif | 698 #endif |
659 } | 699 } |
660 | 700 |
661 } // namespace browser_sync | 701 } // namespace browser_sync |
OLD | NEW |