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

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

Issue 72613006: Eliminate AutofillWebDataService::FromBrowserContext(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to reviews Created 7 years, 1 month 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"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() { 135 scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
136 return web_data_.get(); 136 return web_data_.get();
137 } 137 }
138 138
139 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { 139 scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
140 return token_web_data_.get(); 140 return token_web_data_.get();
141 } 141 }
142 142
143 // static 143 // static
144 scoped_refptr<AutofillWebDataService>
145 AutofillWebDataService::FromBrowserContext(content::BrowserContext* context) {
146 // For this service, the implicit/explicit distinction doesn't
147 // really matter; it's just used for a DCHECK. So we currently
148 // cheat and always say EXPLICIT_ACCESS.
149 WebDataServiceWrapper* wrapper =
150 WebDataServiceFactory::GetForProfile(
151 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
152 if (wrapper)
153 return wrapper->GetAutofillWebData();
154 // |wrapper| can be NULL in Incognito mode.
155 return scoped_refptr<AutofillWebDataService>(NULL);
156 }
157
158 // static
159 scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext( 144 scoped_refptr<TokenWebData> TokenWebData::FromBrowserContext(
160 content::BrowserContext* context) { 145 content::BrowserContext* context) {
161 // For this service, the implicit/explicit distinction doesn't 146 // For this service, the implicit/explicit distinction doesn't
162 // really matter; it's just used for a DCHECK. So we currently 147 // really matter; it's just used for a DCHECK. So we currently
163 // cheat and always say EXPLICIT_ACCESS. 148 // cheat and always say EXPLICIT_ACCESS.
164 WebDataServiceWrapper* wrapper = 149 WebDataServiceWrapper* wrapper =
165 WebDataServiceFactory::GetForProfile( 150 WebDataServiceFactory::GetForProfile(
166 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); 151 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
167 if (wrapper) 152 if (wrapper)
168 return wrapper->GetTokenWebData(); 153 return wrapper->GetTokenWebData();
(...skipping 20 matching lines...) Expand all
189 : BrowserContextKeyedServiceFactory( 174 : BrowserContextKeyedServiceFactory(
190 "WebDataService", 175 "WebDataService",
191 BrowserContextDependencyManager::GetInstance()) { 176 BrowserContextDependencyManager::GetInstance()) {
192 // WebDataServiceFactory has no dependecies. 177 // WebDataServiceFactory has no dependecies.
193 } 178 }
194 179
195 WebDataServiceFactory::~WebDataServiceFactory() {} 180 WebDataServiceFactory::~WebDataServiceFactory() {}
196 181
197 // static 182 // static
198 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( 183 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile(
199 Profile* profile, Profile::ServiceAccessType access_type) { 184 Profile* profile, Profile::ServiceAccessType access_type) {
Peter Kasting 2013/11/19 19:14:15 Nit: While here: Same comment about one arg per li
blundell 2013/12/02 16:10:59 Done.
200 // If |access_type| starts being used for anything other than this 185 // If |access_type| starts being used for anything other than this
201 // DCHECK, we need to start taking it as a parameter to 186 // DCHECK, we need to start taking it as a parameter to
202 // AutofillWebDataService::FromBrowserContext (see above). 187 // the *WebDataService::FromBrowserContext() functions (see above).
203 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); 188 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
204 return static_cast<WebDataServiceWrapper*>( 189 return static_cast<WebDataServiceWrapper*>(
205 GetInstance()->GetServiceForBrowserContext(profile, true)); 190 GetInstance()->GetServiceForBrowserContext(profile, true));
206 } 191 }
207 192
208 // static 193 // static
209 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( 194 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists(
210 Profile* profile, Profile::ServiceAccessType access_type) { 195 Profile* profile, Profile::ServiceAccessType access_type) {
211 // If |access_type| starts being used for anything other than this 196 // If |access_type| starts being used for anything other than this
212 // DCHECK, we need to start taking it as a parameter to 197 // DCHECK, we need to start taking it as a parameter to
213 // AutofillWebDataService::FromBrowserContext (see above). 198 // the *WebDataService::FromBrowserContext() functions (see above).
214 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); 199 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
215 return static_cast<WebDataServiceWrapper*>( 200 return static_cast<WebDataServiceWrapper*>(
216 GetInstance()->GetServiceForBrowserContext(profile, false)); 201 GetInstance()->GetServiceForBrowserContext(profile, false));
217 } 202 }
218 203
219 // static 204 // static
205 scoped_refptr<AutofillWebDataService>
206 WebDataServiceFactory::GetAutofillWebDataForProfile(
Peter Kasting 2013/11/19 19:14:15 Nit: Indent 4
blundell 2013/12/02 16:10:59 No indentation after return type: http://google-st
207 Profile* profile, Profile::ServiceAccessType access_type) {
208 WebDataServiceWrapper* wrapper =
209 WebDataServiceFactory::GetForProfile(profile, access_type);
210 // |wrapper| can be NULL in Incognito mode.
211 return wrapper ?
212 wrapper->GetAutofillWebData() :
Peter Kasting 2013/11/19 19:14:15 Nit: Indent 4, not 2
blundell 2013/12/02 16:10:59 Done.
213 scoped_refptr<AutofillWebDataService>(NULL);
214 }
215
216 // static
220 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { 217 WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
221 return Singleton<WebDataServiceFactory>::get(); 218 return Singleton<WebDataServiceFactory>::get();
222 } 219 }
223 220
224 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( 221 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse(
225 content::BrowserContext* context) const { 222 content::BrowserContext* context) const {
226 return chrome::GetBrowserContextRedirectedInIncognito(context); 223 return chrome::GetBrowserContextRedirectedInIncognito(context);
227 } 224 }
228 225
229 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( 226 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor(
230 content::BrowserContext* profile) const { 227 content::BrowserContext* profile) const {
231 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 228 return new WebDataServiceWrapper(static_cast<Profile*>(profile));
232 } 229 }
233 230
234 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { 231 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const {
235 return true; 232 return true;
236 } 233 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698