| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/webdata_services/web_data_service_wrapper.h" | 5 #include "components/webdata_services/web_data_service_wrapper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/feature_list.h" |
| 9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 12 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "components/autofill/core/browser/webdata/autocomplete_sync_bridge.h" |
| 13 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" | 15 #include "components/autofill/core/browser/webdata/autocomplete_syncable_service
.h" |
| 14 #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" |
| 15 #include "components/autofill/core/browser/webdata/autofill_table.h" | 17 #include "components/autofill/core/browser/webdata/autofill_table.h" |
| 16 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" | 18 #include "components/autofill/core/browser/webdata/autofill_wallet_metadata_sync
able_service.h" |
| 17 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" | 19 #include "components/autofill/core/browser/webdata/autofill_wallet_syncable_serv
ice.h" |
| 18 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 20 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
| 19 #include "components/password_manager/core/browser/webdata/logins_table.h" | 21 #include "components/password_manager/core/browser/webdata/logins_table.h" |
| 20 #include "components/search_engines/keyword_table.h" | 22 #include "components/search_engines/keyword_table.h" |
| 21 #include "components/search_engines/keyword_web_data_service.h" | 23 #include "components/search_engines/keyword_web_data_service.h" |
| 22 #include "components/signin/core/browser/webdata/token_service_table.h" | 24 #include "components/signin/core/browser/webdata/token_service_table.h" |
| 23 #include "components/signin/core/browser/webdata/token_web_data.h" | 25 #include "components/signin/core/browser/webdata/token_web_data.h" |
| 26 #include "components/sync/driver/sync_driver_switches.h" |
| 24 #include "components/webdata/common/web_database_service.h" | 27 #include "components/webdata/common/web_database_service.h" |
| 25 #include "components/webdata/common/webdata_constants.h" | 28 #include "components/webdata/common/webdata_constants.h" |
| 26 | 29 |
| 27 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 28 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" | 31 #include "components/password_manager/core/browser/webdata/password_web_data_ser
vice_win.h" |
| 29 #endif | 32 #endif |
| 30 | 33 |
| 31 namespace { | 34 namespace { |
| 32 | 35 |
| 33 void InitSyncableServicesOnDBThread( | 36 void InitSyncableServicesOnDBThread( |
| 34 scoped_refptr<base::SingleThreadTaskRunner> db_thread, | 37 scoped_refptr<base::SingleThreadTaskRunner> db_thread, |
| 35 const syncer::SyncableService::StartSyncFlare& sync_flare, | 38 const syncer::SyncableService::StartSyncFlare& sync_flare, |
| 36 const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data, | 39 const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data, |
| 37 const base::FilePath& context_path, | 40 const base::FilePath& context_path, |
| 38 const std::string& app_locale, | 41 const std::string& app_locale, |
| 39 autofill::AutofillWebDataBackend* autofill_backend) { | 42 autofill::AutofillWebDataBackend* autofill_backend) { |
| 40 DCHECK(db_thread->BelongsToCurrentThread()); | 43 DCHECK(db_thread->BelongsToCurrentThread()); |
| 41 | 44 |
| 42 // Currently only Autocomplete and Autofill profiles use the new Sync API, but | 45 // Currently only Autocomplete and Autofill profiles use the new Sync API, but |
| 43 // all the database data should migrate to this API over time. | 46 // all the database data should migrate to this API over time. |
| 44 autofill::AutocompleteSyncableService::CreateForWebDataServiceAndBackend( | 47 if (base::FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { |
| 45 autofill_web_data.get(), autofill_backend); | 48 autofill::AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( |
| 46 autofill::AutocompleteSyncableService::FromWebDataService( | 49 autofill_web_data.get(), autofill_backend); |
| 47 autofill_web_data.get())->InjectStartSyncFlare(sync_flare); | 50 } else { |
| 51 autofill::AutocompleteSyncableService::CreateForWebDataServiceAndBackend( |
| 52 autofill_web_data.get(), autofill_backend); |
| 53 autofill::AutocompleteSyncableService::FromWebDataService( |
| 54 autofill_web_data.get()) |
| 55 ->InjectStartSyncFlare(sync_flare); |
| 56 } |
| 48 | 57 |
| 49 autofill::AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( | 58 autofill::AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( |
| 50 autofill_web_data.get(), autofill_backend, app_locale); | 59 autofill_web_data.get(), autofill_backend, app_locale); |
| 51 autofill::AutofillWalletSyncableService::CreateForWebDataServiceAndBackend( | 60 autofill::AutofillWalletSyncableService::CreateForWebDataServiceAndBackend( |
| 52 autofill_web_data.get(), autofill_backend, app_locale); | 61 autofill_web_data.get(), autofill_backend, app_locale); |
| 53 autofill::AutofillWalletMetadataSyncableService:: | 62 autofill::AutofillWalletMetadataSyncableService:: |
| 54 CreateForWebDataServiceAndBackend(autofill_web_data.get(), | 63 CreateForWebDataServiceAndBackend(autofill_web_data.get(), |
| 55 autofill_backend, app_locale); | 64 autofill_backend, app_locale); |
| 56 | 65 |
| 57 autofill::AutofillProfileSyncableService::FromWebDataService( | 66 autofill::AutofillProfileSyncableService::FromWebDataService( |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { | 150 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { |
| 142 return token_web_data_.get(); | 151 return token_web_data_.get(); |
| 143 } | 152 } |
| 144 | 153 |
| 145 #if defined(OS_WIN) | 154 #if defined(OS_WIN) |
| 146 scoped_refptr<PasswordWebDataService> | 155 scoped_refptr<PasswordWebDataService> |
| 147 WebDataServiceWrapper::GetPasswordWebData() { | 156 WebDataServiceWrapper::GetPasswordWebData() { |
| 148 return password_web_data_.get(); | 157 return password_web_data_.get(); |
| 149 } | 158 } |
| 150 #endif | 159 #endif |
| OLD | NEW |