| 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::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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 autofill_web_data_->Init(); | 93 autofill_web_data_->Init(); |
| 90 | 94 |
| 91 web_data_ = new WebDataService( | 95 web_data_ = new WebDataService( |
| 92 web_database_, base::Bind(&ProfileErrorCallback)); | 96 web_database_, base::Bind(&ProfileErrorCallback)); |
| 93 web_data_->Init(); | 97 web_data_->Init(); |
| 94 | 98 |
| 95 BrowserThread::PostTask( | 99 BrowserThread::PostTask( |
| 96 BrowserThread::DB, FROM_HERE, | 100 BrowserThread::DB, FROM_HERE, |
| 97 base::Bind(&InitSyncableServicesOnDBThread, | 101 base::Bind(&InitSyncableServicesOnDBThread, |
| 98 autofill_web_data_, | 102 autofill_web_data_, |
| 103 sync_start_util::GetFlareForSyncableService(path), |
| 99 g_browser_process->GetApplicationLocale())); | 104 g_browser_process->GetApplicationLocale())); |
| 100 } | 105 } |
| 101 | 106 |
| 102 WebDataServiceWrapper::~WebDataServiceWrapper() { | 107 WebDataServiceWrapper::~WebDataServiceWrapper() { |
| 103 } | 108 } |
| 104 | 109 |
| 105 void WebDataServiceWrapper::Shutdown() { | 110 void WebDataServiceWrapper::Shutdown() { |
| 106 autofill_web_data_->ShutdownOnUIThread(); | 111 autofill_web_data_->ShutdownOnUIThread(); |
| 107 web_data_->ShutdownOnUIThread(); | 112 web_data_->ShutdownOnUIThread(); |
| 108 web_database_->ShutdownDatabase(); | 113 web_database_->ShutdownDatabase(); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 } | 192 } |
| 188 | 193 |
| 189 ProfileKeyedService* | 194 ProfileKeyedService* |
| 190 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { | 195 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { |
| 191 return new WebDataServiceWrapper(profile); | 196 return new WebDataServiceWrapper(profile); |
| 192 } | 197 } |
| 193 | 198 |
| 194 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 199 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 195 return true; | 200 return true; |
| 196 } | 201 } |
| OLD | NEW |