| 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 "ios/chrome/browser/sync/ios_chrome_sync_client.h" | 5 #include "ios/chrome/browser/sync/ios_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/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" | 14 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" |
| 15 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 15 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" | 16 #include "components/autofill/core/browser/webdata/autofill_profile_syncable_ser
vice.h" |
| 17 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" | 17 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" |
| 18 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" | 18 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" |
| 19 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 19 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 20 #include "components/browser_sync/browser_sync_switches.h" | 20 #include "components/browser_sync/browser_sync_switches.h" |
| 21 #include "components/browser_sync/profile_sync_components_factory_impl.h" | 21 #include "components/browser_sync/profile_sync_components_factory_impl.h" |
| 22 #include "components/browser_sync/profile_sync_service.h" | 22 #include "components/browser_sync/profile_sync_service.h" |
| 23 #include "components/dom_distiller/core/dom_distiller_service.h" | 23 #include "components/dom_distiller/core/dom_distiller_service.h" |
| 24 #include "components/history/core/browser/history_model_worker.h" | 24 #include "components/history/core/browser/history_model_worker.h" |
| 25 #include "components/history/core/browser/history_service.h" | 25 #include "components/history/core/browser/history_service.h" |
| 26 #include "components/history/core/browser/typed_url_sync_bridge.h" |
| 27 #include "components/history/core/browser/typed_url_syncable_service.h" |
| 26 #include "components/invalidation/impl/profile_invalidation_provider.h" | 28 #include "components/invalidation/impl/profile_invalidation_provider.h" |
| 27 #include "components/keyed_service/core/service_access_type.h" | 29 #include "components/keyed_service/core/service_access_type.h" |
| 28 #include "components/password_manager/core/browser/password_store.h" | 30 #include "components/password_manager/core/browser/password_store.h" |
| 29 #include "components/password_manager/sync/browser/password_model_worker.h" | 31 #include "components/password_manager/sync/browser/password_model_worker.h" |
| 30 #include "components/reading_list/core/reading_list_model.h" | 32 #include "components/reading_list/core/reading_list_model.h" |
| 31 #include "components/search_engines/search_engine_data_type_controller.h" | 33 #include "components/search_engines/search_engine_data_type_controller.h" |
| 32 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 34 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| 33 #include "components/sync/base/report_unrecoverable_error.h" | 35 #include "components/sync/base/report_unrecoverable_error.h" |
| 34 #include "components/sync/driver/sync_api_component_factory.h" | 36 #include "components/sync/driver/sync_api_component_factory.h" |
| 35 #include "components/sync/driver/sync_util.h" | 37 #include "components/sync/driver/sync_util.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 131 |
| 130 // SyncSessionsClient implementation. | 132 // SyncSessionsClient implementation. |
| 131 bookmarks::BookmarkModel* GetBookmarkModel() override { | 133 bookmarks::BookmarkModel* GetBookmarkModel() override { |
| 132 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 134 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 133 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); | 135 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); |
| 134 } | 136 } |
| 135 | 137 |
| 136 favicon::FaviconService* GetFaviconService() override { | 138 favicon::FaviconService* GetFaviconService() override { |
| 137 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 139 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 138 return ios::FaviconServiceFactory::GetForBrowserState( | 140 return ios::FaviconServiceFactory::GetForBrowserState( |
| 139 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 141 browser_state_, ServiceAccessType::IMPLICIT_ACCESS); |
| 140 } | 142 } |
| 141 | 143 |
| 142 history::HistoryService* GetHistoryService() override { | 144 history::HistoryService* GetHistoryService() override { |
| 143 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 145 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 144 return ios::HistoryServiceFactory::GetForBrowserState( | 146 return ios::HistoryServiceFactory::GetForBrowserState( |
| 145 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 147 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); |
| 146 } | 148 } |
| 147 | 149 |
| 148 bool ShouldSyncURL(const GURL& url) const override { | 150 bool ShouldSyncURL(const GURL& url) const override { |
| 149 if (url == GURL(kChromeUIHistoryURL)) { | 151 if (url == GURL(kChromeUIHistoryURL)) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 base::MakeUnique<SyncSessionsClientImpl>(browser_state)), | 185 base::MakeUnique<SyncSessionsClientImpl>(browser_state)), |
| 184 weak_ptr_factory_(this) {} | 186 weak_ptr_factory_(this) {} |
| 185 | 187 |
| 186 IOSChromeSyncClient::~IOSChromeSyncClient() {} | 188 IOSChromeSyncClient::~IOSChromeSyncClient() {} |
| 187 | 189 |
| 188 void IOSChromeSyncClient::Initialize() { | 190 void IOSChromeSyncClient::Initialize() { |
| 189 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 191 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 190 | 192 |
| 191 web_data_service_ = | 193 web_data_service_ = |
| 192 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( | 194 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( |
| 193 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 195 browser_state_, ServiceAccessType::IMPLICIT_ACCESS); |
| 194 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here? | |
| 195 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState( | 196 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState( |
| 196 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 197 browser_state_, ServiceAccessType::IMPLICIT_ACCESS); |
| 197 | 198 |
| 198 // Component factory may already be set in tests. | 199 // Component factory may already be set in tests. |
| 199 if (!GetSyncApiComponentFactory()) { | 200 if (!GetSyncApiComponentFactory()) { |
| 200 const GURL sync_service_url = syncer::GetSyncServiceURL( | 201 const GURL sync_service_url = syncer::GetSyncServiceURL( |
| 201 *base::CommandLine::ForCurrentProcess(), ::GetChannel()); | 202 *base::CommandLine::ForCurrentProcess(), ::GetChannel()); |
| 202 ProfileOAuth2TokenService* token_service = | 203 ProfileOAuth2TokenService* token_service = |
| 203 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_); | 204 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_); |
| 204 | 205 |
| 205 net::URLRequestContextGetter* url_request_context_getter = | 206 net::URLRequestContextGetter* url_request_context_getter = |
| 206 browser_state_->GetRequestContext(); | 207 browser_state_->GetRequestContext(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 236 } | 237 } |
| 237 | 238 |
| 238 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() { | 239 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() { |
| 239 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 240 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 240 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); | 241 return ios::BookmarkModelFactory::GetForBrowserState(browser_state_); |
| 241 } | 242 } |
| 242 | 243 |
| 243 favicon::FaviconService* IOSChromeSyncClient::GetFaviconService() { | 244 favicon::FaviconService* IOSChromeSyncClient::GetFaviconService() { |
| 244 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 245 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 245 return ios::FaviconServiceFactory::GetForBrowserState( | 246 return ios::FaviconServiceFactory::GetForBrowserState( |
| 246 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 247 browser_state_, ServiceAccessType::IMPLICIT_ACCESS); |
| 247 } | 248 } |
| 248 | 249 |
| 249 history::HistoryService* IOSChromeSyncClient::GetHistoryService() { | 250 history::HistoryService* IOSChromeSyncClient::GetHistoryService() { |
| 250 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 251 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 251 return ios::HistoryServiceFactory::GetForBrowserState( | 252 return ios::HistoryServiceFactory::GetForBrowserState( |
| 252 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 253 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); |
| 253 } | 254 } |
| 254 | 255 |
| 255 bool IOSChromeSyncClient::HasPasswordStore() { | 256 bool IOSChromeSyncClient::HasPasswordStore() { |
| 256 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 257 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 ->AsWeakPtr(); | 386 ->AsWeakPtr(); |
| 386 case syncer::READING_LIST: { | 387 case syncer::READING_LIST: { |
| 387 ReadingListModel* reading_list_model = | 388 ReadingListModel* reading_list_model = |
| 388 ReadingListModelFactory::GetForBrowserState(browser_state_); | 389 ReadingListModelFactory::GetForBrowserState(browser_state_); |
| 389 return reading_list_model->GetModelTypeSyncBridge()->AsWeakPtr(); | 390 return reading_list_model->GetModelTypeSyncBridge()->AsWeakPtr(); |
| 390 } | 391 } |
| 391 case syncer::AUTOFILL: | 392 case syncer::AUTOFILL: |
| 392 return autofill::AutocompleteSyncBridge::FromWebDataService( | 393 return autofill::AutocompleteSyncBridge::FromWebDataService( |
| 393 web_data_service_.get()) | 394 web_data_service_.get()) |
| 394 ->AsWeakPtr(); | 395 ->AsWeakPtr(); |
| 396 case syncer::TYPED_URLS: |
| 397 // TODO(gangwu):implement TypedURLSyncBridge and return real |
| 398 // TypedURLSyncBridge here. |
| 399 return base::WeakPtr<syncer::ModelTypeSyncBridge>(); |
| 395 default: | 400 default: |
| 396 NOTREACHED(); | 401 NOTREACHED(); |
| 397 return base::WeakPtr<syncer::ModelTypeSyncBridge>(); | 402 return base::WeakPtr<syncer::ModelTypeSyncBridge>(); |
| 398 } | 403 } |
| 399 } | 404 } |
| 400 | 405 |
| 401 scoped_refptr<syncer::ModelSafeWorker> | 406 scoped_refptr<syncer::ModelSafeWorker> |
| 402 IOSChromeSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) { | 407 IOSChromeSyncClient::CreateModelWorkerForGroup(syncer::ModelSafeGroup group) { |
| 403 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 408 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
| 404 switch (group) { | 409 switch (group) { |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); | 461 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); |
| 457 if (profile_sync_service != nullptr) { | 462 if (profile_sync_service != nullptr) { |
| 458 const syncer::DeviceInfoTracker* tracker = | 463 const syncer::DeviceInfoTracker* tracker = |
| 459 profile_sync_service->GetDeviceInfoTracker(); | 464 profile_sync_service->GetDeviceInfoTracker(); |
| 460 if (tracker != nullptr) { | 465 if (tracker != nullptr) { |
| 461 trackers->push_back(tracker); | 466 trackers->push_back(tracker); |
| 462 } | 467 } |
| 463 } | 468 } |
| 464 } | 469 } |
| 465 } | 470 } |
| OLD | NEW |