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" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 web_data_service_ = | 144 web_data_service_ = |
145 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( | 145 ios::WebDataServiceFactory::GetAutofillWebDataForBrowserState( |
146 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 146 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); |
147 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here? | 147 // TODO(crbug.com/558320) Is EXPLICIT_ACCESS appropriate here? |
148 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState( | 148 password_store_ = IOSChromePasswordStoreFactory::GetForBrowserState( |
149 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); | 149 browser_state_, ServiceAccessType::EXPLICIT_ACCESS); |
150 | 150 |
151 // Component factory may already be set in tests. | 151 // Component factory may already be set in tests. |
152 if (!GetSyncApiComponentFactory()) { | 152 if (!GetSyncApiComponentFactory()) { |
153 const GURL sync_service_url = GetSyncServiceURL( | 153 const GURL sync_service_url = syncer::GetSyncServiceURL( |
154 *base::CommandLine::ForCurrentProcess(), ::GetChannel()); | 154 *base::CommandLine::ForCurrentProcess(), ::GetChannel()); |
155 ProfileOAuth2TokenService* token_service = | 155 ProfileOAuth2TokenService* token_service = |
156 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_); | 156 OAuth2TokenServiceFactory::GetForBrowserState(browser_state_); |
157 | 157 |
158 net::URLRequestContextGetter* url_request_context_getter = | 158 net::URLRequestContextGetter* url_request_context_getter = |
159 browser_state_->GetRequestContext(); | 159 browser_state_->GetRequestContext(); |
160 | 160 |
161 component_factory_.reset(new browser_sync::ProfileSyncComponentsFactoryImpl( | 161 component_factory_.reset(new browser_sync::ProfileSyncComponentsFactoryImpl( |
162 this, ::GetChannel(), ::GetVersionString(), | 162 this, ::GetChannel(), ::GetVersionString(), |
163 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, | 163 ui::GetDeviceFormFactor() == ui::DEVICE_FORM_FACTOR_TABLET, |
164 *base::CommandLine::ForCurrentProcess(), | 164 *base::CommandLine::ForCurrentProcess(), |
165 prefs::kSavingBrowserHistoryDisabled, sync_service_url, | 165 prefs::kSavingBrowserHistoryDisabled, sync_service_url, |
166 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), | 166 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), |
167 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), | 167 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), |
168 token_service, url_request_context_getter, web_data_service_, | 168 token_service, url_request_context_getter, web_data_service_, |
169 password_store_)); | 169 password_store_)); |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 sync_driver::SyncService* IOSChromeSyncClient::GetSyncService() { | 173 syncer::SyncService* IOSChromeSyncClient::GetSyncService() { |
174 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 174 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
175 return IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_); | 175 return IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state_); |
176 } | 176 } |
177 | 177 |
178 PrefService* IOSChromeSyncClient::GetPrefService() { | 178 PrefService* IOSChromeSyncClient::GetPrefService() { |
179 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 179 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
180 return browser_state_->GetPrefs(); | 180 return browser_state_->GetPrefs(); |
181 } | 181 } |
182 | 182 |
183 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() { | 183 bookmarks::BookmarkModel* IOSChromeSyncClient::GetBookmarkModel() { |
(...skipping 18 matching lines...) Expand all Loading... |
202 return autofill::PersonalDataManagerFactory::GetForBrowserState( | 202 return autofill::PersonalDataManagerFactory::GetForBrowserState( |
203 browser_state_); | 203 browser_state_); |
204 } | 204 } |
205 | 205 |
206 base::Closure IOSChromeSyncClient::GetPasswordStateChangedCallback() { | 206 base::Closure IOSChromeSyncClient::GetPasswordStateChangedCallback() { |
207 return base::Bind( | 207 return base::Bind( |
208 &IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged, | 208 &IOSChromePasswordStoreFactory::OnPasswordsSyncedStatePotentiallyChanged, |
209 base::Unretained(browser_state_)); | 209 base::Unretained(browser_state_)); |
210 } | 210 } |
211 | 211 |
212 sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod | 212 syncer::SyncApiComponentFactory::RegisterDataTypesMethod |
213 IOSChromeSyncClient::GetRegisterPlatformTypesCallback() { | 213 IOSChromeSyncClient::GetRegisterPlatformTypesCallback() { |
214 // The iOS port does not have any platform-specific datatypes. | 214 // The iOS port does not have any platform-specific datatypes. |
215 return sync_driver::SyncApiComponentFactory::RegisterDataTypesMethod(); | 215 return syncer::SyncApiComponentFactory::RegisterDataTypesMethod(); |
216 } | 216 } |
217 | 217 |
218 BookmarkUndoService* IOSChromeSyncClient::GetBookmarkUndoServiceIfExists() { | 218 BookmarkUndoService* IOSChromeSyncClient::GetBookmarkUndoServiceIfExists() { |
219 return ios::BookmarkUndoServiceFactory::GetForBrowserStateIfExists( | 219 return ios::BookmarkUndoServiceFactory::GetForBrowserStateIfExists( |
220 browser_state_); | 220 browser_state_); |
221 } | 221 } |
222 | 222 |
223 invalidation::InvalidationService* | 223 invalidation::InvalidationService* |
224 IOSChromeSyncClient::GetInvalidationService() { | 224 IOSChromeSyncClient::GetInvalidationService() { |
225 invalidation::ProfileInvalidationProvider* provider = | 225 invalidation::ProfileInvalidationProvider* provider = |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 case syncer::PASSWORDS: { | 320 case syncer::PASSWORDS: { |
321 return password_store_ ? password_store_->GetPasswordSyncableService() | 321 return password_store_ ? password_store_->GetPasswordSyncableService() |
322 : base::WeakPtr<syncer::SyncableService>(); | 322 : base::WeakPtr<syncer::SyncableService>(); |
323 } | 323 } |
324 default: | 324 default: |
325 NOTREACHED(); | 325 NOTREACHED(); |
326 return base::WeakPtr<syncer::SyncableService>(); | 326 return base::WeakPtr<syncer::SyncableService>(); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 base::WeakPtr<syncer_v2::ModelTypeService> | 330 base::WeakPtr<syncer::ModelTypeService> |
331 IOSChromeSyncClient::GetModelTypeServiceForType(syncer::ModelType type) { | 331 IOSChromeSyncClient::GetModelTypeServiceForType(syncer::ModelType type) { |
332 switch (type) { | 332 switch (type) { |
333 case syncer::DEVICE_INFO: | 333 case syncer::DEVICE_INFO: |
334 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( | 334 return IOSChromeProfileSyncServiceFactory::GetForBrowserState( |
335 browser_state_) | 335 browser_state_) |
336 ->GetDeviceInfoService() | 336 ->GetDeviceInfoService() |
337 ->AsWeakPtr(); | 337 ->AsWeakPtr(); |
338 default: | 338 default: |
339 NOTREACHED(); | 339 NOTREACHED(); |
340 return base::WeakPtr<syncer_v2::ModelTypeService>(); | 340 return base::WeakPtr<syncer::ModelTypeService>(); |
341 } | 341 } |
342 } | 342 } |
343 | 343 |
344 scoped_refptr<syncer::ModelSafeWorker> | 344 scoped_refptr<syncer::ModelSafeWorker> |
345 IOSChromeSyncClient::CreateModelWorkerForGroup( | 345 IOSChromeSyncClient::CreateModelWorkerForGroup( |
346 syncer::ModelSafeGroup group, | 346 syncer::ModelSafeGroup group, |
347 syncer::WorkerLoopDestructionObserver* observer) { | 347 syncer::WorkerLoopDestructionObserver* observer) { |
348 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 348 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
349 switch (group) { | 349 switch (group) { |
350 case syncer::GROUP_DB: | 350 case syncer::GROUP_DB: |
351 return new browser_sync::BrowserThreadModelWorker( | 351 return new syncer::BrowserThreadModelWorker( |
352 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), | 352 web::WebThread::GetTaskRunnerForThread(web::WebThread::DB), |
353 syncer::GROUP_DB, observer); | 353 syncer::GROUP_DB, observer); |
354 case syncer::GROUP_FILE: | 354 case syncer::GROUP_FILE: |
355 return new browser_sync::BrowserThreadModelWorker( | 355 return new syncer::BrowserThreadModelWorker( |
356 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), | 356 web::WebThread::GetTaskRunnerForThread(web::WebThread::FILE), |
357 syncer::GROUP_FILE, observer); | 357 syncer::GROUP_FILE, observer); |
358 case syncer::GROUP_UI: | 358 case syncer::GROUP_UI: |
359 return new browser_sync::UIModelWorker( | 359 return new syncer::UIModelWorker( |
360 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), observer); | 360 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), observer); |
361 case syncer::GROUP_PASSIVE: | 361 case syncer::GROUP_PASSIVE: |
362 return new syncer::PassiveModelWorker(observer); | 362 return new syncer::PassiveModelWorker(observer); |
363 case syncer::GROUP_HISTORY: { | 363 case syncer::GROUP_HISTORY: { |
364 history::HistoryService* history_service = GetHistoryService(); | 364 history::HistoryService* history_service = GetHistoryService(); |
365 if (!history_service) | 365 if (!history_service) |
366 return nullptr; | 366 return nullptr; |
367 return new browser_sync::HistoryModelWorker( | 367 return new browser_sync::HistoryModelWorker( |
368 history_service->AsWeakPtr(), | 368 history_service->AsWeakPtr(), |
369 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), observer); | 369 web::WebThread::GetTaskRunnerForThread(web::WebThread::UI), observer); |
370 } | 370 } |
371 case syncer::GROUP_PASSWORD: { | 371 case syncer::GROUP_PASSWORD: { |
372 if (!password_store_) | 372 if (!password_store_) |
373 return nullptr; | 373 return nullptr; |
374 return new browser_sync::PasswordModelWorker(password_store_, observer); | 374 return new browser_sync::PasswordModelWorker(password_store_, observer); |
375 } | 375 } |
376 default: | 376 default: |
377 return nullptr; | 377 return nullptr; |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 sync_driver::SyncApiComponentFactory* | 381 syncer::SyncApiComponentFactory* |
382 IOSChromeSyncClient::GetSyncApiComponentFactory() { | 382 IOSChromeSyncClient::GetSyncApiComponentFactory() { |
383 return component_factory_.get(); | 383 return component_factory_.get(); |
384 } | 384 } |
385 | 385 |
386 void IOSChromeSyncClient::SetSyncApiComponentFactoryForTesting( | 386 void IOSChromeSyncClient::SetSyncApiComponentFactoryForTesting( |
387 std::unique_ptr<sync_driver::SyncApiComponentFactory> component_factory) { | 387 std::unique_ptr<syncer::SyncApiComponentFactory> component_factory) { |
388 component_factory_ = std::move(component_factory); | 388 component_factory_ = std::move(component_factory); |
389 } | 389 } |
390 | 390 |
391 // static | 391 // static |
392 void IOSChromeSyncClient::GetDeviceInfoTrackers( | 392 void IOSChromeSyncClient::GetDeviceInfoTrackers( |
393 std::vector<const sync_driver::DeviceInfoTracker*>* trackers) { | 393 std::vector<const syncer::DeviceInfoTracker*>* trackers) { |
394 DCHECK(trackers); | 394 DCHECK(trackers); |
395 std::vector<ios::ChromeBrowserState*> browser_state_list = | 395 std::vector<ios::ChromeBrowserState*> browser_state_list = |
396 GetApplicationContext() | 396 GetApplicationContext() |
397 ->GetChromeBrowserStateManager() | 397 ->GetChromeBrowserStateManager() |
398 ->GetLoadedBrowserStates(); | 398 ->GetLoadedBrowserStates(); |
399 for (ios::ChromeBrowserState* browser_state : browser_state_list) { | 399 for (ios::ChromeBrowserState* browser_state : browser_state_list) { |
400 browser_sync::ProfileSyncService* profile_sync_service = | 400 browser_sync::ProfileSyncService* profile_sync_service = |
401 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); | 401 IOSChromeProfileSyncServiceFactory::GetForBrowserState(browser_state); |
402 if (profile_sync_service != nullptr) { | 402 if (profile_sync_service != nullptr) { |
403 const sync_driver::DeviceInfoTracker* tracker = | 403 const syncer::DeviceInfoTracker* tracker = |
404 profile_sync_service->GetDeviceInfoTracker(); | 404 profile_sync_service->GetDeviceInfoTracker(); |
405 if (tracker != nullptr) { | 405 if (tracker != nullptr) { |
406 trackers->push_back(tracker); | 406 trackers->push_back(tracker); |
407 } | 407 } |
408 } | 408 } |
409 } | 409 } |
410 } | 410 } |
OLD | NEW |