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

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

Issue 129253003: Revert of 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"
17 #include "chrome/browser/webdata/web_apps_table.h" 19 #include "chrome/browser/webdata/web_apps_table.h"
18 #include "chrome/browser/webdata/web_data_service.h" 20 #include "chrome/browser/webdata/web_data_service.h"
19 #include "chrome/browser/webdata/web_intents_table.h" 21 #include "chrome/browser/webdata/web_intents_table.h"
20 #include "components/autofill/core/browser/autofill_country.h" 22 #include "components/autofill/core/browser/autofill_country.h"
21 #include "components/autofill/core/browser/webdata/autofill_table.h" 23 #include "components/autofill/core/browser/webdata/autofill_table.h"
22 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" 24 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
23 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 25 #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 content::BrowserThread; 32 using content::BrowserThread;
33 33
34 namespace { 34 namespace {
35 35
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 scoped_ptr<WebDatabaseTable>(new WebIntentsTable())); 98 scoped_ptr<WebDatabaseTable>(new WebIntentsTable()));
99 99
100 web_database_->LoadDatabase(); 100 web_database_->LoadDatabase();
101 101
102 autofill_web_data_ = new AutofillWebDataService( 102 autofill_web_data_ = new AutofillWebDataService(
103 web_database_, ui_thread, db_thread, base::Bind( 103 web_database_, ui_thread, db_thread, base::Bind(
104 &ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA)); 104 &ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA));
105 autofill_web_data_->Init(); 105 autofill_web_data_->Init();
106 106
107 token_web_data_ = new TokenWebData( 107 token_web_data_ = new TokenWebData(
108 web_database_, ui_thread, db_thread, base::Bind( 108 web_database_, base::Bind(&ProfileErrorCallback,
109 &ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA)); 109 PROFILE_ERROR_DB_TOKEN_WEB_DATA));
110 token_web_data_->Init(); 110 token_web_data_->Init();
111 111
112 web_data_ = new WebDataService( 112 web_data_ = new WebDataService(
113 web_database_, base::Bind(&ProfileErrorCallback, 113 web_database_, base::Bind(&ProfileErrorCallback,
114 PROFILE_ERROR_DB_WEB_DATA)); 114 PROFILE_ERROR_DB_WEB_DATA));
115 web_data_->Init(); 115 web_data_->Init();
116 116
117 autofill_web_data_->GetAutofillBackend( 117 autofill_web_data_->GetAutofillBackend(
118 base::Bind(&InitSyncableServicesOnDBThread, 118 base::Bind(&InitSyncableServicesOnDBThread,
119 autofill_web_data_, 119 autofill_web_data_,
(...skipping 18 matching lines...) Expand all
138 138
139 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { 139 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
140 return web_data_.get(); 140 return web_data_.get();
141 } 141 }
142 142
143 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { 143 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
144 return token_web_data_.get(); 144 return token_web_data_.get();
145 } 145 }
146 146
147 // static 147 // static
148 scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext(
149 content::BrowserContext* context) {
150 // For this service, the implicit/explicit distinction doesn't
151 // really matter; it's just used for a DCHECK. So we currently
152 // cheat and always say EXPLICIT_ACCESS.
153 WebDataServiceWrapper* wrapper =
154 WebDataServiceFactory::GetForProfile(
155 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
156 if (wrapper)
157 return wrapper->GetTokenWebData();
158 // |wrapper| can be NULL in Incognito mode.
159 return scoped_refptr<TokenWebData>(NULL);
160 }
161
162 // static
148 scoped_refptr<WebDataService> WebDataService::FromBrowserContext( 163 scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
149 content::BrowserContext* context) { 164 content::BrowserContext* context) {
150 // For this service, the implicit/explicit distinction doesn't 165 // For this service, the implicit/explicit distinction doesn't
151 // really matter; it's just used for a DCHECK. So we currently 166 // really matter; it's just used for a DCHECK. So we currently
152 // cheat and always say EXPLICIT_ACCESS. 167 // cheat and always say EXPLICIT_ACCESS.
153 WebDataServiceWrapper* wrapper = 168 WebDataServiceWrapper* wrapper =
154 WebDataServiceFactory::GetForProfile( 169 WebDataServiceFactory::GetForProfile(
155 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); 170 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
156 if (wrapper) 171 if (wrapper)
157 return wrapper->GetWebData(); 172 return wrapper->GetWebData();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Profile::ServiceAccessType access_type) { 214 Profile::ServiceAccessType access_type) {
200 WebDataServiceWrapper* wrapper = 215 WebDataServiceWrapper* wrapper =
201 WebDataServiceFactory::GetForProfile(profile, access_type); 216 WebDataServiceFactory::GetForProfile(profile, access_type);
202 // |wrapper| can be NULL in Incognito mode. 217 // |wrapper| can be NULL in Incognito mode.
203 return wrapper ? 218 return wrapper ?
204 wrapper->GetAutofillWebData() : 219 wrapper->GetAutofillWebData() :
205 scoped_refptr<AutofillWebDataService>(NULL); 220 scoped_refptr<AutofillWebDataService>(NULL);
206 } 221 }
207 222
208 // static 223 // static
209 scoped_refptr<TokenWebData>
210 WebDataServiceFactory::GetTokenWebDataForProfile(
211 Profile* profile,
212 Profile::ServiceAccessType access_type) {
213 WebDataServiceWrapper* wrapper =
214 WebDataServiceFactory::GetForProfile(profile, access_type);
215 // |wrapper| can be NULL in Incognito mode.
216 return wrapper ? wrapper->GetTokenWebData()
217 : scoped_refptr<TokenWebData>(NULL);
218 }
219
220 // static
221 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { 224 WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
222 return Singleton<WebDataServiceFactory>::get(); 225 return Singleton<WebDataServiceFactory>::get();
223 } 226 }
224 227
225 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( 228 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse(
226 content::BrowserContext* context) const { 229 content::BrowserContext* context) const {
227 return chrome::GetBrowserContextRedirectedInIncognito(context); 230 return chrome::GetBrowserContextRedirectedInIncognito(context);
228 } 231 }
229 232
230 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( 233 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor(
231 content::BrowserContext* profile) const { 234 content::BrowserContext* profile) const {
232 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 235 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
233 } 236 }
234 237
235 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 238 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
236 return true; 239 return true;
237 } 240 }
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