15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/memory/singleton.h" 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "components/keyed_service/content/browser_context_keyed_service_factory.h" 1090dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) 1190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class Profile; 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 13c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)namespace user_prefs { 142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class PrefRegistrySyncable; 15c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)} 162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 175821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace policy { 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 193551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)class DeviceManagementService; 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class UserPolicySigninService; 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Singleton that owns all UserPolicySigninServices and creates/deletes them as 235821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// new Profiles are created/shutdown. 2490dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles)class UserPolicySigninServiceFactory 2590dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) : public BrowserContextKeyedServiceFactory { 265821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public: 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns an instance of the UserPolicySigninServiceFactory singleton. 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static UserPolicySigninServiceFactory* GetInstance(); 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Returns the instance of UserPolicySigninService for the passed |profile|. 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Used primarily for testing. 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) static UserPolicySigninService* GetForProfile(Profile* profile); 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 343551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Allows setting a mock DeviceManagementService for tests. Does not take 353551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // ownership, and should be reset to NULL at the end of the test. 363551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Set this before an instance is built for a Profile. 373551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) static void SetDeviceManagementServiceForTesting( 383551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) DeviceManagementService* device_management_service); 393551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 405821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 4190dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) // BrowserContextKeyedServiceFactory implementation. 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) virtual KeyedService* BuildServiceInstanceFor( 43c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) content::BrowserContext* profile) const OVERRIDE; 445821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 455821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Overridden to cause this object to be created when the profile is created. 4690dce4d38c5ff5333bea97d859d4e484e27edf0cTorne (Richard Coles) virtual bool ServiceIsCreatedWithBrowserContext() const OVERRIDE; 475821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 485821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // Register the preferences related to cloud-based user policy. 497dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch virtual void RegisterProfilePrefs( 50c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) user_prefs::PrefRegistrySyncable* registry) OVERRIDE; 515821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 525821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) private: 535821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) friend struct DefaultSingletonTraits<UserPolicySigninServiceFactory>; 545821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 555821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) UserPolicySigninServiceFactory(); 565821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~UserPolicySigninServiceFactory(); 575821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 585821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(UserPolicySigninServiceFactory); 595821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)}; 605821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 615821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} // namespace policy 625821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // CHROME_BROWSER_POLICY_CLOUD_USER_POLICY_SIGNIN_SERVICE_FACTORY_H_ 64