Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/webdata/web_data_service_factory.cc

Issue 14081043: Hook up Autofill Backend interface to SyncableServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/ui/profile_error_dialog.h" 11 #include "chrome/browser/ui/profile_error_dialog.h"
12 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 12 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
13 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 13 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
14 #include "chrome/browser/webdata/keyword_table.h" 14 #include "chrome/browser/webdata/keyword_table.h"
15 #include "chrome/browser/webdata/logins_table.h" 15 #include "chrome/browser/webdata/logins_table.h"
16 #include "chrome/browser/webdata/token_service_table.h" 16 #include "chrome/browser/webdata/token_service_table.h"
17 #include "chrome/browser/webdata/web_apps_table.h" 17 #include "chrome/browser/webdata/web_apps_table.h"
18 #include "chrome/browser/webdata/web_data_service.h" 18 #include "chrome/browser/webdata/web_data_service.h"
19 #include "chrome/browser/webdata/web_intents_table.h" 19 #include "chrome/browser/webdata/web_intents_table.h"
20 #include "components/autofill/browser/autofill_country.h" 20 #include "components/autofill/browser/autofill_country.h"
21 #include "components/autofill/browser/webdata/autofill_backend_delegate.h"
21 #include "components/autofill/browser/webdata/autofill_table.h" 22 #include "components/autofill/browser/webdata/autofill_table.h"
22 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 23 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
23 #include "components/webdata/common/webdata_constants.h" 24 #include "components/webdata/common/webdata_constants.h"
24 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
25 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 28
28 using autofill::AutofillWebDataService; 29 using autofill::AutofillWebDataService;
29 using content::BrowserThread; 30 using content::BrowserThread;
30 31
31 namespace { 32 namespace {
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 const std::string& app_locale,
42 const std::string& app_locale) { 43 autofill::AutofillWebDataService* autofill_web_data,
44 autofill::AutofillBackendDelegate* delegate) {
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(
50 autofill_web_data, delegate);
48 AutofillProfileSyncableService::CreateForWebDataService( 51 AutofillProfileSyncableService::CreateForWebDataService(
49 autofill_web_data, app_locale); 52 autofill_web_data, delegate, app_locale);
50 } 53 }
51 54
52 } // namespace 55 } // namespace
53 56
54 WebDataServiceWrapper::WebDataServiceWrapper() {} 57 WebDataServiceWrapper::WebDataServiceWrapper() {}
55 58
56 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { 59 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
57 base::FilePath path = profile->GetPath(); 60 base::FilePath path = profile->GetPath();
58 path = path.Append(kWebDataFilename); 61 path = path.Append(kWebDataFilename);
59 62
(...skipping 23 matching lines...) Expand all
83 web_database_->LoadDatabase(); 86 web_database_->LoadDatabase();
84 87
85 autofill_web_data_ = new AutofillWebDataService( 88 autofill_web_data_ = new AutofillWebDataService(
86 web_database_, base::Bind(&ProfileErrorCallback)); 89 web_database_, base::Bind(&ProfileErrorCallback));
87 autofill_web_data_->Init(); 90 autofill_web_data_->Init();
88 91
89 web_data_ = new WebDataService( 92 web_data_ = new WebDataService(
90 web_database_, base::Bind(&ProfileErrorCallback)); 93 web_database_, base::Bind(&ProfileErrorCallback));
91 web_data_->Init(); 94 web_data_->Init();
92 95
93 BrowserThread::PostTask( 96 autofill_web_data_->GetDelegateOnDB(
94 BrowserThread::DB, FROM_HERE,
95 base::Bind(&InitSyncableServicesOnDBThread, 97 base::Bind(&InitSyncableServicesOnDBThread,
96 autofill_web_data_, 98 g_browser_process->GetApplicationLocale(),
97 g_browser_process->GetApplicationLocale())); 99 autofill_web_data_));
98 } 100 }
99 101
100 WebDataServiceWrapper::~WebDataServiceWrapper() { 102 WebDataServiceWrapper::~WebDataServiceWrapper() {
101 } 103 }
102 104
103 void WebDataServiceWrapper::Shutdown() { 105 void WebDataServiceWrapper::Shutdown() {
104 autofill_web_data_->ShutdownOnUIThread(); 106 autofill_web_data_->ShutdownOnUIThread();
105 web_data_->ShutdownOnUIThread(); 107 web_data_->ShutdownOnUIThread();
106 web_database_->ShutdownDatabase(); 108 web_database_->ShutdownDatabase();
107 } 109 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 187 }
186 188
187 ProfileKeyedService* 189 ProfileKeyedService*
188 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const { 190 WebDataServiceFactory::BuildServiceInstanceFor(Profile* profile) const {
189 return new WebDataServiceWrapper(profile); 191 return new WebDataServiceWrapper(profile);
190 } 192 }
191 193
192 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 194 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
193 return true; 195 return true;
194 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698