summaryrefslogtreecommitdiffstats
path: root/chrome/browser/protector/protector_service_factory.cc
blob: 4d854e3dc8ac2d01c6f28b6a4115bd196264a94b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// 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/protector/protector_service_factory.h"

#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/protector/protected_prefs_watcher.h"
#include "chrome/browser/protector/protector_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"

namespace protector {

// static
ProtectorService* ProtectorServiceFactory::GetForProfile(Profile* profile) {
  return static_cast<ProtectorService*>(
      GetInstance()->GetServiceForProfile(profile, true));
}

//  static
ProtectorServiceFactory* ProtectorServiceFactory::GetInstance() {
  return Singleton<ProtectorServiceFactory>::get();
}

ProtectorServiceFactory::ProtectorServiceFactory()
    : ProfileKeyedServiceFactory("ProtectorService",
                                 ProfileDependencyManager::GetInstance()) {
  // Dependencies for the correct service shutdown order.
  DependsOn(GlobalErrorServiceFactory::GetInstance());
  DependsOn(TemplateURLServiceFactory::GetInstance());
}

ProtectorServiceFactory::~ProtectorServiceFactory() {
}

ProfileKeyedService* ProtectorServiceFactory::BuildServiceInstanceFor(
    Profile* profile) const {
  return new ProtectorService(profile);
}

void ProtectorServiceFactory::RegisterUserPrefs(PrefService* user_prefs) {
  ProtectedPrefsWatcher::RegisterUserPrefs(user_prefs);
}

bool ProtectorServiceFactory::ServiceIsCreatedWithProfile() const {
  // ProtectorService watches changes for protected prefs so it must be started
  // right with the profile creation.
  return true;
}

bool ProtectorServiceFactory::ServiceRedirectedInIncognito() const {
  return true;
}

}  // namespace protector