| OLD | NEW |
| 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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 WebDataServiceWrapper* wrapper = | 149 WebDataServiceWrapper* wrapper = |
| 150 WebDataServiceFactory::GetForProfile( | 150 WebDataServiceFactory::GetForProfile( |
| 151 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); | 151 static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS); |
| 152 if (wrapper) | 152 if (wrapper) |
| 153 return wrapper->GetWebData(); | 153 return wrapper->GetWebData(); |
| 154 // |wrapper| can be NULL in Incognito mode. | 154 // |wrapper| can be NULL in Incognito mode. |
| 155 return scoped_refptr<WebDataService>(NULL); | 155 return scoped_refptr<WebDataService>(NULL); |
| 156 } | 156 } |
| 157 | 157 |
| 158 WebDataServiceFactory::WebDataServiceFactory() | 158 WebDataServiceFactory::WebDataServiceFactory() |
| 159 : ProfileKeyedServiceFactory("WebDataService", | 159 : BrowserContextKeyedServiceFactory( |
| 160 ProfileDependencyManager::GetInstance()) { | 160 "WebDataService", |
| 161 BrowserContextDependencyManager::GetInstance()) { |
| 161 // WebDataServiceFactory has no dependecies. | 162 // WebDataServiceFactory has no dependecies. |
| 162 } | 163 } |
| 163 | 164 |
| 164 WebDataServiceFactory::~WebDataServiceFactory() {} | 165 WebDataServiceFactory::~WebDataServiceFactory() {} |
| 165 | 166 |
| 166 // static | 167 // static |
| 167 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( | 168 WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( |
| 168 Profile* profile, Profile::ServiceAccessType access_type) { | 169 Profile* profile, Profile::ServiceAccessType access_type) { |
| 169 // If |access_type| starts being used for anything other than this | 170 // If |access_type| starts being used for anything other than this |
| 170 // DCHECK, we need to start taking it as a parameter to | 171 // DCHECK, we need to start taking it as a parameter to |
| 171 // AutofillWebDataService::FromBrowserContext (see above). | 172 // AutofillWebDataService::FromBrowserContext (see above). |
| 172 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 173 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 173 return static_cast<WebDataServiceWrapper*>( | 174 return static_cast<WebDataServiceWrapper*>( |
| 174 GetInstance()->GetServiceForProfile(profile, true)); | 175 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 175 } | 176 } |
| 176 | 177 |
| 177 // static | 178 // static |
| 178 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( | 179 WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( |
| 179 Profile* profile, Profile::ServiceAccessType access_type) { | 180 Profile* profile, Profile::ServiceAccessType access_type) { |
| 180 // If |access_type| starts being used for anything other than this | 181 // If |access_type| starts being used for anything other than this |
| 181 // DCHECK, we need to start taking it as a parameter to | 182 // DCHECK, we need to start taking it as a parameter to |
| 182 // AutofillWebDataService::FromBrowserContext (see above). | 183 // AutofillWebDataService::FromBrowserContext (see above). |
| 183 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); | 184 DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); |
| 184 return static_cast<WebDataServiceWrapper*>( | 185 return static_cast<WebDataServiceWrapper*>( |
| 185 GetInstance()->GetServiceForProfile(profile, false)); | 186 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 186 } | 187 } |
| 187 | 188 |
| 188 // static | 189 // static |
| 189 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { | 190 WebDataServiceFactory* WebDataServiceFactory::GetInstance() { |
| 190 return Singleton<WebDataServiceFactory>::get(); | 191 return Singleton<WebDataServiceFactory>::get(); |
| 191 } | 192 } |
| 192 | 193 |
| 193 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( | 194 content::BrowserContext* WebDataServiceFactory::GetBrowserContextToUse( |
| 194 content::BrowserContext* context) const { | 195 content::BrowserContext* context) const { |
| 195 return chrome::GetBrowserContextRedirectedInIncognito(context); | 196 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 196 } | 197 } |
| 197 | 198 |
| 198 ProfileKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( | 199 BrowserContextKeyedService* WebDataServiceFactory::BuildServiceInstanceFor( |
| 199 content::BrowserContext* profile) const { | 200 content::BrowserContext* profile) const { |
| 200 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); | 201 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); |
| 201 } | 202 } |
| 202 | 203 |
| 203 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { | 204 bool WebDataServiceFactory::ServiceIsNULLWhileTesting() const { |
| 204 return true; | 205 return true; |
| 205 } | 206 } |
| OLD | NEW |