| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webdata/web_data_service_factory.h" | 5 #include "chrome/browser/webdata/web_data_service_factory.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/profiles/profile_dependency_manager.h" | 10 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 11 #include "chrome/browser/sync/glue/sync_start_util.h" |
| 11 #include "chrome/browser/ui/profile_error_dialog.h" | 12 #include "chrome/browser/ui/profile_error_dialog.h" |
| 12 #include "chrome/browser/webdata/autocomplete_syncable_service.h" | 13 #include "chrome/browser/webdata/autocomplete_syncable_service.h" |
| 13 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" | 14 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" |
| 14 #include "chrome/browser/webdata/keyword_table.h" | 15 #include "chrome/browser/webdata/keyword_table.h" |
| 15 #include "chrome/browser/webdata/logins_table.h" | 16 #include "chrome/browser/webdata/logins_table.h" |
| 16 #include "chrome/browser/webdata/token_service_table.h" | 17 #include "chrome/browser/webdata/token_service_table.h" |
| 17 #include "chrome/browser/webdata/web_apps_table.h" | 18 #include "chrome/browser/webdata/web_apps_table.h" |
| 18 #include "chrome/browser/webdata/web_data_service.h" | 19 #include "chrome/browser/webdata/web_data_service.h" |
| 19 #include "chrome/browser/webdata/web_intents_table.h" | 20 #include "chrome/browser/webdata/web_intents_table.h" |
| 20 #include "components/autofill/browser/autofill_country.h" | 21 #include "components/autofill/browser/autofill_country.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 32 | 33 |
| 33 // Callback to show error dialog on profile load error. | 34 // Callback to show error dialog on profile load error. |
| 34 void ProfileErrorCallback(sql::InitStatus status) { | 35 void ProfileErrorCallback(sql::InitStatus status) { |
| 35 ShowProfileErrorDialog( | 36 ShowProfileErrorDialog( |
| 36 (status == sql::INIT_FAILURE) ? | 37 (status == sql::INIT_FAILURE) ? |
| 37 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); | 38 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); |
| 38 } | 39 } |
| 39 | 40 |
| 40 void InitSyncableServicesOnDBThread( | 41 void InitSyncableServicesOnDBThread( |
| 41 scoped_refptr<AutofillWebDataService> autofill_web_data, | 42 scoped_refptr<AutofillWebDataService> autofill_web_data, |
| 43 const syncer::SyncableService::StartSyncFlare& flare, |
| 42 const std::string& app_locale) { | 44 const std::string& app_locale) { |
| 43 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); | 45 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); |
| 44 | 46 |
| 45 // Currently only Autocomplete and Autofill profiles use the new Sync API, but | 47 // Currently only Autocomplete and Autofill profiles use the new Sync API, but |
| 46 // all the database data should migrate to this API over time. | 48 // all the database data should migrate to this API over time. |
| 47 AutocompleteSyncableService::CreateForWebDataService(autofill_web_data); | 49 AutocompleteSyncableService::CreateForWebDataService(autofill_web_data); |
| 50 AutocompleteSyncableService::FromWebDataService( |
| 51 autofill_web_data)->InjectStartSyncFlare(flare); |
| 48 AutofillProfileSyncableService::CreateForWebDataService( | 52 AutofillProfileSyncableService::CreateForWebDataService( |
| 49 autofill_web_data, app_locale); | 53 autofill_web_data, app_locale); |
| 50 } | 54 } |
| 51 | 55 |
| 52 } // namespace | 56 } // namespace |
| 53 | 57 |
| 54 WebDataServiceWrapper::WebDataServiceWrapper() {} | 58 WebDataServiceWrapper::WebDataServiceWrapper() {} |
| 55 | 59 |
| 56 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { | 60 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { |
| 57 base::FilePath path = profile->GetPath(); | 61 base::FilePath path = profile->GetPath(); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 87 autofill_web_data_->Init(); | 91 autofill_web_data_->Init(); |
| 88 | 92 |
| 89 web_data_ = new WebDataService( | 93 web_data_ = new WebDataService( |
| 90 web_database_, base::Bind(&ProfileErrorCallback)); | 94 web_database_, base::Bind(&ProfileErrorCallback)); |
| 91 web_data_->Init(); | 95 web_data_->Init(); |
| 92 | 96 |
| 93 BrowserThread::PostTask( | 97 BrowserThread::PostTask( |
| 94 BrowserThread::DB, FROM_HERE, | 98 BrowserThread::DB, FROM_HERE, |
| 95 base::Bind(&InitSyncableServicesOnDBThread, | 99 base::Bind(&InitSyncableServicesOnDBThread, |
| 96 autofill_web_data_, | 100 autofill_web_data_, |
| 101 sync_start_util::GetFlareForSyncableService(path), |
| 97 g_browser_process->GetApplicationLocale())); | 102 g_browser_process->GetApplicationLocale())); |
| 98 } | 103 } |
| 99 | 104 |
| 100 WebDataServiceWrapper::~WebDataServiceWrapper() { | 105 WebDataServiceWrapper::~WebDataServiceWrapper() { |
| 101 } | 106 } |
| 102 | 107 |
| 103 void WebDataServiceWrapper::Shutdown() { | 108 void WebDataServiceWrapper::Shutdown() { |
| 104 autofill_web_data_->ShutdownOnUIThread(); | 109 autofill_web_data_->ShutdownOnUIThread(); |
| 105 web_data_->ShutdownOnUIThread(); | 110 web_data_->ShutdownOnUIThread(); |
| 106 web_database_->ShutdownDatabase(); | 111 web_database_->ShutdownDatabase(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 } | 190 } |
| 186 | 191 |
| 187 ProfileKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( | 192 ProfileKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( |
| 188 content::BrowserContext* profile) const { | 193 content::BrowserContext* profile) const { |
| 189 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 194 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 190 } | 195 } |
| 191 | 196 |
| 192 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 197 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 193 return true; | 198 return true; |
| 194 } | 199 } |
| OLD | NEW |