blob: 6b770fad6f691870f7381a29449be249527bb5cc [file] [log] [blame]
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/autofill/personal_data_manager_factory.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/signin_manager_factory.h"
#include "chrome/browser/web_data_service_factory.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/signin_manager.h"
namespace autofill {
// static
PersonalDataManager* PersonalDataManagerFactory::GetForProfile(
Profile* profile) {
return static_cast<PersonalDataManager*>(
GetInstance()->GetServiceForBrowserContext(profile, true));
}
// static
PersonalDataManagerFactory* PersonalDataManagerFactory::GetInstance() {
return base::Singleton<PersonalDataManagerFactory>::get();
}
PersonalDataManagerFactory::PersonalDataManagerFactory()
: BrowserContextKeyedServiceFactory(
"PersonalDataManager",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(AccountTrackerServiceFactory::GetInstance());
DependsOn(SigninManagerFactory::GetInstance());
DependsOn(WebDataServiceFactory::GetInstance());
}
PersonalDataManagerFactory::~PersonalDataManagerFactory() {
}
KeyedService* PersonalDataManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Profile* profile = Profile::FromBrowserContext(context);
PersonalDataManager* service =
new PersonalDataManager(g_browser_process->GetApplicationLocale());
service->Init(WebDataServiceFactory::GetAutofillWebDataForProfile(
profile, ServiceAccessType::EXPLICIT_ACCESS),
profile->GetPrefs(),
AccountTrackerServiceFactory::GetForProfile(profile),
SigninManagerFactory::GetForProfile(profile),
profile->IsOffTheRecord());
return service;
}
content::BrowserContext* PersonalDataManagerFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}
} // namespace autofill