| 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/feature_list.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 #endif | 32 #endif |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 void InitSyncableServicesOnDBThread( | 36 void InitSyncableServicesOnDBThread( |
| 37 scoped_refptr<base::SingleThreadTaskRunner> db_thread, | 37 scoped_refptr<base::SingleThreadTaskRunner> db_thread, |
| 38 const syncer::SyncableService::StartSyncFlare& sync_flare, | 38 const syncer::SyncableService::StartSyncFlare& sync_flare, |
| 39 const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data, | 39 const scoped_refptr<autofill::AutofillWebDataService>& autofill_web_data, |
| 40 const base::FilePath& context_path, | 40 const base::FilePath& context_path, |
| 41 const std::string& app_locale, | 41 const std::string& app_locale, |
| 42 version_info::Channel channel, |
| 42 autofill::AutofillWebDataBackend* autofill_backend) { | 43 autofill::AutofillWebDataBackend* autofill_backend) { |
| 43 DCHECK(db_thread->BelongsToCurrentThread()); | 44 DCHECK(db_thread->BelongsToCurrentThread()); |
| 44 | 45 |
| 45 // Currently only Autocomplete and Autofill profiles use the new Sync API, but | 46 // Currently only Autocomplete and Autofill profiles use the new Sync API, but |
| 46 // all the database data should migrate to this API over time. | 47 // all the database data should migrate to this API over time. |
| 47 if (base::FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { | 48 if (base::FeatureList::IsEnabled(switches::kSyncUSSAutocomplete)) { |
| 48 autofill::AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( | 49 autofill::AutocompleteSyncBridge::CreateForWebDataServiceAndBackend( |
| 49 autofill_web_data.get(), autofill_backend); | 50 autofill_web_data.get(), autofill_backend, channel); |
| 50 } else { | 51 } else { |
| 51 autofill::AutocompleteSyncableService::CreateForWebDataServiceAndBackend( | 52 autofill::AutocompleteSyncableService::CreateForWebDataServiceAndBackend( |
| 52 autofill_web_data.get(), autofill_backend); | 53 autofill_web_data.get(), autofill_backend); |
| 53 autofill::AutocompleteSyncableService::FromWebDataService( | 54 autofill::AutocompleteSyncableService::FromWebDataService( |
| 54 autofill_web_data.get()) | 55 autofill_web_data.get()) |
| 55 ->InjectStartSyncFlare(sync_flare); | 56 ->InjectStartSyncFlare(sync_flare); |
| 56 } | 57 } |
| 57 | 58 |
| 58 autofill::AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( | 59 autofill::AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( |
| 59 autofill_web_data.get(), autofill_backend, app_locale); | 60 autofill_web_data.get(), autofill_backend, app_locale); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 73 | 74 |
| 74 WebDataServiceWrapper::WebDataServiceWrapper() { | 75 WebDataServiceWrapper::WebDataServiceWrapper() { |
| 75 } | 76 } |
| 76 | 77 |
| 77 WebDataServiceWrapper::WebDataServiceWrapper( | 78 WebDataServiceWrapper::WebDataServiceWrapper( |
| 78 const base::FilePath& context_path, | 79 const base::FilePath& context_path, |
| 79 const std::string& application_locale, | 80 const std::string& application_locale, |
| 80 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, | 81 const scoped_refptr<base::SingleThreadTaskRunner>& ui_thread, |
| 81 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, | 82 const scoped_refptr<base::SingleThreadTaskRunner>& db_thread, |
| 82 const syncer::SyncableService::StartSyncFlare& flare, | 83 const syncer::SyncableService::StartSyncFlare& flare, |
| 83 const ShowErrorCallback& show_error_callback) { | 84 const ShowErrorCallback& show_error_callback, |
| 85 version_info::Channel channel) { |
| 84 base::FilePath path = context_path.Append(kWebDataFilename); | 86 base::FilePath path = context_path.Append(kWebDataFilename); |
| 85 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); | 87 web_database_ = new WebDatabaseService(path, ui_thread, db_thread); |
| 86 | 88 |
| 87 // All tables objects that participate in managing the database must | 89 // All tables objects that participate in managing the database must |
| 88 // be added here. | 90 // be added here. |
| 89 web_database_->AddTable(base::WrapUnique(new autofill::AutofillTable)); | 91 web_database_->AddTable(base::WrapUnique(new autofill::AutofillTable)); |
| 90 web_database_->AddTable(base::WrapUnique(new KeywordTable)); | 92 web_database_->AddTable(base::WrapUnique(new KeywordTable)); |
| 91 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password | 93 // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password |
| 92 // access, but for now, we still create it on all platforms since it deletes | 94 // access, but for now, we still create it on all platforms since it deletes |
| 93 // the old logins table. We can remove this after a while, e.g. in M22 or so. | 95 // the old logins table. We can remove this after a while, e.g. in M22 or so. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 110 base::Bind(show_error_callback, ERROR_LOADING_TOKEN)); | 112 base::Bind(show_error_callback, ERROR_LOADING_TOKEN)); |
| 111 token_web_data_->Init(); | 113 token_web_data_->Init(); |
| 112 | 114 |
| 113 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
| 114 password_web_data_ = new PasswordWebDataService( | 116 password_web_data_ = new PasswordWebDataService( |
| 115 web_database_, ui_thread, | 117 web_database_, ui_thread, |
| 116 base::Bind(show_error_callback, ERROR_LOADING_PASSWORD)); | 118 base::Bind(show_error_callback, ERROR_LOADING_PASSWORD)); |
| 117 password_web_data_->Init(); | 119 password_web_data_->Init(); |
| 118 #endif | 120 #endif |
| 119 | 121 |
| 120 autofill_web_data_->GetAutofillBackend( | 122 autofill_web_data_->GetAutofillBackend(base::Bind( |
| 121 base::Bind(&InitSyncableServicesOnDBThread, db_thread, flare, | 123 &InitSyncableServicesOnDBThread, db_thread, flare, autofill_web_data_, |
| 122 autofill_web_data_, context_path, application_locale)); | 124 context_path, application_locale, channel)); |
| 123 } | 125 } |
| 124 | 126 |
| 125 WebDataServiceWrapper::~WebDataServiceWrapper() { | 127 WebDataServiceWrapper::~WebDataServiceWrapper() { |
| 126 } | 128 } |
| 127 | 129 |
| 128 void WebDataServiceWrapper::Shutdown() { | 130 void WebDataServiceWrapper::Shutdown() { |
| 129 autofill_web_data_->ShutdownOnUIThread(); | 131 autofill_web_data_->ShutdownOnUIThread(); |
| 130 keyword_web_data_->ShutdownOnUIThread(); | 132 keyword_web_data_->ShutdownOnUIThread(); |
| 131 token_web_data_->ShutdownOnUIThread(); | 133 token_web_data_->ShutdownOnUIThread(); |
| 132 | 134 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 150 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { | 152 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { |
| 151 return token_web_data_.get(); | 153 return token_web_data_.get(); |
| 152 } | 154 } |
| 153 | 155 |
| 154 #if defined(OS_WIN) | 156 #if defined(OS_WIN) |
| 155 scoped_refptr<PasswordWebDataService> | 157 scoped_refptr<PasswordWebDataService> |
| 156 WebDataServiceWrapper::GetPasswordWebData() { | 158 WebDataServiceWrapper::GetPasswordWebData() { |
| 157 return password_web_data_.get(); | 159 return password_web_data_.get(); |
| 158 } | 160 } |
| 159 #endif | 161 #endif |
| OLD | NEW |