Elim cr-checkbox
[chromium-blink-merge.git] / chrome / browser / chromeos / policy / policy_cert_service_factory.h
blob5d5b74b690e67711f4c29ae6983b6f9757ffa06b
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 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
15 namespace base {
16 template <typename T>
17 struct DefaultSingletonTraits;
18 } // namespace base
20 class PrefRegistrySimple;
21 class Profile;
23 namespace policy {
25 class PolicyCertService;
26 class PolicyCertVerifier;
28 // Factory to create PolicyCertServices.
29 class PolicyCertServiceFactory : public BrowserContextKeyedServiceFactory {
30 public:
31 // Returns an existing PolicyCertService for |profile|. See
32 // CreateForProfile.
33 static PolicyCertService* GetForProfile(Profile* profile);
35 // Creates a new PolicyCertService and returns the associated
36 // PolicyCertVerifier. Returns NULL if this service isn't allowed for
37 // |profile|, i.e. if NetworkConfigurationUpdater doesn't exist.
38 // This service is created separately for the original profile and the
39 // incognito profile.
40 // Note: NetworkConfigurationUpdater is currently only created for the primary
41 // user's profile.
42 static scoped_ptr<PolicyCertVerifier> CreateForProfile(Profile* profile);
44 static PolicyCertServiceFactory* GetInstance();
46 // Used to mark or clear |user_id| as having used certificates pushed by
47 // policy before.
48 static void SetUsedPolicyCertificates(const std::string& user_id);
49 static void ClearUsedPolicyCertificates(const std::string& user_id);
50 static bool UsedPolicyCertificates(const std::string& user_id);
52 static void RegisterPrefs(PrefRegistrySimple* local_state);
54 private:
55 friend struct base::DefaultSingletonTraits<PolicyCertServiceFactory>;
57 PolicyCertServiceFactory();
58 ~PolicyCertServiceFactory() override;
60 // BrowserContextKeyedServiceFactory:
61 KeyedService* BuildServiceInstanceFor(
62 content::BrowserContext* context) const override;
63 content::BrowserContext* GetBrowserContextToUse(
64 content::BrowserContext* context) const override;
65 void RegisterProfilePrefs(
66 user_prefs::PrefRegistrySyncable* registry) override;
67 bool ServiceIsNULLWhileTesting() const override;
69 DISALLOW_COPY_AND_ASSIGN(PolicyCertServiceFactory);
72 } // namespace policy
74 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_