1 // Copyright (c) 2012 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. 4 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 7 8 #include "base/memory/singleton.h" 9 #include "components/browser_context_keyed_service/browser_context_keyed_service_factory.h" 10 11 class Profile; 12 13 namespace user_prefs { 14 class PrefRegistrySyncable; 15 } 16 17 namespace policy { 18 19 class UserPolicySigninService; 20 21 // Singleton that owns all UserPolicySigninServices and creates/deletes them as 22 // new Profiles are created/shutdown. 23 class UserPolicySigninServiceFactory 24 : public BrowserContextKeyedServiceFactory { 25 public: 26 // Returns an instance of the UserPolicySigninServiceFactory singleton. 27 static UserPolicySigninServiceFactory* GetInstance(); 28 29 // Returns the instance of UserPolicySigninService for the passed |profile|. 30 // Used primarily for testing. 31 static UserPolicySigninService* GetForProfile(Profile* profile); 32 33 protected: 34 // BrowserContextKeyedServiceFactory implementation. 35 virtual BrowserContextKeyedService* BuildServiceInstanceFor( 36 content::BrowserContext* profile) const OVERRIDE; 37 38 // Overridden to cause this object to be created when the profile is created. 39 virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; 40 41 // Register the preferences related to cloud-based user policy. 42 virtual void RegisterProfilePrefs( 43 user_prefs::PrefRegistrySyncable* registry) OVERRIDE; 44 45 private: 46 friend struct DefaultSingletonTraits<UserPolicySigninServiceFactory>; 47 48 UserPolicySigninServiceFactory(); 49 virtual ~UserPolicySigninServiceFactory(); 50 51 DISALLOW_COPY_AND_ASSIGN(UserPolicySigninServiceFactory); 52 }; 53 54 } // namespace policy 55 56 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 57