| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ |
| 7 | 7 |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 13 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" | 11 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 14 | 12 |
| 15 template <typename T> struct DefaultSingletonTraits; | 13 template <typename T> struct DefaultSingletonTraits; |
| 16 | 14 |
| 17 class PrefRegistrySimple; | 15 class PrefRegistrySimple; |
| 18 class Profile; | 16 class Profile; |
| 19 | 17 |
| 18 namespace user_manager { |
| 19 class UserID; |
| 20 } |
| 21 |
| 20 namespace policy { | 22 namespace policy { |
| 21 | 23 |
| 22 class PolicyCertService; | 24 class PolicyCertService; |
| 23 class PolicyCertVerifier; | 25 class PolicyCertVerifier; |
| 24 | 26 |
| 25 // Factory to create PolicyCertServices. | 27 // Factory to create PolicyCertServices. |
| 26 class PolicyCertServiceFactory : public BrowserContextKeyedServiceFactory { | 28 class PolicyCertServiceFactory : public BrowserContextKeyedServiceFactory { |
| 27 public: | 29 public: |
| 28 // Returns an existing PolicyCertService for |profile|. See | 30 // Returns an existing PolicyCertService for |profile|. See |
| 29 // CreateForProfile. | 31 // CreateForProfile. |
| 30 static PolicyCertService* GetForProfile(Profile* profile); | 32 static PolicyCertService* GetForProfile(Profile* profile); |
| 31 | 33 |
| 32 // Creates a new PolicyCertService and returns the associated | 34 // Creates a new PolicyCertService and returns the associated |
| 33 // PolicyCertVerifier. Returns NULL if this service isn't allowed for | 35 // PolicyCertVerifier. Returns NULL if this service isn't allowed for |
| 34 // |profile|, i.e. if NetworkConfigurationUpdater doesn't exist. | 36 // |profile|, i.e. if NetworkConfigurationUpdater doesn't exist. |
| 35 // This service is created separately for the original profile and the | 37 // This service is created separately for the original profile and the |
| 36 // incognito profile. | 38 // incognito profile. |
| 37 // Note: NetworkConfigurationUpdater is currently only created for the primary | 39 // Note: NetworkConfigurationUpdater is currently only created for the primary |
| 38 // user's profile. | 40 // user's profile. |
| 39 static scoped_ptr<PolicyCertVerifier> CreateForProfile(Profile* profile); | 41 static scoped_ptr<PolicyCertVerifier> CreateForProfile(Profile* profile); |
| 40 | 42 |
| 41 static PolicyCertServiceFactory* GetInstance(); | 43 static PolicyCertServiceFactory* GetInstance(); |
| 42 | 44 |
| 43 // Used to mark or clear |user_id| as having used certificates pushed by | 45 // Used to mark or clear |user_id| as having used certificates pushed by |
| 44 // policy before. | 46 // policy before. |
| 45 static void SetUsedPolicyCertificates(const std::string& user_id); | 47 static void SetUsedPolicyCertificates(const user_manager::UserID& user_id); |
| 46 static void ClearUsedPolicyCertificates(const std::string& user_id); | 48 static void ClearUsedPolicyCertificates(const user_manager::UserID& user_id); |
| 47 static bool UsedPolicyCertificates(const std::string& user_id); | 49 static bool UsedPolicyCertificates(const user_manager::UserID& user_id); |
| 48 | 50 |
| 49 static void RegisterPrefs(PrefRegistrySimple* local_state); | 51 static void RegisterPrefs(PrefRegistrySimple* local_state); |
| 50 | 52 |
| 51 private: | 53 private: |
| 52 friend struct DefaultSingletonTraits<PolicyCertServiceFactory>; | 54 friend struct DefaultSingletonTraits<PolicyCertServiceFactory>; |
| 53 | 55 |
| 54 PolicyCertServiceFactory(); | 56 PolicyCertServiceFactory(); |
| 55 ~PolicyCertServiceFactory() override; | 57 ~PolicyCertServiceFactory() override; |
| 56 | 58 |
| 57 // BrowserContextKeyedServiceFactory: | 59 // BrowserContextKeyedServiceFactory: |
| 58 KeyedService* BuildServiceInstanceFor( | 60 KeyedService* BuildServiceInstanceFor( |
| 59 content::BrowserContext* context) const override; | 61 content::BrowserContext* context) const override; |
| 60 content::BrowserContext* GetBrowserContextToUse( | 62 content::BrowserContext* GetBrowserContextToUse( |
| 61 content::BrowserContext* context) const override; | 63 content::BrowserContext* context) const override; |
| 62 void RegisterProfilePrefs( | 64 void RegisterProfilePrefs( |
| 63 user_prefs::PrefRegistrySyncable* registry) override; | 65 user_prefs::PrefRegistrySyncable* registry) override; |
| 64 bool ServiceIsNULLWhileTesting() const override; | 66 bool ServiceIsNULLWhileTesting() const override; |
| 65 | 67 |
| 66 DISALLOW_COPY_AND_ASSIGN(PolicyCertServiceFactory); | 68 DISALLOW_COPY_AND_ASSIGN(PolicyCertServiceFactory); |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace policy | 71 } // namespace policy |
| 70 | 72 |
| 71 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ | 73 #endif // CHROME_BROWSER_CHROMEOS_POLICY_POLICY_CERT_SERVICE_FACTORY_H_ |
| OLD | NEW |