Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / profile_resetter / automatic_profile_resetter_factory.cc
blobb67d258b9b87a796b217ac0b29b4cd01ef79c134
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/browser_context_keyed_service/browser_context_dependency_manager.h"
15 #include "components/user_prefs/pref_registry_syncable.h"
16 #include "content/public/browser/browser_context.h"
18 // static
19 AutomaticProfileResetter* AutomaticProfileResetterFactory::GetForBrowserContext(
20 content::BrowserContext* context) {
21 return static_cast<AutomaticProfileResetter*>(
22 GetInstance()->GetServiceForBrowserContext(context, true));
25 // static
26 AutomaticProfileResetterFactory*
27 AutomaticProfileResetterFactory::GetInstance() {
28 return Singleton<AutomaticProfileResetterFactory>::get();
31 // static
32 void AutomaticProfileResetterFactory::RegisterPrefs(
33 PrefRegistrySimple* registry) {
34 registry->RegisterDictionaryPref(prefs::kProfileResetPromptMemento);
37 AutomaticProfileResetterFactory::AutomaticProfileResetterFactory()
38 : BrowserContextKeyedServiceFactory(
39 "AutomaticProfileResetter",
40 BrowserContextDependencyManager::GetInstance()) {
41 DependsOn(TemplateURLServiceFactory::GetInstance());
42 DependsOn(GlobalErrorServiceFactory::GetInstance());
45 AutomaticProfileResetterFactory::~AutomaticProfileResetterFactory() {}
47 BrowserContextKeyedService*
48 AutomaticProfileResetterFactory::BuildServiceInstanceFor(
49 content::BrowserContext* context) const {
50 Profile* profile = Profile::FromBrowserContext(context);
51 AutomaticProfileResetter* service = new AutomaticProfileResetter(profile);
52 service->Initialize();
53 service->Activate();
54 return service;
57 void AutomaticProfileResetterFactory::RegisterProfilePrefs(
58 user_prefs::PrefRegistrySyncable* registry) {
59 registry->RegisterStringPref(
60 prefs::kProfileResetPromptMemento,
61 "",
62 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
65 bool AutomaticProfileResetterFactory::
66 ServiceIsCreatedWithBrowserContext() const {
67 return true;
70 bool AutomaticProfileResetterFactory::ServiceIsNULLWhileTesting() const {
71 return true;