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

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: Comments Created 7 years, 7 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/incognito_helpers.h" 10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h" 11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/browser/sync/glue/sync_start_util.h" 12 #include "chrome/browser/sync/glue/sync_start_util.h"
13 #include "chrome/browser/ui/profile_error_dialog.h" 13 #include "chrome/browser/ui/profile_error_dialog.h"
14 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 14 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
15 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 15 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
16 #include "chrome/browser/webdata/keyword_table.h" 16 #include "chrome/browser/webdata/keyword_table.h"
17 #include "chrome/browser/webdata/logins_table.h" 17 #include "chrome/browser/webdata/logins_table.h"
18 #include "chrome/browser/webdata/token_service_table.h" 18 #include "chrome/browser/webdata/token_service_table.h"
19 #include "chrome/browser/webdata/web_apps_table.h" 19 #include "chrome/browser/webdata/web_apps_table.h"
20 #include "chrome/browser/webdata/web_data_service.h" 20 #include "chrome/browser/webdata/web_data_service.h"
21 #include "chrome/browser/webdata/web_intents_table.h" 21 #include "chrome/browser/webdata/web_intents_table.h"
22 #include "components/autofill/browser/autofill_country.h" 22 #include "components/autofill/browser/autofill_country.h"
23 #include "components/autofill/browser/webdata/autofill_table.h" 23 #include "components/autofill/browser/webdata/autofill_table.h"
24 #include "components/autofill/browser/webdata/autofill_webdata_backend.h"
24 #include "components/autofill/browser/webdata/autofill_webdata_service.h" 25 #include "components/autofill/browser/webdata/autofill_webdata_service.h"
25 #include "components/webdata/common/webdata_constants.h" 26 #include "components/webdata/common/webdata_constants.h"
26 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
27 #include "grit/chromium_strings.h" 28 #include "grit/chromium_strings.h"
28 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
29 30
30 using autofill::AutofillWebDataService; 31 using autofill::AutofillWebDataService;
31 using content::BrowserThread; 32 using content::BrowserThread;
32 33
33 namespace { 34 namespace {
34 35
35 // Callback to show error dialog on profile load error. 36 // Callback to show error dialog on profile load error.
36 void ProfileErrorCallback(sql::InitStatus status) { 37 void ProfileErrorCallback(sql::InitStatus status) {
37 ShowProfileErrorDialog( 38 ShowProfileErrorDialog(
38 (status == sql::INIT_FAILURE) ? 39 (status == sql::INIT_FAILURE) ?
39 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); 40 IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
40 } 41 }
41 42
42 void InitSyncableServicesOnDBThread( 43 void InitSyncableServicesOnDBThread(
43 scoped_refptr<AutofillWebDataService> autofill_web_data, 44 scoped_refptr<AutofillWebDataService> autofill_web_data,
44 const syncer::SyncableService::StartSyncFlare& flare, 45 const syncer::SyncableService::StartSyncFlare& flare,
45 const std::string& app_locale) { 46 const std::string& app_locale,
47 autofill::AutofillWebDataBackend* autofill_backend) {
46 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
47 49
48 // Currently only Autocomplete and Autofill profiles use the new Sync API, but 50 // Currently only Autocomplete and Autofill profiles use the new Sync API, but
49 // all the database data should migrate to this API over time. 51 // all the database data should migrate to this API over time.
50 AutocompleteSyncableService::CreateForWebDataService(autofill_web_data); 52 AutocompleteSyncableService::CreateForWebDataServiceAndBackend(
53 autofill_web_data, autofill_backend);
51 AutocompleteSyncableService::FromWebDataService( 54 AutocompleteSyncableService::FromWebDataService(
52 autofill_web_data)->InjectStartSyncFlare(flare); 55 autofill_web_data)->InjectStartSyncFlare(flare);
53 AutofillProfileSyncableService::CreateForWebDataService( 56 AutofillProfileSyncableService::CreateForWebDataServiceAndBackend(
54 autofill_web_data, app_locale); 57 autofill_web_data, autofill_backend, app_locale);
55 } 58 }
56 59
57 } // namespace 60 } // namespace
58 61
59 WebDataServiceWrapper::WebDataServiceWrapper() {} 62 WebDataServiceWrapper::WebDataServiceWrapper() {}
60 63
61 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { 64 WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
62 base::FilePath path = profile->GetPath(); 65 base::FilePath path = profile->GetPath();
63 path = path.Append(kWebDataFilename); 66 path = path.Append(kWebDataFilename);
64 67
(...skipping 23 matching lines...) Expand all
88 web_database_->LoadDatabase(); 91 web_database_->LoadDatabase();
89 92
90 autofill_web_data_ = new AutofillWebDataService( 93 autofill_web_data_ = new AutofillWebDataService(
91 web_database_, base::Bind(&ProfileErrorCallback)); 94 web_database_, base::Bind(&ProfileErrorCallback));
92 autofill_web_data_->Init(); 95 autofill_web_data_->Init();
93 96
94 web_data_ = new WebDataService( 97 web_data_ = new WebDataService(
95 web_database_, base::Bind(&ProfileErrorCallback)); 98 web_database_, base::Bind(&ProfileErrorCallback));
96 web_data_->Init(); 99 web_data_->Init();
97 100
98 BrowserThread::PostTask( 101 autofill_web_data_->GetAutofillBackend(
99 BrowserThread::DB, FROM_HERE,
100 base::Bind(&InitSyncableServicesOnDBThread, 102 base::Bind(&InitSyncableServicesOnDBThread,
101 autofill_web_data_, 103 autofill_web_data_,
102 sync_start_util::GetFlareForSyncableService(path), 104 sync_start_util::GetFlareForSyncableService(path),
103 g_browser_process->GetApplicationLocale())); 105 g_browser_process->GetApplicationLocale()));
104 } 106 }
105 107
106 WebDataServiceWrapper::~WebDataServiceWrapper() { 108 WebDataServiceWrapper::~WebDataServiceWrapper() {
107 } 109 }
108 110
109 void WebDataServiceWrapper::Shutdown() { 111 void WebDataServiceWrapper::Shutdown() {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 194 }
193 195
194 ProfileKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( 196 ProfileKeyedService* WebDataServiceFactory::BuildServiceInstanceFor(
195 content::BrowserContext* profile) const { 197 content::BrowserContext* profile) const {
196 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 198 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
197 } 199 }
198 200
199 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 201 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
200 return true; 202 return true;
201 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698