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
3 // found in the LICENSE file.
5 #include "chrome/browser/autofill/personal_data_manager_factory.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/memory/singleton.h"
9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/incognito_helpers.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/webdata/web_data_service_factory.h"
13 #include "components/autofill/core/browser/personal_data_manager.h"
14 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
15 #include "components/keyed_service/content/browser_context_dependency_manager.h"
20 PersonalDataManager
* PersonalDataManagerFactory::GetForProfile(
22 return static_cast<PersonalDataManager
*>(
23 GetInstance()->GetServiceForBrowserContext(profile
, true));
27 PersonalDataManagerFactory
* PersonalDataManagerFactory::GetInstance() {
28 return Singleton
<PersonalDataManagerFactory
>::get();
31 PersonalDataManagerFactory::PersonalDataManagerFactory()
32 : BrowserContextKeyedServiceFactory(
33 "PersonalDataManager",
34 BrowserContextDependencyManager::GetInstance()) {
35 DependsOn(WebDataServiceFactory::GetInstance());
38 PersonalDataManagerFactory::~PersonalDataManagerFactory() {
41 KeyedService
* PersonalDataManagerFactory::BuildServiceInstanceFor(
42 content::BrowserContext
* context
) const {
43 Profile
* profile
= Profile::FromBrowserContext(context
);
44 PersonalDataManager
* service
=
45 new PersonalDataManager(g_browser_process
->GetApplicationLocale());
46 service
->Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
47 profile
, Profile::EXPLICIT_ACCESS
),
49 profile
->IsOffTheRecord());
53 content::BrowserContext
* PersonalDataManagerFactory::GetBrowserContextToUse(
54 content::BrowserContext
* context
) const {
55 return chrome::GetBrowserContextOwnInstanceInIncognito(context
);
58 } // namespace autofill