| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_USER_CLOUD_POLICY_MANAGER_FACTORY_CHROMEO
S_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHROMEO
S_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHROMEO
S_H_ | 6 #define CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHROMEO
S_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" | 12 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" |
| 13 | 13 |
| 14 class Profile; | 14 class Profile; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class BrowserContext; | 17 class BrowserContext; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace policy { | 20 namespace policy { |
| 21 | 21 |
| 22 class UserCloudPolicyManagerChromeOS; | 22 class UserCloudPolicyManagerChromeOS; |
| 23 | 23 |
| 24 // ProfileKeyedBaseFactory implementation for UserCloudPolicyManagerChromeOS | 24 // BrowserContextKeyedBaseFactory implementation for UserCloudPolicyManagerChrom
eOS |
| 25 // instances that initialize per-profile cloud policy settings on ChromeOS. | 25 // instances that initialize per-profile cloud policy settings on ChromeOS. |
| 26 // | 26 // |
| 27 // UserCloudPolicyManagerChromeOS is handled different than other | 27 // UserCloudPolicyManagerChromeOS is handled different than other |
| 28 // ProfileKeyedServices because it is a dependency of PrefService. Therefore, | 28 // BrowserContextKeyedServices because it is a dependency of PrefService. Theref
ore, |
| 29 // lifetime of instances is managed by Profile, Profile startup code invokes | 29 // lifetime of instances is managed by Profile, Profile startup code invokes |
| 30 // CreateForProfile() explicitly, takes ownership, and the instance is only | 30 // CreateForProfile() explicitly, takes ownership, and the instance is only |
| 31 // deleted after PrefService destruction. | 31 // deleted after PrefService destruction. |
| 32 // | 32 // |
| 33 // TODO(mnissler): Remove the special lifetime management in favor of | 33 // TODO(mnissler): Remove the special lifetime management in favor of |
| 34 // PrefService directly depending on UserCloudPolicyManagerChromeOS once the | 34 // PrefService directly depending on UserCloudPolicyManagerChromeOS once the |
| 35 // former has been converted to a ProfileKeyedService. | 35 // former has been converted to a BrowserContextKeyedService. |
| 36 // See also http://crbug.com/131843 and http://crbug.com/131844. | 36 // See also http://crbug.com/131843 and http://crbug.com/131844. |
| 37 class UserCloudPolicyManagerFactoryChromeOS : public ProfileKeyedBaseFactory { | 37 class UserCloudPolicyManagerFactoryChromeOS : public BrowserContextKeyedBaseFact
ory { |
| 38 public: | 38 public: |
| 39 // Returns an instance of the UserCloudPolicyManagerFactoryChromeOS singleton. | 39 // Returns an instance of the UserCloudPolicyManagerFactoryChromeOS singleton. |
| 40 static UserCloudPolicyManagerFactoryChromeOS* GetInstance(); | 40 static UserCloudPolicyManagerFactoryChromeOS* GetInstance(); |
| 41 | 41 |
| 42 // Returns the UserCloudPolicyManagerChromeOS instance associated with | 42 // Returns the UserCloudPolicyManagerChromeOS instance associated with |
| 43 // |profile|. | 43 // |profile|. |
| 44 static UserCloudPolicyManagerChromeOS* GetForProfile(Profile* profile); | 44 static UserCloudPolicyManagerChromeOS* GetForProfile(Profile* profile); |
| 45 | 45 |
| 46 // Creates an instance for |profile|. Note that the caller is responsible for | 46 // Creates an instance for |profile|. Note that the caller is responsible for |
| 47 // managing the lifetime of the instance. Subsequent calls to GetForProfile() | 47 // managing the lifetime of the instance. Subsequent calls to GetForProfile() |
| (...skipping 10 matching lines...) Expand all Loading... |
| 58 | 58 |
| 59 UserCloudPolicyManagerFactoryChromeOS(); | 59 UserCloudPolicyManagerFactoryChromeOS(); |
| 60 virtual ~UserCloudPolicyManagerFactoryChromeOS(); | 60 virtual ~UserCloudPolicyManagerFactoryChromeOS(); |
| 61 | 61 |
| 62 // See comments for the static versions above. | 62 // See comments for the static versions above. |
| 63 UserCloudPolicyManagerChromeOS* GetManagerForProfile(Profile* profile); | 63 UserCloudPolicyManagerChromeOS* GetManagerForProfile(Profile* profile); |
| 64 scoped_ptr<UserCloudPolicyManagerChromeOS> CreateManagerForProfile( | 64 scoped_ptr<UserCloudPolicyManagerChromeOS> CreateManagerForProfile( |
| 65 Profile* profile, | 65 Profile* profile, |
| 66 bool force_immediate_load); | 66 bool force_immediate_load); |
| 67 | 67 |
| 68 // ProfileKeyedBaseFactory: | 68 // BrowserContextKeyedBaseFactory: |
| 69 virtual void ProfileShutdown(content::BrowserContext* context) OVERRIDE; | 69 virtual void BrowserContextShutdown( |
| 70 virtual void ProfileDestroyed(content::BrowserContext* context) OVERRIDE; | 70 content::BrowserContext* context) OVERRIDE; |
| 71 virtual void BrowserContextDestroyed( |
| 72 content::BrowserContext* context) OVERRIDE; |
| 71 virtual void SetEmptyTestingFactory( | 73 virtual void SetEmptyTestingFactory( |
| 72 content::BrowserContext* context) OVERRIDE; | 74 content::BrowserContext* context) OVERRIDE; |
| 73 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; | 75 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; |
| 74 | 76 |
| 75 typedef std::map<Profile*, UserCloudPolicyManagerChromeOS*> ManagerMap; | 77 typedef std::map<Profile*, UserCloudPolicyManagerChromeOS*> ManagerMap; |
| 76 ManagerMap managers_; | 78 ManagerMap managers_; |
| 77 | 79 |
| 78 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactoryChromeOS); | 80 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactoryChromeOS); |
| 79 }; | 81 }; |
| 80 | 82 |
| 81 } // namespace policy | 83 } // namespace policy |
| 82 | 84 |
| 83 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHRO
MEOS_H_ | 85 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHRO
MEOS_H_ |
| OLD | NEW |