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

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

Issue 130813003: Create signin component and componentize TokenWebData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/sync/glue/sync_start_util.h" 11 #include "chrome/browser/sync/glue/sync_start_util.h"
12 #include "chrome/browser/ui/profile_error_dialog.h" 12 #include "chrome/browser/ui/profile_error_dialog.h"
13 #include "chrome/browser/webdata/autocomplete_syncable_service.h" 13 #include "chrome/browser/webdata/autocomplete_syncable_service.h"
14 #include "chrome/browser/webdata/autofill_profile_syncable_service.h" 14 #include "chrome/browser/webdata/autofill_profile_syncable_service.h"
15 #include "chrome/browser/webdata/keyword_table.h" 15 #include "chrome/browser/webdata/keyword_table.h"
16 #include "chrome/browser/webdata/logins_table.h" 16 #include "chrome/browser/webdata/logins_table.h"
17 #include "chrome/browser/webdata/token_service_table.h"
18 #include "chrome/browser/webdata/token_web_data.h"
19 #include "chrome/browser/webdata/web_apps_table.h" 17 #include "chrome/browser/webdata/web_apps_table.h"
20 #include "chrome/browser/webdata/web_data_service.h" 18 #include "chrome/browser/webdata/web_data_service.h"
21 #include "chrome/browser/webdata/web_intents_table.h" 19 #include "chrome/browser/webdata/web_intents_table.h"
22 #include "components/autofill/core/browser/autofill_country.h" 20 #include "components/autofill/core/browser/autofill_country.h"
23 #include "components/autofill/core/browser/webdata/autofill_table.h" 21 #include "components/autofill/core/browser/webdata/autofill_table.h"
24 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
25 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 23 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
24 #include "components/signin/core/webdata/token_service_table.h"
25 #include "components/signin/core/webdata/token_web_data.h"
26 #include "components/webdata/common/webdata_constants.h" 26 #include "components/webdata/common/webdata_constants.h"
27 #include "content/public/browser/browser_thread.h" 27 #include "content/public/browser/browser_thread.h"
28 #include "grit/chromium_strings.h" 28 #include "grit/chromium_strings.h"
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 30
31 using autofill::AutofillWebDataService; 31 using autofill::AutofillWebDataService;
32 using autofill::AutofillProfileSyncableService; 32 using autofill::AutofillProfileSyncableService;
33 using content::BrowserThread; 33 using content::BrowserThread;
34 34
35 namespace { 35 namespace {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); 99 scoped_ptr<WebDatabaseTable>(new WebIntentsTable()));
100 100
101 web_database_->LoadDatabase(); 101 web_database_->LoadDatabase();
102 102
103 autofill_web_data_ = new AutofillWebDataService( 103 autofill_web_data_ = new AutofillWebDataService(
104 web_database_, ui_thread, db_thread, base::Bind( 104 web_database_, ui_thread, db_thread, base::Bind(
105 &ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA)); 105 &ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA));
106 autofill_web_data_->Init(); 106 autofill_web_data_->Init();
107 107
108 token_web_data_ = new TokenWebData( 108 token_web_data_ = new TokenWebData(
109 web_database_, base::Bind(&ProfileErrorCallback, 109 web_database_, ui_thread, db_thread, base::Bind(
110 PROFILE_ERROR_DB_TOKEN_WEB_DATA)); 110 &ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA));
111 token_web_data_->Init(); 111 token_web_data_->Init();
112 112
113 web_data_ = new WebDataService( 113 web_data_ = new WebDataService(
114 web_database_, base::Bind(&ProfileErrorCallback, 114 web_database_, base::Bind(&ProfileErrorCallback,
115 PROFILE_ERROR_DB_WEB_DATA)); 115 PROFILE_ERROR_DB_WEB_DATA));
116 web_data_->Init(); 116 web_data_->Init();
117 117
118 autofill_web_data_->GetAutofillBackend( 118 autofill_web_data_->GetAutofillBackend(
119 base::Bind(&InitSyncableServicesOnDBThread, 119 base::Bind(&InitSyncableServicesOnDBThread,
120 autofill_web_data_, 120 autofill_web_data_,
(...skipping 18 matching lines...) Expand all
139 139
140 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { 140 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
141 return web_data_.get(); 141 return web_data_.get();
142 } 142 }
143 143
144 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { 144 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
145 return token_web_data_.get(); 145 return token_web_data_.get();
146 } 146 }
147 147
148 // static 148 // static
149 scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext(
150 content::BrowserContext* context) {
151 // For this service, the implicit/explicit distinction doesn't
152 // really matter; it's just used for a DCHECK. So we currently
153 // cheat and always say EXPLICIT_ACCESS.
154 WebDataServiceWrapper* wrapper =
155 WebDataServiceFactory::GetForProfile(
156 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
157 if (wrapper)
158 return wrapper->GetTokenWebData();
159 // |wrapper| can be NULL in Incognito mode.
160 return scoped_refptr<TokenWebData>(NULL);
161 }
162
163 // static
164 scoped_refptr<WebDataService> WebDataService::FromBrowserContext( 149 scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
165 content::BrowserContext* context) { 150 content::BrowserContext* context) {
166 // For this service, the implicit/explicit distinction doesn't 151 // For this service, the implicit/explicit distinction doesn't
167 // really matter; it's just used for a DCHECK. So we currently 152 // really matter; it's just used for a DCHECK. So we currently
168 // cheat and always say EXPLICIT_ACCESS. 153 // cheat and always say EXPLICIT_ACCESS.
169 WebDataServiceWrapper* wrapper = 154 WebDataServiceWrapper* wrapper =
170 WebDataServiceFactory::GetForProfile( 155 WebDataServiceFactory::GetForProfile(
171 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); 156 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
172 if (wrapper) 157 if (wrapper)
173 return wrapper->GetWebData(); 158 return wrapper->GetWebData();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 Profile::ServiceAccessType access_type) { 200 Profile::ServiceAccessType access_type) {
216 WebDataServiceWrapper* wrapper = 201 WebDataServiceWrapper* wrapper =
217 WebDataServiceFactory::GetForProfile(profile, access_type); 202 WebDataServiceFactory::GetForProfile(profile, access_type);
218 // |wrapper| can be NULL in Incognito mode. 203 // |wrapper| can be NULL in Incognito mode.
219 return wrapper ? 204 return wrapper ?
220 wrapper->GetAutofillWebData() : 205 wrapper->GetAutofillWebData() :
221 scoped_refptr<AutofillWebDataService>(NULL); 206 scoped_refptr<AutofillWebDataService>(NULL);
222 } 207 }
223 208
224 // static 209 // static
210 scoped_refptr<TokenWebData>
211 WebDataServiceFactory::GetTokenWebDataForProfile(
212 Profile* profile,
213 Profile::ServiceAccessType access_type) {
214 WebDataServiceWrapper* wrapper =
215 WebDataServiceFactory::GetForProfile(profile, access_type);
216 // |wrapper| can be NULL in Incognito mode.
217 return wrapper ? wrapper->GetTokenWebData()
218 : scoped_refptr<TokenWebData>(NULL);
219 }
220
221 // static
225 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { 222 WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
226 return Singleton<WebDataServiceFactory>::get(); 223 return Singleton<WebDataServiceFactory>::get();
227 } 224 }
228 225
229 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( 226 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse(
230 content::BrowserContext* context) const { 227 content::BrowserContext* context) const {
231 return chrome::GetBrowserContextRedirectedInIncognito(context); 228 return chrome::GetBrowserContextRedirectedInIncognito(context);
232 } 229 }
233 230
234 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( 231 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor(
235 content::BrowserContext* profile) const { 232 content::BrowserContext* profile) const {
236 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 233 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
237 } 234 }
238 235
239 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 236 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
240 return true; 237 return true;
241 } 238 }
OLDNEW
« no previous file with comments | « chrome/browser/webdata/web_data_service_factory.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698