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 |
25 // instances that initialize per-profile cloud policy settings on ChromeOS. | 25 // for UserCloudPolicyManagerChromeOS instances that initialize per-profile |
| 26 // cloud policy settings on ChromeOS. |
26 // | 27 // |
27 // UserCloudPolicyManagerChromeOS is handled different than other | 28 // UserCloudPolicyManagerChromeOS is handled different than other |
28 // ProfileKeyedServices because it is a dependency of PrefService. Therefore, | 29 // BrowserContextKeyedServices because it is a dependency of PrefService. |
29 // lifetime of instances is managed by Profile, Profile startup code invokes | 30 // Therefore, lifetime of instances is managed by Profile, Profile startup code |
30 // CreateForProfile() explicitly, takes ownership, and the instance is only | 31 // invokes CreateForProfile() explicitly, takes ownership, and the instance |
31 // deleted after PrefService destruction. | 32 // is only deleted after PrefService destruction. |
32 // | 33 // |
33 // TODO(mnissler): Remove the special lifetime management in favor of | 34 // TODO(mnissler): Remove the special lifetime management in favor of |
34 // PrefService directly depending on UserCloudPolicyManagerChromeOS once the | 35 // PrefService directly depending on UserCloudPolicyManagerChromeOS once the |
35 // former has been converted to a ProfileKeyedService. | 36 // former has been converted to a BrowserContextKeyedService. |
36 // See also http://crbug.com/131843 and http://crbug.com/131844. | 37 // See also http://crbug.com/131843 and http://crbug.com/131844. |
37 class UserCloudPolicyManagerFactoryChromeOS : public ProfileKeyedBaseFactory { | 38 class UserCloudPolicyManagerFactoryChromeOS |
| 39 : public BrowserContextKeyedBaseFactory { |
38 public: | 40 public: |
39 // Returns an instance of the UserCloudPolicyManagerFactoryChromeOS singleton. | 41 // Returns an instance of the UserCloudPolicyManagerFactoryChromeOS singleton. |
40 static UserCloudPolicyManagerFactoryChromeOS* GetInstance(); | 42 static UserCloudPolicyManagerFactoryChromeOS* GetInstance(); |
41 | 43 |
42 // Returns the UserCloudPolicyManagerChromeOS instance associated with | 44 // Returns the UserCloudPolicyManagerChromeOS instance associated with |
43 // |profile|. | 45 // |profile|. |
44 static UserCloudPolicyManagerChromeOS* GetForProfile(Profile* profile); | 46 static UserCloudPolicyManagerChromeOS* GetForProfile(Profile* profile); |
45 | 47 |
46 // Creates an instance for |profile|. Note that the caller is responsible for | 48 // Creates an instance for |profile|. Note that the caller is responsible for |
47 // managing the lifetime of the instance. Subsequent calls to GetForProfile() | 49 // managing the lifetime of the instance. Subsequent calls to GetForProfile() |
(...skipping 10 matching lines...) Expand all Loading... |
58 | 60 |
59 UserCloudPolicyManagerFactoryChromeOS(); | 61 UserCloudPolicyManagerFactoryChromeOS(); |
60 virtual ~UserCloudPolicyManagerFactoryChromeOS(); | 62 virtual ~UserCloudPolicyManagerFactoryChromeOS(); |
61 | 63 |
62 // See comments for the static versions above. | 64 // See comments for the static versions above. |
63 UserCloudPolicyManagerChromeOS* GetManagerForProfile(Profile* profile); | 65 UserCloudPolicyManagerChromeOS* GetManagerForProfile(Profile* profile); |
64 scoped_ptr<UserCloudPolicyManagerChromeOS> CreateManagerForProfile( | 66 scoped_ptr<UserCloudPolicyManagerChromeOS> CreateManagerForProfile( |
65 Profile* profile, | 67 Profile* profile, |
66 bool force_immediate_load); | 68 bool force_immediate_load); |
67 | 69 |
68 // ProfileKeyedBaseFactory: | 70 // BrowserContextKeyedBaseFactory: |
69 virtual void ProfileShutdown(content::BrowserContext* context) OVERRIDE; | 71 virtual void BrowserContextShutdown( |
70 virtual void ProfileDestroyed(content::BrowserContext* context) OVERRIDE; | 72 content::BrowserContext* context) OVERRIDE; |
| 73 virtual void BrowserContextDestroyed( |
| 74 content::BrowserContext* context) OVERRIDE; |
71 virtual void SetEmptyTestingFactory( | 75 virtual void SetEmptyTestingFactory( |
72 content::BrowserContext* context) OVERRIDE; | 76 content::BrowserContext* context) OVERRIDE; |
73 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; | 77 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; |
74 | 78 |
75 typedef std::map<Profile*, UserCloudPolicyManagerChromeOS*> ManagerMap; | 79 typedef std::map<Profile*, UserCloudPolicyManagerChromeOS*> ManagerMap; |
76 ManagerMap managers_; | 80 ManagerMap managers_; |
77 | 81 |
78 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactoryChromeOS); | 82 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactoryChromeOS); |
79 }; | 83 }; |
80 | 84 |
81 } // namespace policy | 85 } // namespace policy |
82 | 86 |
83 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHRO
MEOS_H_ | 87 #endif // CHROME_BROWSER_CHROMEOS_POLICY_USER_CLOUD_POLICY_MANAGER_FACTORY_CHRO
MEOS_H_ |
OLD | NEW |