Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | |
| 6 #define CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "base/memory/singleton.h" | |
| 12 #include "chrome/browser/profiles/profile_keyed_base_factory.h" | |
| 13 | |
| 14 class Profile; | |
| 15 | |
| 16 namespace policy { | |
| 17 | |
| 18 class UserCloudPolicyManager; | |
| 19 | |
| 20 // ProfileKeyedBaseFactory implementation for UserCloudPolicyManager | |
| 21 // instances that initialize per-profile cloud policy settings on the desktop | |
| 22 // platforms. | |
| 23 // | |
| 24 // UserCloudPolicyManager is handled different than other ProfileKeyedServices | |
| 25 // because it is a dependency of PrefService. Therefore, Profile startup code | |
| 26 // invokes InitForProfile() explicitly and the instance is only deleted after | |
| 27 // PrefService destruction. | |
| 28 // | |
| 29 // TODO(mnissler): Remove the special lifetime management in favor of directly | |
| 30 // depending on PrefService once the latter is a ProfileKeyedService. | |
|
Joao da Silva
2012/11/23 10:08:12
Mention bugs 131843 and 131844.
Mattias Nissler (ping if slow)
2012/11/23 17:36:06
Done.
| |
| 31 class UserCloudPolicyManagerFactory : public ProfileKeyedBaseFactory { | |
| 32 public: | |
| 33 // Returns an instance of the UserCloudPolicyManagerFactory singleton. | |
| 34 static UserCloudPolicyManagerFactory* GetInstance(); | |
| 35 | |
| 36 // Returns the UserCloudPolicyManager instance associated with |profile|. | |
| 37 static UserCloudPolicyManager* GetForProfile(Profile* profile); | |
| 38 | |
| 39 private: | |
| 40 friend class UserCloudPolicyManager; | |
| 41 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>; | |
| 42 | |
| 43 UserCloudPolicyManagerFactory(); | |
| 44 virtual ~UserCloudPolicyManagerFactory(); | |
| 45 | |
| 46 // Returns the instance for |profile| or NULL if not found. | |
| 47 UserCloudPolicyManager* GetManagerForProfile(Profile* profile); | |
| 48 | |
| 49 // ProfileKeyedBaseFactory: | |
| 50 virtual void ProfileShutdown(Profile* profile) OVERRIDE; | |
| 51 virtual void SetEmptyTestingFactory(Profile* profile) OVERRIDE; | |
| 52 virtual void CreateServiceNow(Profile* profile) OVERRIDE; | |
| 53 | |
| 54 // Invoked by UserCloudPolicyManager to register/unregister instances. | |
| 55 void Register(Profile* profile, UserCloudPolicyManager* instance); | |
| 56 void Unregister(Profile* profile, UserCloudPolicyManager* instance); | |
| 57 | |
| 58 typedef std::map<Profile*, UserCloudPolicyManager*> ManagerMap; | |
| 59 ManagerMap managers_; | |
| 60 | |
| 61 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory); | |
| 62 }; | |
| 63 | |
| 64 } // namespace policy | |
| 65 | |
| 66 #endif // CHROME_BROWSER_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | |
| OLD | NEW |