OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ |
6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 6 #define CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_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/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/singleton.h" | 12 #include "base/memory/singleton.h" |
13 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_base_fa
ctory.h" |
14 | 14 |
15 class Profile; | 15 class Profile; |
16 | 16 |
17 namespace base { | 17 namespace base { |
18 class SequencedTaskRunner; | 18 class SequencedTaskRunner; |
19 } | 19 } |
20 | 20 |
| 21 namespace content { |
| 22 class BrowserContext; |
| 23 } |
| 24 |
21 namespace policy { | 25 namespace policy { |
22 | 26 |
23 class UserCloudPolicyManager; | 27 class UserCloudPolicyManager; |
24 | 28 |
25 // BrowserContextKeyedBaseFactory implementation for UserCloudPolicyManager | 29 // BrowserContextKeyedBaseFactory implementation for UserCloudPolicyManager |
26 // instances that initialize per-profile cloud policy settings on the desktop | 30 // instances that initialize per-profile cloud policy settings on the desktop |
27 // platforms. | 31 // platforms. |
28 // | 32 // |
29 // UserCloudPolicyManager is handled different than other | 33 // UserCloudPolicyManager is handled different than other |
30 // BrowserContextKeyedServices because it is a dependency of PrefService. | 34 // BrowserContextKeyedServices because it is a dependency of PrefService. |
(...skipping 12 matching lines...) Expand all Loading... |
43 | 47 |
44 // Returns the UserCloudPolicyManager instance associated with |profile|. | 48 // Returns the UserCloudPolicyManager instance associated with |profile|. |
45 static UserCloudPolicyManager* GetForProfile(Profile* profile); | 49 static UserCloudPolicyManager* GetForProfile(Profile* profile); |
46 | 50 |
47 // Creates an instance for |profile|. Note that the caller is responsible for | 51 // Creates an instance for |profile|. Note that the caller is responsible for |
48 // managing the lifetime of the instance. Subsequent calls to GetForProfile() | 52 // managing the lifetime of the instance. Subsequent calls to GetForProfile() |
49 // will return the created instance as long as it lives. | 53 // will return the created instance as long as it lives. |
50 // | 54 // |
51 // If |force_immediate_load| is true, policy is loaded synchronously from | 55 // If |force_immediate_load| is true, policy is loaded synchronously from |
52 // UserCloudPolicyStore at startup. | 56 // UserCloudPolicyStore at startup. |
53 static scoped_ptr<UserCloudPolicyManager> CreateForProfile( | 57 static scoped_ptr<UserCloudPolicyManager> CreateForOriginalProfile( |
54 Profile* profile, | 58 Profile* profile, |
55 bool force_immediate_load, | 59 bool force_immediate_load, |
56 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 60 scoped_refptr<base::SequencedTaskRunner> background_task_runner); |
57 | 61 |
| 62 static UserCloudPolicyManager* RegisterForOffTheRecordProfile( |
| 63 Profile* original_profile, |
| 64 Profile* off_the_record_profile); |
| 65 |
58 private: | 66 private: |
59 friend class UserCloudPolicyManager; | 67 friend class UserCloudPolicyManager; |
60 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>; | 68 friend struct DefaultSingletonTraits<UserCloudPolicyManagerFactory>; |
61 | 69 |
62 UserCloudPolicyManagerFactory(); | 70 UserCloudPolicyManagerFactory(); |
63 virtual ~UserCloudPolicyManagerFactory(); | 71 virtual ~UserCloudPolicyManagerFactory(); |
64 | 72 |
65 // See comments for the static versions above. | 73 // See comments for the static versions above. |
66 UserCloudPolicyManager* GetManagerForProfile(Profile* profile); | 74 UserCloudPolicyManager* GetManagerForProfile( |
67 scoped_ptr<UserCloudPolicyManager> CreateManagerForProfile( | 75 content::BrowserContext* context); |
| 76 |
| 77 scoped_ptr<UserCloudPolicyManager> CreateManagerForOriginalProfile( |
68 Profile* profile, | 78 Profile* profile, |
69 bool force_immediate_load, | 79 bool force_immediate_load, |
70 scoped_refptr<base::SequencedTaskRunner> background_task_runner); | 80 scoped_refptr<base::SequencedTaskRunner> background_task_runner); |
71 | 81 |
| 82 UserCloudPolicyManager* RegisterManagerForOffTheRecordProfile( |
| 83 Profile* original_profile, |
| 84 Profile* off_the_record_profile); |
| 85 |
72 // BrowserContextKeyedBaseFactory: | 86 // BrowserContextKeyedBaseFactory: |
73 virtual void BrowserContextShutdown( | 87 virtual void BrowserContextShutdown( |
74 content::BrowserContext* profile) OVERRIDE; | 88 content::BrowserContext* context) OVERRIDE; |
75 virtual void SetEmptyTestingFactory( | 89 virtual void SetEmptyTestingFactory( |
76 content::BrowserContext* profile) OVERRIDE; | 90 content::BrowserContext* context) OVERRIDE; |
77 virtual void CreateServiceNow(content::BrowserContext* profile) OVERRIDE; | 91 virtual void CreateServiceNow(content::BrowserContext* context) OVERRIDE; |
78 | 92 |
79 // Invoked by UserCloudPolicyManager to register/unregister instances. | 93 // Invoked by UserCloudPolicyManager to register/unregister instances. |
80 void Register(Profile* profile, UserCloudPolicyManager* instance); | 94 void Register(content::BrowserContext* context, |
81 void Unregister(Profile* profile, UserCloudPolicyManager* instance); | 95 UserCloudPolicyManager* instance); |
| 96 void Unregister(content::BrowserContext* context, |
| 97 UserCloudPolicyManager* instance); |
82 | 98 |
83 typedef std::map<Profile*, UserCloudPolicyManager*> ManagerMap; | 99 typedef std::map<content::BrowserContext*, UserCloudPolicyManager*> |
| 100 ManagerMap; |
| 101 |
84 ManagerMap managers_; | 102 ManagerMap managers_; |
85 | 103 |
86 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory); | 104 DISALLOW_COPY_AND_ASSIGN(UserCloudPolicyManagerFactory); |
87 }; | 105 }; |
88 | 106 |
89 } // namespace policy | 107 } // namespace policy |
90 | 108 |
91 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ | 109 #endif // CHROME_BROWSER_POLICY_CLOUD_USER_CLOUD_POLICY_MANAGER_FACTORY_H_ |
OLD | NEW |