1 // Copyright 2013 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/profile_resetter/automatic_profile_resetter_factory.h"
7 #include "base/memory/singleton.h"
8 #include "base/prefs/pref_registry_simple.h"
9 #include "chrome/browser/profile_resetter/automatic_profile_resetter.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
13 #include "chrome/common/pref_names.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "content/public/browser/browser_context.h"
19 AutomaticProfileResetter
* AutomaticProfileResetterFactory::GetForBrowserContext(
20 content::BrowserContext
* context
) {
21 return static_cast<AutomaticProfileResetter
*>(
22 GetInstance()->GetServiceForBrowserContext(context
, true));
26 AutomaticProfileResetterFactory
*
27 AutomaticProfileResetterFactory::GetInstance() {
28 return base::Singleton
<AutomaticProfileResetterFactory
>::get();
32 void AutomaticProfileResetterFactory::RegisterPrefs(
33 PrefRegistrySimple
* registry
) {
34 registry
->RegisterDictionaryPref(
35 prefs::kProfileResetPromptMementosInLocalState
);
38 AutomaticProfileResetterFactory::AutomaticProfileResetterFactory()
39 : BrowserContextKeyedServiceFactory(
40 "AutomaticProfileResetter",
41 BrowserContextDependencyManager::GetInstance()) {
42 DependsOn(TemplateURLServiceFactory::GetInstance());
43 DependsOn(GlobalErrorServiceFactory::GetInstance());
46 AutomaticProfileResetterFactory::~AutomaticProfileResetterFactory() {}
48 KeyedService
* AutomaticProfileResetterFactory::BuildServiceInstanceFor(
49 content::BrowserContext
* context
) const {
50 Profile
* profile
= Profile::FromBrowserContext(context
);
51 AutomaticProfileResetter
* service
= new AutomaticProfileResetter(profile
);
52 service
->Initialize();
57 void AutomaticProfileResetterFactory::RegisterProfilePrefs(
58 user_prefs::PrefRegistrySyncable
* registry
) {
59 registry
->RegisterStringPref(prefs::kProfileResetPromptMementoInProfilePrefs
,
63 bool AutomaticProfileResetterFactory::
64 ServiceIsCreatedWithBrowserContext() const {
68 bool AutomaticProfileResetterFactory::ServiceIsNULLWhileTesting() const {