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"
17 struct DefaultSingletonTraits
;
20 class PrefRegistrySimple
;
25 class PolicyCertService
;
26 class PolicyCertVerifier
;
28 // Factory to create PolicyCertServices.
29 class PolicyCertServiceFactory
: public BrowserContextKeyedServiceFactory
{
31 // Returns an existing PolicyCertService for |profile|. See
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
40 // Note: NetworkConfigurationUpdater is currently only created for the primary
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
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
);
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
);
74 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_