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_
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 template <typename T
> struct DefaultSingletonTraits
;
17 class PrefRegistrySimple
;
22 class PolicyCertService
;
23 class PolicyCertVerifier
;
25 // Factory to create PolicyCertServices.
26 class PolicyCertServiceFactory
: public BrowserContextKeyedServiceFactory
{
28 // Returns an existing PolicyCertService for |profile|. See
30 static PolicyCertService
* GetForProfile(Profile
* profile
);
32 // Creates a new PolicyCertService and returns the associated
33 // PolicyCertVerifier. Returns NULL if this service isn't allowed for
34 // |profile|, i.e. if NetworkConfigurationUpdater doesn't exist.
35 // This service is created separately for the original profile and the
37 // Note: NetworkConfigurationUpdater is currently only created for the primary
39 static scoped_ptr
<PolicyCertVerifier
> CreateForProfile(Profile
* profile
);
41 static PolicyCertServiceFactory
* GetInstance();
43 // Used to mark or clear |user_id| as having used certificates pushed by
45 static void SetUsedPolicyCertificates(const std::string
& user_id
);
46 static void ClearUsedPolicyCertificates(const std::string
& user_id
);
47 static bool UsedPolicyCertificates(const std::string
& user_id
);
49 static void RegisterPrefs(PrefRegistrySimple
* local_state
);
52 friend struct DefaultSingletonTraits
<PolicyCertServiceFactory
>;
54 PolicyCertServiceFactory();
55 ~PolicyCertServiceFactory() override
;
57 // BrowserContextKeyedServiceFactory:
58 KeyedService
* BuildServiceInstanceFor(
59 content::BrowserContext
* context
) const override
;
60 content::BrowserContext
* GetBrowserContextToUse(
61 content::BrowserContext
* context
) const override
;
62 void RegisterProfilePrefs(
63 user_prefs::PrefRegistrySyncable
* registry
) override
;
64 bool ServiceIsNULLWhileTesting() const override
;
66 DISALLOW_COPY_AND_ASSIGN(PolicyCertServiceFactory
);
71 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_